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

consider-augmented-assign false positive #8086

Closed
SimonSchick opened this issue Jan 20, 2023 · 5 comments · Fixed by #8088
Closed

consider-augmented-assign false positive #8086

SimonSchick opened this issue Jan 20, 2023 · 5 comments · Fixed by #8088
Labels
Blocker 🙅 Blocks the next release False Positive 🦟 A message is emitted but nothing is wrong with the code Unreleased
Milestone

Comments

@SimonSchick
Copy link

SimonSchick commented Jan 20, 2023

Bug description

Currently this checker doesn't appear to pay attention to the context of a field lookup and assumes that as long as the field name matches it can proceed, example:

class A:
    def __init__(self) -> None:
        self.a = 1
        self.b = A()

    def test(self) -> None:
        self.a = self.a + 1 # should flag
        self.b.a = self.a + 1 # should NOT flag, the error is here

Configuration

Appears to be not relevant as long as the offending rule is enabled

Command used

Please don't scream, we need to move things around (suggestions welcome either way).

`find . -type f -name "*.py" -not -path "./.env/*" -not -path "*/src/common/*" | xargs pylint --jobs 4 --init-hook "import sys; sys.path.append(\"$PWD\")"`

Pylint output

`Use '+=' to do an augmented assign directlypylint(consider-using-augmented-assign)`

Expected behavior

The false positive should not be reported

Pylint version

pylint 2.16.0b0
astroid 2.13.2
Python 3.10.8 (main, Oct 13 2022, 09:48:40) [Clang 14.0.0 (clang-1400.0.29.102)]

OS / Environment

MacOS

Additional dependencies

No response

@SimonSchick SimonSchick added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jan 20, 2023
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.16.0 milestone Jan 20, 2023
@Pierre-Sassoulas Pierre-Sassoulas added Blocker 🙅 Blocks the next release Unreleased False Positive 🦟 A message is emitted but nothing is wrong with the code and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Jan 20, 2023
@cdce8p cdce8p removed the Unreleased label Jan 20, 2023
@cdce8p
Copy link
Member

cdce8p commented Jan 20, 2023

This is probably an issue for 2.15.x as well. Removed the Unreleased label. Opened #8088 with a fix.

@Pierre-Sassoulas
Copy link
Member

Are you sure we introduced this check in #7605 ?

@Pierre-Sassoulas
Copy link
Member

Well it was modified a lot : #7628 based on #7514. I also consider making a special case for anti-commutative operator, I might as well :D

@cdce8p
Copy link
Member

cdce8p commented Jan 20, 2023

Are you sure we introduced this check in #7605 ?

I only checked git blame and saw that it was added last November, so I though it must have been released yet. Seems I was wrong 😄

@Pierre-Sassoulas
Copy link
Member

Ho, because we release a lot of patch version it does not seem like it, but time fly and 2.15.0 was released in late AUGUST (!!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocker 🙅 Blocks the next release False Positive 🦟 A message is emitted but nothing is wrong with the code Unreleased
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants