unnecessary-lambda-assignment / C3001ΒΆ

Message emitted:

Lambda expression assigned to a variable. Define a function using the "def" keyword instead.


Used when a lambda expression is assigned to variable rather than defining a standard function with the "def" keyword.

Problematic code:

foo = lambda x: x**2 + 2 * x + 1  # [unnecessary-lambda-assignment]

Correct code:

def foo(x):
    return x**2 + 2 * x + 1

Created by the lambda-expressions checker.