-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
Mypy fails to check recursive/cyclic type aliases, even with #731 being part of v0.991. However, this happens on Python 3.8 and 3.9 only (and possibly below), but not on 3.10 or 3.11.
Example:
RecursiveTypeAlias: TypeAlias = Union[bool, int, float, str, Sequence['RecursiveTypeAlias']]for which mypy raises error: Cannot resolve name "RecursiveTypeAlias" (possible cyclic definition) [misc].
To Reproduce
- Create an environment with:
- Mypy v0.991
- Python 3.8 or 3.9
- typing_extensions 4.4.0
- Create a Python file with the offending type alias. See https://github.com/bartfeenstra/mypy-type-alias/blob/main/mypy-type-alias/main.py for additional imports for cross-Python-version compatibility.
- Run mypy without any additional options or arguments
Alternatively, clone https://github.com/bartfeenstra/mypy-type-alias and run tox.
Expected Behavior
Mypy not raising any errors for recursive/cyclig type aliases and correctly parsing them as it does on Python 3.10 and 3.11.
Actual Behavior
Mypy fails on recursive/cyclic type aliases with the error error: Cannot resolve name "RecursiveTypeAlias" (possible cyclic definition) [misc].
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong