generics_upper_bound
error
TypeVar upper bound violation at call site
When a function parameter is annotated with a TypeVar that has an upper bound (e.g. bound=Sized), and the call site passes a literal value whose type does not satisfy that bound, Basilisk reports the violation.
from typing import Sized, TypeVar
ST = TypeVar("ST", bound=Sized)
def longer(x: ST, y: ST) -> ST:
if len(x) > len(y):
return x
return y
longer(3, 3) # E -- int does not implement Sized (__len__)
How to handle it
Every rule is on by default — strict is the default, not a cage. You can dial
generics_upper_bound 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