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
typing_extensions.NewType annotations are not recognized on < 3.10 (regression in 1.4.0) #16297
Mypy 1.4.0 introduced a regression where typing_extensions.NewType annotations are not correctly recognized when --python-version < 3.10.
this bisects to python/typeshed@a6d0aaf via python/typeshed#10205 via #15334. however this does not appear to be a typeshed issue; it's just that the typeshed change exposed a previously-hidden Mypy issue.
To Reproduce
# run with --python-version=3.9 or below, using mypy d11db28 or 1.4 or laterfromtyping_extensionsimportNewTypeN=NewType("N", int)
x: N# error: Variable "eg_newtype.N" is not valid as a type [valid-type]
Expected Behavior
Mypy passes this example.
Actual Behavior
Mypy fails this example; see above.
Your Environment
Mypy version used: 1.6.1 (compiled) and current master (uncompiled)
Mypy command-line flags: --python-version=3.9
Mypy configuration options from mypy.ini (and other config files): none (i.e. using vendored typeshed)
Activity
Correctly recognize `typing_extensions.NewType` (#16298)