Redundant lambda definitions

Avoid unnecessarily wrapping a function in a lambda

Avoid defining a lambda function which passes through of it is arguments to another callable. You can instead safely directly call the callable.

If our GitHub code review bot spots this issue in your pull request it gives this advice:

code-review-doctorbotsuggested changes just now
foo = lambda x: bar(x)
Suggested changes
foo = lambda x: bar(x)
foo = bar
Commit suggestion

Avoid unnecessarily wrapping a function in a lambda

Read more
We're your Python code review copilot. Get code improvements right in your pull request with our GitHub code review bot.

Configuring this check

Code Review Doctor will run this check by default. No configuration is needed but the check can be turned on/off using check code avoid-redundant-lambda-definition in your pyproject.toml file.

Read more about configuring Code Review Doctor.