BSK-E0149 error

PEP 695 generic type parameter scoping violations

Detects violations of PEP 695 type-parameter scoping rules, driven entirely by ruff_python_ast nodes (via basilisk_resolver::Pep695Scoping) — never by raw source.lines() scanning, so docstring/comment/string content is never mistaken for real class / def / type declarations.

1. A type parameter's bound references another type parameter in the same list (forward or backward reference). 2. A type parameter is used at module scope (2a) or in a decorator applied to the generic construct that declares it (2b). 3. A method re-declares an enclosing class's type parameter (shadowing). 4. A type statement references an old-style TypeVar. 5. A type statement appears inside a function body. 6. A type alias is circular. 7. A type alias is misused (called, subclassed, isinstance, attribute). 8. A type argument violates a bounded alias type parameter.

class ClassA[S, T: Sequence[S]]: ...  # E — T's bound references S
print(T)                              # E — T not defined at module scope

@decorator(Foo[T])                    # E — T not in scope in the decorator
class ClassD[T]: ...

class ClassE[T]:
    def method1[T](self): ...         # E — method re-defines class type param

Reference: <https://peps.python.org/pep-0695/#type-parameter-scopes>

How to handle it

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