-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
isinstance inference not working in closures #4679
Comments
This is a known issue; it's somewhat of a feature because sometimes the closure variable can change its value (and hence type) again before the function is called (e.g. consider if your code has |
Related to this. I would like to write code similar to this one
Maybe the case for anonymous function is easier? |
OTOH the way mypy treats lambda is different from regular functions. Until
someone (not me) tries to implement this I have no idea what's easy or not
in this case.
|
Giving it a second thought, I think is it equally easy to invalidates things for lambdas than for regular functions. |
I ran into this as well:
In this case the closure isn't going to change. I wonder if we can infer that. |
This is actually a duplicate of #2608 (already high priority). Yes, one of proposed solutions was to use the binder, if e.g. the inner function appears at the end of the outer function, so the closure can't change. |
In the code:
this warning is wrongly emitted:
The text was updated successfully, but these errors were encountered: