-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
mypy ignores annotated types in various circumstances #4636
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
|
Thanks, adding the return type appears to help superficially (I've spent hours at trying to figure this out), I find it difficult to understand the logic of this? Basically if the scoping function has no return type annotation, things 'sort' of work, but strangely/incorrectly? (In any case, If the return type annotation is so critically important, it would be helpful if mypy would notify about it) |
There is an open issues about this (#3948) with some discussion. The documentation could be a bit clearer about this. Mypy doesn't type check functions without annotations to avoid generating spurious errors for partially annotated legacy code. |
Edit: some of the error messages here later turned out not to be related to mypy, see this comment.
Sorry if duplicate! (I wasn't sure what keywords to use to search this)
(using mypy
0.560
)The following doesn't error:
but this does:
And it gets even more bizarre:
However:
And if the argument to
f
has a type unknown to mypy, it doesn't error as well (this is the form which I originally discovered this behavior):The text was updated successfully, but these errors were encountered: