Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unnecessary-lambda false positive if parameter is used in lambda body #8496

Closed
cherryblossom000 opened this issue Mar 27, 2023 · 0 comments · Fixed by #8498, #8521 or #9093
Closed

unnecessary-lambda false positive if parameter is used in lambda body #8496

cherryblossom000 opened this issue Mar 27, 2023 · 0 comments · Fixed by #8498, #8521 or #9093
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code unnecessary-lambda
Milestone

Comments

@cherryblossom000
Copy link
Contributor

cherryblossom000 commented Mar 27, 2023

Bug description

A unnecessary-lambda warning is created for lambda expressions which use one of its parameters in its body, for example:

# pylint: disable=expression-not-assigned,missing-module-docstring,undefined-variable
lambda x: x(x)

My real code was something like

lambda foo, bar: (function1 if bar == 1 else function2)(foo, bar)

Configuration

No response

Command used

pylint tmp.py

Pylint output

************* Module tmp
tmp.py:2:0: W0108: Lambda may not be necessary (unnecessary-lambda)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

Expected behavior

No warning

Pylint version

pylint 2.17.0
astroid 2.15.0
Python 3.11.2 (main, Mar 17 2023, 12:30:14) [Clang 14.0.0 (clang-1400.0.29.202)]

OS / Environment

No response

Additional dependencies

No response

@cherryblossom000 cherryblossom000 added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Mar 27, 2023
@nickdrozd nickdrozd added False Positive 🦟 A message is emitted but nothing is wrong with the code unnecessary-lambda and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Mar 27, 2023
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.17.2 milestone Mar 27, 2023
Pierre-Sassoulas pushed a commit that referenced this issue Mar 28, 2023
github-actions bot pushed a commit that referenced this issue Mar 28, 2023
…ers in their body (#8498)

Fixes #8496

(cherry picked from commit b621436)
Pierre-Sassoulas pushed a commit that referenced this issue Mar 28, 2023
…ers in their body (#8498) (#8506)

Fixes #8496

(cherry picked from commit b621436)

Co-authored-by: cherryblossom <31467609+cherryblossom000@users.noreply.github.com>
This was referenced Mar 31, 2023
DifferentialOrange added a commit to tarantool/tarantool-python that referenced this issue Oct 3, 2023
Disable unnecessary-lambda lint warning in test. The warning had been
uncovered since pylint 3.0.0, but it's not clear what exactly is
the reason since the only CHANGELOG entry related to unnecessary-lambda
declares that false positive cases were fixed [1].

1. pylint-dev/pylint#8496
DifferentialOrange added a commit to tarantool/tarantool-python that referenced this issue Oct 3, 2023
Disable unnecessary-lambda lint warning in test. The warning had been
uncovered since pylint 3.0.0, but it's not clear what exactly is
the reason since the only CHANGELOG entry related to unnecessary-lambda
declares that false positive cases were fixed [1].

1. pylint-dev/pylint#8496
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code unnecessary-lambda
Projects
None yet
3 participants