generics_upper_bound_2 error

TypeVar bound violation at call site

When a function has a parameter typed with a TypeVar that has a bound, and a call passes an argument whose type is not a subtype of that bound, this rule reports the mismatch.

TLiteral = TypeVar("TLiteral", bound=LiteralString)

def literal_identity(s: TLiteral) -> TLiteral:
    return s

def func5(s: str):
    literal_identity(s)  # E — str is not a subtype of LiteralString

How to handle it

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