aliases_typealiastype error

Invalid TypeAliasType(...) call

Detects violations in TypeAliasType(...) calls:

1. **Invalid type expression**: The value argument is not a valid type form (e.g. a list literal, dict literal, lambda, conditional expression).

2. **Circular reference**: The alias value references itself directly or through a forward-reference string.

3. **Undeclared type variable**: A TypeVar / ParamSpec / TypeVarTuple used in the value is not listed in type_params.

4. **Non-literal type_params**: The type_params keyword argument is not a literal tuple expression.

from typing import TypeAliasType, TypeVar

T = TypeVar("T")
S = TypeVar("S")

Bad1 = TypeAliasType("Bad1", [int, str])        # E: list is not a type expression
Bad2 = TypeAliasType("Bad2", "Bad2")             # E: circular reference
Bad3 = TypeAliasType("Bad3", list[S], type_params=(T,))  # E: S not in type_params
Bad4 = TypeAliasType("Bad4", int, type_params=my_tuple)  # E: not a literal tuple

How to handle it

Every rule is on by default — strict is the default, not a cage. You can dial aliases_typealiastype 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_typealiastype