type-check-without-type-error
What it does
Section titled “What it does”Reports a branch tested with isinstance, issubclass or callable that raises a builtin exception other than TypeError (NotImplementedError is accepted too).
Why it matters
Section titled “Why it matters”A value of the wrong type is what TypeError means, and callers catch it for that case. A ValueError or Exception there makes them handle a type mistake as a bad value.
To fix, raise TypeError.
Example
Section titled “Example”...
... raise ValueError("x")
... if x:...Configuration
Section titled “Configuration”python: lint: rules: type-check-without-type-error: warn # off (default), warn, errorEnabled by the presets: python/ruff.
Suppress one line with sudsy-disable-next-line type-check-without-type-error 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 | TRY004 |
full |