nested-with
What it does
Section titled “What it does”Reports a with whose only statement is another with, when both are sync or both are async.
Why it matters
Section titled “Why it matters”One with can open several context managers (with a, b:), which saves an indent level and the long lines that nesting forces.
To fix, join the two into one with.
Example
Section titled “Example”...
...
with a:... pass
...Configuration
Section titled “Configuration”python: lint: rules: nested-with: warn # off (default), warn, errorEnabled by the presets: python/ruff.
Suppress one line with sudsy-disable-next-line nested-with 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 | SIM117 |
full |