-
Notifications
You must be signed in to change notification settings - Fork 6k
[Bug]: Type hint error because of improper field definition #18856
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The type hint error you're seeing with In the current implementation, both For reference, the constructor for def __init__(
...,
max_tokens: Optional[int] = None,
...,
api_version: Optional[str] = None,
...
) However, if the class attribute for Making both fields explicitly optional and giving them default values both in the class attribute definition and the constructor should resolve the type checker confusion. This approach is consistent with how similar parameters are handled in related classes, such as To summarize:
If you have control over the code, updating the class definition as described should fix the type hint errors. If not, you may want to raise this as a bug or feature request with the maintainers. To reply, just mention my name @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
PR very welcome @medihack |
Bug Description
When using
OpenAILike
type checker like pyright argue about missingmax_tokens
andapi_version
parameters. This is not the case whenOpenAI
(whichOpenAILike
inherits from).The reason is that for example
api_version
field is not optional and does not have a default value, but is indirectly set as optional in the constructor. This unfortunately confuses the type checker. Why not make both fields optional and give them a default?Version
llama-index-llms-openai-like v0.3.5, lama-index-llms-openai v0.3.42
Steps to Reproduce
When using
pyright tells me
max_tokens
andapi_version
is missing.Relevant Logs/Tracbacks
The text was updated successfully, but these errors were encountered: