any-eq-parameter
What it does
Section titled “What it does”Reports an __eq__ or __ne__ method whose second parameter is annotated Any.
Why it matters
Section titled “Why it matters”Python calls __eq__ with any object on the right, so the accurate type is object. With Any a type checker accepts other.value without a check and the method fails at run time on a value of another type.
To fix, annotate other: object and check its type before using it.
Example
Section titled “Example”...
from typing import Any... def __eq__(self, other: Any) -> bool: return True
from typing import TypeVar...Configuration
Section titled “Configuration”python: lint: rules: any-eq-parameter: warn # off (default), warn, errorEnabled by the presets: python/ruff.
Suppress one line with sudsy-disable-next-line any-eq-parameter 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 | PYI032 |
full |