-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Type inferred from assertion somehow gets lost in lambda expression #4973
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
Type restrictions in mypy don't propagate to nested functions, see e.g. #2608, and lambda is a nested function. I think however this is not a duplicate since this use case is unrelated to |
I have a similar test case, that uses Mypy version: 0.620
Only |
This is something that is happening a lot with me, in which I am writing interpreters for tree-like structures and need lambdas to create laziness in its evaluation. Having to access fields outside lambdas triples the number of lines of the files, and becomes more unreadable. |
This will usually be fixed by the same heuristics that were good enough for #2608 |
This works:
This gives an error:
Error message:
Mypy version:
0.590
Python version:
3.6.3
I believe the second example should not raise any errors when checked by mypy.
The code obviously makes no sense. I prepared the examples in order to explain the issue.
The text was updated successfully, but these errors were encountered: