pycodestyle
pycodestyle copied to clipboard
E731: assignment of lambda is not detected if parenthesized
$ cat foo.py
foo = lambda x: x
bar = (lambda x: x)
$ pycodestyle foo.py
foo.py:1:1: E731 do not assign a lambda expression, use a def
The second case is not detected. (A realistic case is when the parentheses are used for line continuation, e.g.
bar = (
lambda ...: ...
)
) Note that I agree that lambdas inside e.g. ternaries (#845) should not trigger a warning; this report is explicitly only for the case where a lambda is the sole thing being parenthesized.