literals_semantics error

Augmented assignment widens Literal type

When a function parameter is annotated with Literal..., augmented assignment (+=, -=, etc.) effectively reassigns the variable to a widened type (e.g. int instead of Literal3, 4, 5), violating the declared Literal constraint.

def func(a: Literal[3, 4, 5]):
    a += 3  # E0100 — augmented assign widens Literal type

How to handle it

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