type-var-name-variance
What it does
Section titled “What it does”Reports a TypeVar with covariant=True whose name does not end in _co, or with contravariant=True and a name that does not end in _contra.
Why it matters
Section titled “Why it matters”The suffixes are the convention of the typing documentation and of the standard library stubs. A reader sees the variance in every annotation that uses the name, without finding the declaration.
To fix, rename the variable with the suffix.
Example
Section titled “Example”... return True
from typing import TypeVarT = TypeVar("T", covariant=True)Configuration
Section titled “Configuration”python: lint: rules: type-var-name-variance: warn # off (default), warn, errorEnabled by the presets: python/ruff.
Suppress one line with sudsy-disable-next-line type-var-name-variance 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 | PLC0105 |
full |