- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 3k
Labels
Description
Crash Report & To Reproduce
See mypy Playground (reproduces on both 1.15 and 1.16).
The motivation in this snippet is to avoid runtime imports from typing.
# mypy: always-false=INTERNAL_DEVELOPMENT_FLAG
TYPE_CHECKING: Final = False
INTERNAL_DEVELOPMENT_FLAG: Final = False
if TYPE_CHECKING:
    from typing_extensions import TypeAliasType, Final, TypeVar
    T1 = TypeVar("T1")
    T2 = TypeVar("T2", default=T1)
    if INTERNAL_DEVELOPMENT_FLAG:
        Alias = TypeAliasType("Alias", "MyClass", type_params=(T1, T2))
    else:
        Alias = TypeAliasType("Alias", T1, type_params=(T1, T2))
class MyClass(tuple["T1", "T2"]): ...The crash seems to be avoidable if the flags aren't annotated with Final, or the typing.* imports aren't under one of the flags.
Traceback
Deferral trace:
    __main__:3
    __main__:3
    __main__:3
    __main__:3
    __main__:3
    __main__:4
    __main__:4
    __main__:4
    __main__:4
    __main__:4
    __main__:13
    __main__:13
    __main__:13
    __main__:13
    __main__:13
    __main__:13
    __main__:13
    __main__:13
    __main__:13
    __main__:13
    __main__:13
    __main__:13
    __main__:13
    __main__:13
    __main__:13
    __main__:13
    __main__:13
    __main__:13
    __main__:13
main.py: error: INTERNAL ERROR: maximum semantic analysis iteration count reached
Found 1 error in 1 file (errors prevented further checking)
Your Environment
- Mypy version used: 1.15, 1.16
- Mypy command-line flags: --show-traceback
- Mypy configuration options from mypy.ini(and other config files): None
- Python version used: 3.9, 3.12