Skip to content
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

typing.TypeAliasType cannot be used to declare self-referential types #18252

Open
bzoracler opened this issue Dec 6, 2024 · 0 comments
Open
Labels
bug mypy got something wrong topic-pep-695 Issues related to PEP 695 syntax topic-recursive-types

Comments

@bzoracler
Copy link
Contributor

Bug Report, To Reproduce, & Actual Behaviour

See mypy Playground:

type T = dict[str, "T"]  # OK

from typing import TypeAliasType

T2 = TypeAliasType("T2", dict[str, "T2"])  # E: Cannot resolve name "T2" (possible cyclic definition)  [misc]

Expected Behavior

Self-referential type successfully declared

Your Environment

  • Mypy version used: 1.13.0
  • Mypy command-line flags: (none)
  • Mypy configuration options from mypy.ini (and other config files): (none)
  • Python version used: 3.12
@bzoracler bzoracler added the bug mypy got something wrong label Dec 6, 2024
@brianschubert brianschubert added topic-recursive-types topic-pep-695 Issues related to PEP 695 syntax labels Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-pep-695 Issues related to PEP 695 syntax topic-recursive-types
Projects
None yet
Development

No branches or pull requests

2 participants