We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Bug Report
When defining a nested function under a branch that accesses argument passed to outer function, the type narrowing resets to the original type.
To Reproduce
See the playground. Code posted here as well.
from functools import wraps from typing import Any, Callable def d(f: Callable[..., Any] | None) -> None: if f is not None: # <-- narrowed to Callable def inner() -> Any: return f() # <-- resolved as Callable | None return None
Expected Behavior
Inner function retains narrowed type.
Actual Behavior
Function f's type is resolved as Callable | None leading to this error:
f
Callable | None
main.py:9: error: "None" not callable [misc]
Your Environment
--strict
mypy.ini
The text was updated successfully, but these errors were encountered:
Duplicate of #2608
Sorry, something went wrong.
(Your code type checks fine on mypy master. The fix for #2608 will be available in the next release of mypy :)
No branches or pull requests
Bug Report
When defining a nested function under a branch that accesses argument passed to outer function, the type narrowing resets to the original type.
To Reproduce
See the playground. Code posted here as well.
Expected Behavior
Inner function retains narrowed type.
Actual Behavior
Function
f
's type is resolved asCallable | None
leading to this error:Your Environment
--strict
mypy.ini
(and other config files): no additional configThe text was updated successfully, but these errors were encountered: