Skip to content

consider-augmented-assign false positive #8086

Closed
@SimonSchick

Description

@SimonSchick

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions