generic-class
What it does
Section titled “What it does”Reports a class that has Generic[...] among its bases when the target_version has type parameters (3.12 and later).
Why it matters
Section titled “Why it matters”Since Python 3.12 a class declares its type variables in the header, class Box[T]:, and the TypeVar and the Generic base are no longer needed. The old form needs a separate declaration that can be mistaken for an unrelated variable.
To fix, move the type variables to the class header.
Example
Section titled “Example”...
from typing import Generic, TypeVarT = TypeVar("T")class A(Generic[T]): pass
from typing import TypeVar...Configuration
Section titled “Configuration”python: lint: rules: generic-class: warn # off (default), warn, errorEnabled by the presets: python/ruff.
Suppress one line with sudsy-disable-next-line generic-class in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| ruff | UP046 |
full |