aliases_recursive
error
Cyclical type alias reference
A TypeAlias-annotated assignment whose RHS contains a forward-reference string that resolves back to the alias itself (directly or through a chain of mutual references) creates an infinite type that cannot be resolved.
from typing import TypeAlias, Union
# Direct self-reference — the Union *only* wraps itself and a base type,
# producing an infinitely expanding alias:
RecursiveUnion: TypeAlias = Union["RecursiveUnion", int] # E
# Mutual reference — two aliases reference each other:
A: TypeAlias = Union["B", int]
B: TypeAlias = Union["A", str] # E
How to handle it
Every rule is on by default — strict is the default, not a cage. You can dial
aliases_recursive down per-file or per-path from your editor or
pyproject.toml, or fix the code
so it type-checks. See the Type System rules and
the complete diagnostic reference.
Canonical URL: https://www.basilisk-python.dev/errors/aliases_recursive