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

False negative for consider-using-augmented-assign for nested dicts #8959

Closed
EugeneZelenko opened this issue Aug 15, 2023 · 6 comments · Fixed by #8964 or #9093
Closed

False negative for consider-using-augmented-assign for nested dicts #8959

EugeneZelenko opened this issue Aug 15, 2023 · 6 comments · Fixed by #8964 or #9093
Labels
False Negative 🦋 No message is emitted but something is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@EugeneZelenko
Copy link

Bug description

consider-using-augmented-assign did not catch next situations:

dict_of_dicts = {
    'key1': {
        'key2': 0
    }
}

dict_of_dicts['key1']['key2'] = dict_of_dicts['key1']['key2'] + 1  # [consider-using-augmented-assign]

Configuration

No response

Command used

pylint --load-plugins=pylint.extensions.code_style --enable=all pylint_test.py

Pylint output

************* Module pylint_test
pylint_test.py:1:0: C0114: Missing module docstring (missing-module-docstring)

-------------------------------------------------------------------
Your code has been rated at 6.67/10 (previous run: 10.00/10, -3.33)

Expected behavior

Warning should be shown.

Pylint version

pylint 2.17.4
astroid 2.15.5
Python 3.11.4 (main, Jun 26 2023, 16:57:25) [GCC 7.5.0]

OS / Environment

No response

Additional dependencies

No response

@EugeneZelenko EugeneZelenko added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Aug 15, 2023
@Pierre-Sassoulas Pierre-Sassoulas added False Negative 🦋 No message is emitted but something is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Aug 15, 2023
@Pierre-Sassoulas
Copy link
Member

Thanks for opening the issue, I can reproduce on main.

@crazybolillo
Copy link
Contributor

Interesting, I think I might be able to get in a PR for this in a few days.

@EugeneZelenko
Copy link
Author

Same is true for regular dict:

a_dict = {
    'key': 0
}

a_dict['key'] = a_dict['key'] + 1  # [consider-using-augmented-assign]

crazybolillo added a commit to crazybolillo/pylint that referenced this issue Aug 18, 2023
Assignments on dictionaries which used the same slices were not
generating `consider-using-augmented-assign` messages. This has been
fixed.

Closes pylint-dev#8959.
crazybolillo added a commit to crazybolillo/pylint that referenced this issue Aug 18, 2023
Assignments on dictionaries which used the same subscripts were not
generating `consider-using-augmented-assign` messages. This has been
fixed.

Closes pylint-dev#8959.
@crazybolillo
Copy link
Contributor

It seems like it also applies for lists:

kiwi = [1, 2]
kiwi[0] = kiwi[0] + 1  # [consider-using-augmented-assign]

crazybolillo added a commit to crazybolillo/pylint that referenced this issue Aug 18, 2023
Assignments on dictionaries or lists which used the same subscripts were not
generating `consider-using-augmented-assign` messages. This has been
fixed.

Closes pylint-dev#8959.
crazybolillo added a commit to crazybolillo/pylint that referenced this issue Aug 22, 2023
Assignments on dictionaries or lists which used the same subscripts were not
generating `consider-using-augmented-assign` messages. This has been
fixed.

Closes pylint-dev#8959.
crazybolillo added a commit to crazybolillo/pylint that referenced this issue Aug 22, 2023
Assignments on dictionaries or lists which used the same subscripts were not
generating `consider-using-augmented-assign` messages. This has been
fixed.

Closes pylint-dev#8959.
crazybolillo added a commit to crazybolillo/pylint that referenced this issue Aug 22, 2023
Assignments on dictionaries or lists which used the same subscripts were not
generating `consider-using-augmented-assign` messages. This has been
fixed.

Closes pylint-dev#8959.
crazybolillo added a commit to crazybolillo/pylint that referenced this issue Aug 22, 2023
Assignments on dictionaries or lists which used the same subscripts were not
generating `consider-using-augmented-assign` messages. This has been
fixed.

Closes pylint-dev#8959.
@crazybolillo
Copy link
Contributor

PR is ready, wonder if you guys can take a look? Thanks

@Pierre-Sassoulas Pierre-Sassoulas added this to the 3.0.0a8 milestone Aug 23, 2023
Pierre-Sassoulas pushed a commit that referenced this issue Aug 23, 2023
…ts (#8964)

Assignments on dictionaries or lists which used the same subscripts were not
generating `consider-using-augmented-assign` messages. This has been
fixed.

Closes #8959.
@EugeneZelenko
Copy link
Author

@crazybolillo: Thank you for quick implementation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Negative 🦋 No message is emitted but something is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
3 participants