Skip to content

Fix false positive for 'used-before-assignment' with terminating func #7784

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

Merged
merged 2 commits into from
Nov 17, 2022

Conversation

clavedeluna
Copy link
Contributor

Type of Changes

Type
βœ“ πŸ› Bug fix

Description

Closes #7563

If a terminating func such as sys.exit, quit, etc is used in an else statement, used-before-assignment should not be flagged.

@coveralls
Copy link

coveralls commented Nov 17, 2022

Pull Request Test Coverage Report for Build 3491561420

  • 14 of 14 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 95.411%

Totals Coverage Status
Change from base Build 3488685976: 0.0%
Covered Lines: 17382
Relevant Lines: 18218

πŸ’› - Coveralls

@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code backport maintenance/2.15.x labels Nov 17, 2022
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.15.7 milestone Nov 17, 2022
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.

The refactor is a nice touch πŸ‘

@clavedeluna
Copy link
Contributor Author

Primer failure reminds me of when primer had a legit error but it didn't show up in CI, so I'll run locally when I can and report back.

@github-actions
Copy link
Contributor

πŸ€– According to the primer, this change has no effect on the checked open source code. πŸ€–πŸŽ‰

This comment was generated for commit 64ddfa7

@Pierre-Sassoulas Pierre-Sassoulas merged commit a29a2ab into pylint-dev:main Nov 17, 2022
@Pierre-Sassoulas Pierre-Sassoulas changed the title fix FP For used-before-assignment if terminating func is used Fix false positive for 'used-before-assignment' with terminating func Nov 17, 2022
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 2.15.7, 2.15.6 Nov 17, 2022
@Pierre-Sassoulas Pierre-Sassoulas added the Needs backport Needs to be cherry-picked on the current patch version by a pylint's maintainer label Nov 17, 2022
@jacobtylerwalls jacobtylerwalls removed their request for review November 17, 2022 22:01
@Pierre-Sassoulas Pierre-Sassoulas removed Needs backport Needs to be cherry-picked on the current patch version by a pylint's maintainer backport maintenance/2.15.x labels Nov 17, 2022
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 2.15.6, 2.16.0 Nov 17, 2022
@Pierre-Sassoulas
Copy link
Member

Not back-porting because of a refactor in SINGLETON_VALUES making the cherry-pick too complicated to be worth it.

):
return False

qnames = {"_sitebuiltins.Quitter", "sys.exit", "posix._exit", "nt._exit"}
Copy link
Member

Choose a reason for hiding this comment

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

Small nit: This could be a global, maybe even a frozenset. That would be a small performance improvement.

Copy link
Member

Choose a reason for hiding this comment

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

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False positive used-before-assignment when else of try/else calls sys.exit()
4 participants