generics_syntax_compatibility error

PEP 695 type parameter syntax mixed with traditional TypeVars

PEP 695 introduced a new syntax for declaring type parameters (class FooT and def fooT()). When a class or function uses this new syntax, it must not reference traditional TypeVar instances from an outer scope in its base classes or parameter annotations.

from typing import TypeVar

K = TypeVar("K")

class ClassA[V](dict[K, V]):  # E: traditional TypeVar K used with PEP 695 syntax
    ...

How to handle it

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