BSK-E0048 error

Invalid right-hand side for a TypeAlias annotation

PEP 613 requires that the RHS of an explicit TypeAlias annotation must be a valid type expression. The following are errors:

- List literals: x: TypeAlias = int, str - Tuple literals: x: TypeAlias = ((int, str),) - Dict literals: x: TypeAlias = {"a": "b"} - List comprehensions: x: TypeAlias = int for i in range(1) - Lambda calls: x: TypeAlias = (lambda: int)() - Conditional expressions: x: TypeAlias = int if cond else str - Boolean literals: x: TypeAlias = True - Integer literals: x: TypeAlias = 1 - Binary boolean operators: x: TypeAlias = list or set - F-strings: x: TypeAlias = f"..." - Subscript-into-subscript: x: TypeAlias = int0 - Runtime calls: x: TypeAlias = eval("int")

from typing import TypeAlias
BadTypeAlias2: TypeAlias = [int, str]   # E — list literal
BadTypeAlias10: TypeAlias = True         # E — bool literal

How to handle it

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