explicit-return-none
What it does
Section titled “What it does”Reports return None in a function whose other returns, if any, return nothing or None. A function that is a generator, one whose only statement is return None, a property and a function annotated with anything but None are left alone.
Why it matters
Section titled “Why it matters”A function without a value returns None anyway, so the word adds nothing. The explicit form is needed where another return has a value, to tell the reader that None is meant, and that case is not reported.
To fix, write return, or remove it at the end of the function.
Example
Section titled “Example”...
... if x: return None print(x)
x = 1...Configuration
Section titled “Configuration”python: lint: rules: explicit-return-none: warn # off (default), warn, errorEnabled by the presets: python/ruff.
Suppress one line with sudsy-disable-next-line explicit-return-none 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 | RET501 |
full |