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

Fix unnecessary-lambda false positive for lambdas using its parameters in their body #8498

Merged
merged 2 commits into from
Mar 28, 2023

Conversation

cherryblossom000
Copy link
Contributor

Type of Changes

Type
🐛 Bug fix

Description

Closes #8496

@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code backport maintenance/3.3.x labels Mar 27, 2023
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.17.2 milestone Mar 27, 2023
@codecov
Copy link

codecov bot commented Mar 27, 2023

Codecov Report

Merging #8498 (5e7256f) into main (4aae943) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #8498   +/-   ##
=======================================
  Coverage   95.81%   95.81%           
=======================================
  Files         174      174           
  Lines       18334    18337    +3     
=======================================
+ Hits        17567    17570    +3     
  Misses        767      767           
Impacted Files Coverage Δ
pylint/checkers/base/basic_checker.py 97.88% <100.00%> (+0.01%) ⬆️

@github-actions

This comment has been minimized.

@cherryblossom000
Copy link
Contributor Author

I refactored the unnecessary-lambda code a little because of the lint warning

pylint/checkers/base/basic_checker.py:522:4: R0911: Too many return statements (12/11) (too-many-return-statements)

@nickdrozd
Copy link
Contributor

The max-returns limit is set in pylintrc. You can just bump that number instead of rewriting everything. The function could certainly use a refactor, but that can be done in a separate PR.

@Pierre-Sassoulas
Copy link
Member

I'd rather disable this one message locally than change the setting for the whole code base.

@cherryblossom000
Copy link
Contributor Author

I’ve disabled the warning for that line.

@github-actions

This comment has been minimized.

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

@github-actions
Copy link
Contributor

🤖 Effect of this PR on checked open source code: 🤖

Effect on pandas:
The following messages are no longer emitted:

  1. unnecessary-lambda:
    Lambda may not be necessary
    https://github.com/pandas-dev/pandas/blob/10000db023208c1db0bba6a7d819bfe87dc49908/pandas/tests/resample/test_resampler_grouper.py#L294

This comment was generated for commit 5e7256f

@Pierre-Sassoulas
Copy link
Member

Amazing first contribution @cherryblossom000 ! This is going into the next patch version (2.17.2)

@Pierre-Sassoulas Pierre-Sassoulas merged commit b621436 into pylint-dev:main Mar 28, 2023
github-actions bot pushed a commit that referenced this pull request Mar 28, 2023
…ers in their body (#8498)

Fixes #8496

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

Fixes #8496

(cherry picked from commit b621436)

Co-authored-by: cherryblossom <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unnecessary-lambda false positive if parameter is used in lambda body
3 participants