default-except-not-last
What it does
Section titled “What it does”Reports a bare except: that is followed by another handler of the same try.
Why it matters
Section titled “Why it matters”A bare except: catches everything, so the handlers after it can never run. Python rejects the file with SyntaxError: default 'except:' must be last.
To fix, put the bare except: last, or better, name the exceptions it should catch.
Example
Section titled “Example”A = B = 1try: passexcept: passexcept A: pass...Configuration
Section titled “Configuration”python: lint: rules: default-except-not-last: warn # off, warn (default), errorEnabled by the presets: python/ruff.
Suppress one line with sudsy-disable-next-line default-except-not-last 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 | F707 |
full |