You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeAlias does not work when attribute-accessed from the typing_extensions package #12179
G: ASDF="G"# error: Incompatible types in assignment (expression has type "Literal['G']", variable has type "Union[Literal['A'], Literal['S'], Literal['D'], Literal['F']]")H: JKL="H"# error: Incompatible types in assignment (expression has type "Literal['H']", variable has type "Union[Literal['J'], Literal['K'], Literal['L']]")n: Int="9"# error: Incompatible types in assignment (expression has type "str", variable has type "int")s: Str=9# error: Incompatible types in assignment (expression has type "int", variable has type "str")
Actual Behavior
The aliases JKL and Int, typed using tpx.TypeAlias, do not trigger errors with mypy:
G: ASDF="G"# error: Incompatible types in assignment (expression has type "Literal['G']", variable has type "Union[Literal['A'], Literal['S'], Literal['D'], Literal['F']]")H: JKL="H"# Expected error here; got nonen: Int="9"# Expected error here; got nones: Str=9# error: Incompatible types in assignment (expression has type "int", variable has type "str")
Your Environment
Mypy version used: 0.931
Mypy command-line flags: None
Mypy configuration options from mypy.ini (and other config files):
Yikes, this is pretty bad. Thanks for the report. I think the issue isn't about typing_extensions vs typing (which tests cover), but rather the import alias. That is, tp.TypeAlias fails as well. Looks easy to fix, though!
Activity
hauntsaninja commentedon Feb 15, 2022
Yikes, this is pretty bad. Thanks for the report. I think the issue isn't about typing_extensions vs typing (which tests cover), but rather the import alias. That is,
tp.TypeAliasfails as well. Looks easy to fix, though!Fix use of TypeAlias from aliased imports
Fix use of TypeAlias from aliased imports (#12180)