BSK-E0045
error
Invalid first argument to Annotated...
PEP 593 requires that the first argument to Annotated... be a valid type expression. The following are errors:
- List literals: Annotated[int, str, ""] - Tuple literals: Annotated((int, str),), "" - Dict literals: Annotated{"a": "b"}, "" - List comprehensions: Annotated[x for x in ..., ""] - Lambda calls: Annotated(lambda: int)(), "" - Conditional expressions: Annotatedint if cond else str, "" - Boolean literals: AnnotatedTrue, "" - Integer literals: Annotated1, "" - Binary boolean operators: Annotatedlist or set, "" - F-strings: Annotatedf"...", "" - Subscript-into-subscript: Annotated[int0, ""]
Additionally, Annotatedint with fewer than 2 arguments is an error, and calling Annotated directly (bare or parameterized) is always invalid.
Bad1: Annotated[[int, str], ""] # E — list literal not valid type
Bad9: Annotated[True, ""] # E — bool literal not valid type
Bad13: Annotated[int] # E — requires at least two arguments
Annotated() # E — Annotated is not callable
SmallInt(1) # E — TypeAlias is not callable
How to handle it
Every rule is on by default — strict is the default, not a cage. You can dial
BSK-E0045 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-E0045