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

[used-before-assignment] Extend "same test" exception to named expressions #10062

Merged
merged 2 commits into from
Nov 3, 2024

Conversation

jacobtylerwalls
Copy link
Member

Type of Changes

Type
βœ“ πŸ› Bug fix

Closes #10061

@jacobtylerwalls jacobtylerwalls added False Positive 🦟 A message is emitted but nothing is wrong with the code C: used-before-assignment Issues related to 'used-before-assignment' check backport maintenance/3.3.x labels Nov 3, 2024
@jacobtylerwalls jacobtylerwalls added this to the 3.3.2 milestone Nov 3, 2024
Copy link

codecov bot commented Nov 3, 2024

Codecov Report

All modified and coverable lines are covered by tests βœ…

Please upload report for BASE (main@15a5ac0). Learn more about missing BASE report.
Report is 65 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #10062   +/-   ##
=======================================
  Coverage        ?   95.79%           
=======================================
  Files           ?      174           
  Lines           ?    18940           
  Branches        ?        0           
=======================================
  Hits            ?    18144           
  Misses          ?      796           
  Partials        ?        0           
Files with missing lines Coverage Ξ”
pylint/checkers/variables.py 97.21% <100.00%> (ΓΈ)

Copy link
Contributor

github-actions bot commented Nov 3, 2024

πŸ€– Effect of this PR on checked open source code: πŸ€–

Effect on home-assistant:
The following messages are now emitted:

  1. useless-suppression:
    Useless suppression of 'possibly-used-before-assignment'
    https://github.com/home-assistant/core/blob/b09e54c961db279785b75b5c3d192624b3d65664/homeassistant/helpers/update_coordinator.py#L465

The following messages are no longer emitted:

  1. possibly-used-before-assignment:
    Possibly using variable 'start' before assignment
    https://github.com/home-assistant/core/blob/b09e54c961db279785b75b5c3d192624b3d65664/homeassistant/loader.py#L1004
  2. possibly-used-before-assignment:
    Possibly using variable 'start' before assignment
    https://github.com/home-assistant/core/blob/b09e54c961db279785b75b5c3d192624b3d65664/homeassistant/loader.py#L1194
  3. possibly-used-before-assignment:
    Possibly using variable 'year' before assignment
    https://github.com/home-assistant/core/blob/b09e54c961db279785b75b5c3d192624b3d65664/homeassistant/components/homeassistant/triggers/time.py#L160
  4. possibly-used-before-assignment:
    Possibly using variable 'month' before assignment
    https://github.com/home-assistant/core/blob/b09e54c961db279785b75b5c3d192624b3d65664/homeassistant/components/homeassistant/triggers/time.py#L161
  5. possibly-used-before-assignment:
    Possibly using variable 'day' before assignment
    https://github.com/home-assistant/core/blob/b09e54c961db279785b75b5c3d192624b3d65664/homeassistant/components/homeassistant/triggers/time.py#L162
  6. suppressed-message:
    Suppressed 'possibly-used-before-assignment' (from line 465)
    https://github.com/home-assistant/core/blob/b09e54c961db279785b75b5c3d192624b3d65664/homeassistant/helpers/update_coordinator.py#L465

This comment was generated for commit 1c538af

@jacobtylerwalls jacobtylerwalls removed the request for review from mbyrnepr2 November 3, 2024 17:39
@jacobtylerwalls jacobtylerwalls merged commit ac2ae53 into main Nov 3, 2024
44 checks passed
@jacobtylerwalls jacobtylerwalls deleted the jtw/fix-same-test-named-expr branch November 3, 2024 17:40
Copy link
Contributor

github-actions bot commented Nov 3, 2024

The backport to maintenance/3.3.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/3.3.x maintenance/3.3.x
# Navigate to the new working tree
cd .worktrees/backport-maintenance/3.3.x
# Create a new branch
git switch --create backport-10062-to-maintenance/3.3.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 ac2ae537468466f390432676e0dcea519ffa5277
# Push it to GitHub
git push --set-upstream origin backport-10062-to-maintenance/3.3.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-maintenance/3.3.x

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

@jacobtylerwalls
Copy link
Member Author

Forget the backport, the manual backport showed that we'd be cherry-picking down some changes with new false negative fixes along with this.

@jacobtylerwalls jacobtylerwalls removed this from the 3.3.2 milestone Nov 4, 2024
@jacobtylerwalls jacobtylerwalls added this to the 4.0.0 milestone Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: used-before-assignment Issues related to 'used-before-assignment' check 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] False positive for "same test" exception when test is a walrus operator
2 participants