hasattr-call
What it does
Section titled “What it does”Reports a call of hasattr or getattr that asks for "__call__".
Why it matters
Section titled “Why it matters”hasattr(x, "__call__") asks for the attribute on the object, which is not what Python does when it calls a value: it looks the method up on the type. The result can differ, and callable(x) is the test that matches the call.
To fix, write callable(x).
Example
Section titled “Example”...
...
hasattr(x, "__call__")Configuration
Section titled “Configuration”python: lint: rules: hasattr-call: warn # off, warn (default), errorEnabled by the presets: python/ruff.
Suppress one line with sudsy-disable-next-line hasattr-call 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 | B004 |
full |