-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
False negative: typing.Literal[<Union expression>] #17260
Copy link
Copy link
Open
Labels
bugmypy got something wrongmypy got something wrongsemantic-analyzerProblems that happen during semantic analysisProblems that happen during semantic analysistopic-literal-typestopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctly
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongsemantic-analyzerProblems that happen during semantic analysisProblems that happen during semantic analysistopic-literal-typestopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctly
Fields
Give feedbackNo fields configured for issues without a type.
Bug Report, To Reproduce, & Actual Behaviour
See mypy playground
For the runtime counterpart, this will result in a
TypeError: unsupported operand type(s) for |: 'int' and 'NoneType'if the module doesn't havefrom __future__ import annotationsor invalid results for runtime annotation inspectors (e.g. in the case oftyping.Literal[1 | 2]).Expected Behavior
Maybe:
Your Environment
mypy.ini(and other config files): None