Skip to content

Fix used-before-assignment if conditional imports guarded again when used #7980

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 1 commit into from
Dec 25, 2022

Conversation

jacobtylerwalls
Copy link
Member

Type of Changes

Type
🐛 Bug fix

Description

Closes #7979

See regression test; fixes false positive in music21.

@jacobtylerwalls jacobtylerwalls added False Positive 🦟 A message is emitted but nothing is wrong with the code backport maintenance/2.15.x labels Dec 24, 2022
@jacobtylerwalls jacobtylerwalls added this to the 2.15.10 milestone Dec 24, 2022
@github-actions
Copy link
Contributor

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

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

  1. used-before-assignment:
    Using variable 'Stream' before assignment
    https://github.com./cuthbertLab/music21/blob/cddb10409b934779c8b28999730fce0621fc2f7f/music21/stream/core.py#L552

Effect on pandas:
The following messages are now emitted:

  1. useless-suppression:
    Useless suppression of 'used-before-assignment'
    https://github.com./pandas-dev/pandas/blob/280fbf6dd472b868e3849e81998db6f266b96514/pandas/core/groupby/indexing.py#L116

The following messages are no longer emitted:

  1. suppressed-message:
    Suppressed 'used-before-assignment' (from line 116)
    https://github.com./pandas-dev/pandas/blob/280fbf6dd472b868e3849e81998db6f266b96514/pandas/core/groupby/indexing.py#L116

This comment was generated for commit 386ffe2

@coveralls
Copy link

Pull Request Test Coverage Report for Build 3772618211

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 95.445%

Totals Coverage Status
Change from base Build 3752298849: 0.0%
Covered Lines: 17663
Relevant Lines: 18506

💛 - Coveralls

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.

Elegant !

@Pierre-Sassoulas Pierre-Sassoulas merged commit e6f0bc5 into pylint-dev:main Dec 25, 2022
@github-actions
Copy link
Contributor

The backport to maintenance/2.15.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-maintenance/2.15.x maintenance/2.15.x
# Navigate to the new working tree
cd .worktrees/backport-maintenance/2.15.x
# Create a new branch
git switch --create backport-7980-to-maintenance/2.15.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 e6f0bc5d32965eef37e498e15f05914d4275afb5
# Push it to GitHub
git push --set-upstream origin backport-7980-to-maintenance/2.15.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-maintenance/2.15.x

Then, create a pull request where the base branch is maintenance/2.15.x and the compare/head branch is backport-7980-to-maintenance/2.15.x.

@Pierre-Sassoulas
Copy link
Member

When the primer emits a new useless supression : feelsgood.jpg

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.

used-before-assignment when import guarded by TYPE_CHECKING guarded again when used
3 participants