pycodestyle icon indicating copy to clipboard operation
pycodestyle copied to clipboard

E731: assignment of lambda is not detected if parenthesized

Open anntzer opened this issue 6 years ago • 0 comments

$ 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.

anntzer avatar May 30 '19 13:05 anntzer