-
Notifications
You must be signed in to change notification settings - Fork 81
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
mypy and type inference with @inject decorators #80
Comments
Hi Dennis, Could you give some examples, please? |
gives the error
|
Hi, this is definitely a problem for projects that use mypy and type linters. With these linters getting more popular, is there any suggestion how to make this library compatible? Wrapping in Optional[] is not really a great solution, because it forces checks for non None when the injected value is used. |
Hi @fibigerg Thank for you comment. I have very little knowledge about mypy or type linters. If some can find a solution and will make a PR, I will gladly merge it and release the next version. |
Any updates with this? |
Hi,
We've been making use of your library quite a lot and it's been a joy to use! The only challenge I've really run into is handling pyright/mypy errors with the
@inject
decorator. The decorator of course modifies the type signature of the function/classes, but pyright, mypy, pylint etc don't really have knowledge of this so they throw warnings that certain parameters are missing.Are there any workarounds to this? I've been trying to figure something out but so far it seems like the likely answer is "no". This is the closest microsoft/pyright#774
Other than that the only ideas I've come up is converting the injected parameters from required to optional. But that's a less than ideal solution since often time these are classes which can be expensive to instantiate, and performance matters for my application.
Best
The text was updated successfully, but these errors were encountered: