lambda-assignment
What it does
Section titled “What it does”Reports a lambda assigned to a single name. An annotated assignment in a class body is left alone.
Why it matters
Section titled “Why it matters”A def gives the function a real name in tracebacks and repr, takes annotations and a docstring, and reads as what it is. The lambda keeps its generic name, <lambda>.
To fix, write a def.
Example
Section titled “Example”h = 1f = lambda x: xg: int = lambda: 1h.attr = lambda: 1j = (lambda: 1)()k = [lambda: 1]Configuration
Section titled “Configuration”python: lint: rules: lambda-assignment: warn # off (default), warn, errorSuppress one line with sudsy-disable-next-line lambda-assignment 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 | E731 |
full |