Skip to content

Crash using forward-referencing type alias parameterised by dependent type variables #19186

Open
@bzoracler

Description

@bzoracler

Crash Report & To Reproduce

See mypy Playground.

This is a much less obscure example than #19185, and came about while trying to find workarounds for that snippet. I'm not sure if it's related.

from typing import Generic, TypeVar, TypeAlias

T1 = TypeVar("T1")
T2 = TypeVar("T2", default=T1)

Alias: TypeAlias = "MyClass[T1, T2]"

class MyClass(Generic["T1", "T2"]): ...

Traceback

Deferral trace:
    __main__:6
    __main__:6
    __main__:6
    __main__:-1
    __main__:6
    __main__:6
    __main__:6
    __main__:6
    __main__:6
    __main__:6
    __main__:6
    __main__:6
    __main__:6
    __main__:6
    __main__:6
    __main__:6
    __main__:6
    __main__:6
    __main__:6
    __main__:6
    __main__:6
    __main__:6
    __main__:6
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions