Derived from the Pylint linter.
Fix is always available.
This rule is unstable and in preview. The
--preview flag is required for use.
What it does#
lambda definitions that consist of a single function call
with the same arguments as the
Why is this bad?#
lambda is used to wrap a function call, and merely propagates
lambda arguments to that function, it can typically be replaced with
the function itself, removing a level of indirection.
This rule's fix is marked as unsafe in cases in which the lambda body itself contains an effect.
For example, replacing
lambda x, y: (func()(x, y)) with
lead to a change in behavior, as
func() would be evaluated eagerly when
defining the lambda, rather than when the lambda is called.
When the lambda body contains no visible effects, the fix is considered safe.