generics_base_class_3
error
Invariant generic type mismatch at call site
When a function parameter expects a parameterised generic like dictstr, list[object] and a subclass whose base parameterisation differs in an invariant position is passed, the call is invalid.
class SymbolTable(dict[str, list[Node]]): ...
def takes(x: dict[str, list[object]]): ...
def test(s: SymbolTable):
takes(s) # E -- list is invariant, list[Node] != list[object]
How to handle it
Every rule is on by default — strict is the default, not a cage. You can dial
generics_base_class_3 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_base_class_3