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 used-before-assignment false positive for walrus operator in dictionary #8176

Merged
merged 2 commits into from
Feb 10, 2023
Merged

Fix used-before-assignment false positive for walrus operator in dictionary #8176

merged 2 commits into from
Feb 10, 2023

Conversation

zenlyj
Copy link
Contributor

@zenlyj zenlyj commented Feb 3, 2023

Type of Changes

Type
🐛 Bug fix
✨ New feature
🔨 Refactoring
📜 Docs

Description

Fix false positive when the walrus operator is used with the ternary operator in dictionary key/value initialization.

Closes #8125

@Pierre-Sassoulas Pierre-Sassoulas added the False Positive 🦟 A message is emitted but nothing is wrong with the code label Feb 3, 2023
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.16.2 milestone Feb 3, 2023
@github-actions

This comment has been minimized.

@codecov
Copy link

codecov bot commented Feb 4, 2023

Codecov Report

Merging #8176 (ed66132) into main (ffbd2e0) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #8176   +/-   ##
=======================================
  Coverage   95.53%   95.53%           
=======================================
  Files         177      177           
  Lines       18622    18624    +2     
=======================================
+ Hits        17791    17793    +2     
  Misses        831      831           
Impacted Files Coverage Δ
pylint/checkers/variables.py 97.38% <100.00%> (+<0.01%) ⬆️

@zenlyj zenlyj changed the title Fix used-before-assignment false positive Fix used-before-assignment false positive for walrus operator in dictionary Feb 4, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2023

🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉

This comment was generated for commit ed66132

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.

LGTM, but the expert about this is Jacob, we can wait a little to merge.

Copy link
Member

@jacobtylerwalls jacobtylerwalls left a comment

Choose a reason for hiding this comment

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

Looks good, thank you! This is so good, it alerted me to another false positive.

The check for BaseContainer should also check all elements. I can handle that in another PR.

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 with := in dict node
3 participants