-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Silent type failure #978
Comments
When I try to type check the file, mypy says However, I'm not convinced that this is the best possible behavior when we can't find a stub. Maybe mypy should complain that (Of course, the best behavior would be to provide a stub for numpy, but some features in numpy make it difficult to provide a good stub.) |
Yes, I do see the Even better would be to support arbitrary class object regardless of stub status:
As long as the user always labels function returns for modules without stubs, that would enable this to be type checked properly:
|
Hmm... that would have the problem that mypy couldn't know about inheritance relationships and some other things, and it could complain about valid things. Giving a warning or error when trying to use a type defined in an unknown module is probably the least surprising thing to do. |
Makes sense. Perhaps then an approach is to follow the example by
|
Mypy will likely get a some sort of type checker plugin mechanism in the future. It's probably going to be needed for things like SQLAlchemy anyway. |
Great to hear! I think a plugin mechanism will be crucial for adoption, especially where stubs are difficult/not available. |
Let's close this issue; the plugin feature will be discussed in #1240. |
I have a function as follows:
It appears that 'np.ndarray' is being interpreted as 'Any'. Why is that? The type is failing silently.
Thanks,
Tyler
The text was updated successfully, but these errors were encountered: