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
Probably best illustrated with an example:
from typing import TypeVar, Union _T = TypeVar('_T') _U = TypeVar('_U') def f(x: Union[_T, int]) -> None: if isinstance(x, int): reveal_type(x) # int def g1() -> None: reveal_type(x) # Union[_T, int] (but expect int) else: reveal_type(x) # _T def g2() -> None: reveal_type(x) # Union[_T, int] (but expect _T)
The same also happens with Optional and if x is None, but I presume the type-checker doesn’t treat this as any different, anyway.
Optional
if x is None
Using:
[mypy] check_untyped_defs = True disallow_any_decorated = True disallow_any_expr = True disallow_any_unimported = True disallow_incomplete_defs = True disallow_subclassing_any = True disallow_untyped_calls = True disallow_untyped_decorators = True disallow_untyped_defs = True warn_return_any = True warn_unused_ignores = True
The text was updated successfully, but these errors were encountered:
Duplicate of #2608
Sorry, something went wrong.
Thanks for finding the duplicate; I searched but couldn’t find it myself :)
No branches or pull requests
Probably best illustrated with an example:
The same also happens with
Optional
andif x is None
, but I presume the type-checker doesn’t treat this as any different, anyway.Using:
The text was updated successfully, but these errors were encountered: