-
-
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
False positive for PEP 604 None | t
when used as value
#12368
Labels
Comments
I assume this means that |
@jhance Your assumption is correct. |
This looks similar to other raised issues 🤔 #12005 a: None | int
b = None | int # error: Unsupported left operand type for | ("None")
isinstance(5, None | int) # error: Unsupported left operand type for | ("None") #12369 is probably related as well. |
JukkaL
added a commit
that referenced
this issue
Nov 7, 2022
Fix Python 3.10 `|` union syntax in type aliases, when one of the operands is a type alias or a type with an overloaded `__init__`. We can now infer `typing._SpecialForm` for type aliases in a runtime context. Also create a bunch of minimal test-only stubs for stdlib modules to fix some test failures caused by the missing `typing._SpecialForm` in the default test stubs. This is generally what we want in any case, since using typeshed stubs with minimal builtins/typing stubs can result in unpredictable behavior and slow tests. Fixes #12368. Fixes #12005. Fixes #11426.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report
Using
None | t
instead oft | None
prompts an error when used as a value (not a type hint).https://peps.python.org/pep-0604/#proposal
To Reproduce
Expected Behavior
Mypy does not complain about the second line.
Your Environment
mypy.ini
(and other config files):The text was updated successfully, but these errors were encountered: