Skip to content

Fix consider-using-augmented-assign nested attribute access #8088

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
Jan 20, 2023

Conversation

cdce8p
Copy link
Member

@cdce8p cdce8p commented Jan 20, 2023

Description

Closes #8086

@cdce8p cdce8p added the False Positive 🦟 A message is emitted but nothing is wrong with the code label Jan 20, 2023
@cdce8p cdce8p added this to the 2.16.0 milestone Jan 20, 2023
@codecov
Copy link

codecov bot commented Jan 20, 2023

Codecov Report

Merging #8088 (54bd2f1) into main (b87cf16) will increase coverage by 0.03%.
The diff coverage is 100.00%.

❗ Current head 54bd2f1 differs from pull request most recent head 4ea0c3b. Consider uploading reports for the commit 4ea0c3b to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #8088      +/-   ##
==========================================
+ Coverage   95.43%   95.46%   +0.03%     
==========================================
  Files         176      176              
  Lines       18545    18536       -9     
==========================================
- Hits        17698    17695       -3     
+ Misses        847      841       -6     
Impacted Files Coverage Δ
pylint/checkers/utils.py 95.70% <100.00%> (+0.36%) ⬆️
pylint/checkers/method_args.py 100.00% <0.00%> (ø)
pylint/checkers/refactoring/refactoring_checker.py 98.33% <0.00%> (+0.20%) ⬆️

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.

👌

@@ -2091,7 +2075,7 @@ def _is_target_name_in_binop_side(
return target.name == side.name # type: ignore[no-any-return]
return False
if isinstance(side, nodes.Attribute) and isinstance(target, nodes.AssignAttr):
return get_full_name_of_attribute(target) == get_full_name_of_attribute(side)
return target.as_string() == side.as_string() # type: ignore[no-any-return]
Copy link
Member

Choose a reason for hiding this comment

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

Well that's clever ! And probably faster too.

@Pierre-Sassoulas Pierre-Sassoulas added Unreleased Skip news 🔇 This change does not require a changelog entry labels Jan 20, 2023
Comment on lines 1 to 3
Fix ``consider-using-augmented-assign`` checker for nested attribute access.

Closes #8086
Copy link
Member

Choose a reason for hiding this comment

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

Nvm, could you remove this fragment as the checker was not released yet ?

@github-actions

This comment has been minimized.

@Pierre-Sassoulas
Copy link
Member

We messed up when reading the primer in previous merge request 😅

@Pierre-Sassoulas Pierre-Sassoulas enabled auto-merge (squash) January 20, 2023 15:33
@github-actions
Copy link
Contributor

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

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

  1. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/PyCQA/astroid/blob/29834bf2cabd77ea60ac1155188ad486e1222c87/astroid/objects.py#L293

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

  1. consider-using-augmented-assign:
    Use '=' to do an augmented assign directly*
    https://github.com/cuthbertLab/music21/blob/aa7b06836a78096220a977a85c9ecd6e368fcec4/music21/duration.py#L2045
  2. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/cuthbertLab/music21/blob/aa7b06836a78096220a977a85c9ecd6e368fcec4/music21/scale/scala/__init__.py#L336
  3. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/cuthbertLab/music21/blob/aa7b06836a78096220a977a85c9ecd6e368fcec4/music21/stream/makeNotation.py#L1233
  4. consider-using-augmented-assign:
    Use '-=' to do an augmented assign directly
    https://github.com/cuthbertLab/music21/blob/aa7b06836a78096220a977a85c9ecd6e368fcec4/music21/stream/base.py#L4622
  5. consider-using-augmented-assign:
    Use '=' to do an augmented assign directly*
    https://github.com/cuthbertLab/music21/blob/aa7b06836a78096220a977a85c9ecd6e368fcec4/music21/stream/tests.py#L611
  6. consider-using-augmented-assign:
    Use '=' to do an augmented assign directly*
    https://github.com/cuthbertLab/music21/blob/aa7b06836a78096220a977a85c9ecd6e368fcec4/music21/stream/tests.py#L613
  7. consider-using-augmented-assign:
    Use '=' to do an augmented assign directly*
    https://github.com/cuthbertLab/music21/blob/aa7b06836a78096220a977a85c9ecd6e368fcec4/music21/stream/tests.py#L615
  8. consider-using-augmented-assign:
    Use '-=' to do an augmented assign directly
    https://github.com/cuthbertLab/music21/blob/aa7b06836a78096220a977a85c9ecd6e368fcec4/music21/romanText/translate.py#L701
  9. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/cuthbertLab/music21/blob/aa7b06836a78096220a977a85c9ecd6e368fcec4/music21/abcFormat/__init__.py#L2735
  10. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/cuthbertLab/music21/blob/aa7b06836a78096220a977a85c9ecd6e368fcec4/music21/abcFormat/__init__.py#L3266
  11. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/cuthbertLab/music21/blob/aa7b06836a78096220a977a85c9ecd6e368fcec4/music21/abcFormat/translate.py#L579

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

  1. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/a93dbc0ef01a12452c8fbdb3dcaf2682ead700a3/src/sentry/pipeline/base.py#L205

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

  1. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/nedbat/coveragepy/blob/82c263814e57e1d790cbe1c00bd1c724b9ca8e3c/coverage/results.py#L283
  2. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/nedbat/coveragepy/blob/82c263814e57e1d790cbe1c00bd1c724b9ca8e3c/coverage/results.py#L284
  3. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/nedbat/coveragepy/blob/82c263814e57e1d790cbe1c00bd1c724b9ca8e3c/coverage/results.py#L285
  4. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/nedbat/coveragepy/blob/82c263814e57e1d790cbe1c00bd1c724b9ca8e3c/coverage/results.py#L286
  5. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/nedbat/coveragepy/blob/82c263814e57e1d790cbe1c00bd1c724b9ca8e3c/coverage/results.py#L287
  6. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/nedbat/coveragepy/blob/82c263814e57e1d790cbe1c00bd1c724b9ca8e3c/coverage/results.py#L288
  7. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/nedbat/coveragepy/blob/82c263814e57e1d790cbe1c00bd1c724b9ca8e3c/coverage/results.py#L291

This comment was generated for commit 4ea0c3b

@cdce8p cdce8p disabled auto-merge January 20, 2023 16:09
@cdce8p cdce8p merged commit 01cd57b into pylint-dev:main Jan 20, 2023
@cdce8p cdce8p deleted the fix-augmented-assign branch January 20, 2023 16:11
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 Skip news 🔇 This change does not require a changelog entry Unreleased
Projects
None yet
Development

Successfully merging this pull request may close these issues.

consider-augmented-assign false positive
2 participants