Lambda assigned to a name
Part of Code Quality & Syntax, which counts for 20% of the overall score. When this check fires it deducts 2 points from that category, once per scan, no matter how many places it turns up.
What it detects
Assigning a lambda to a name behaves like a function but loses a proper __name__ for debugging and tracebacks; PEP 8 recommends a def statement instead.
Why it matters
Assigning a lambda to a name (square = lambda x: x * x) behaves like a function but loses a proper __name__ for debugging and tracebacks, is limited to a single expression, and PEP 8 explicitly recommends a def statement instead for exactly this reason. It reads as if it should be a quick one-off, but once it has a name and is called from multiple places, it is functionally indistinguishable from a normal function and should just be one.
How to fix it
Convert the lambda to a regular function with def, for example def square(x): return x * x. Keep lambdas for genuinely anonymous, inline use such as a sort key or a callback passed directly as an argument, where they are never assigned to a name.
The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing
Does your repo trip this check?
Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.
Scan your repo