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

Add consider-using-augmented-assign checker #7514

Merged
merged 11 commits into from
Sep 22, 2022

Conversation

DanielNoord
Copy link
Collaborator

  • Write a good description on what the PR does.
  • Create a news fragment with towncrier create <IssueNumber>.<type> which will be
    included in the changelog. <type> can be one of: new_check, removed_check, extension,
    false_positive, false_negative, bugfix, other, internal. If necessary you can write
    details or offer examples on how the new change is supposed to work.
  • If you used multiple emails or multiple names when contributing, add your mails
    and preferred name in script/.contributors_aliases.json

Type of Changes

Type
✨ New feature

Description

Closes #3391

Based around the work by @clavedeluna in #7509. But to make this checker work I had to add some additional checking.

Let's see what the primer thinks of this! 😰

@DanielNoord
Copy link
Collaborator Author

Something is up with the caches of the primer. Seems to have to do with a bump in the Python versions used by the runner that is happening in between the creation of the cache and the calling to the cache.

Let's see if all things return back to normal after the run on main has completed and we can start a new primer run on this branch.

@coveralls
Copy link

coveralls commented Sep 22, 2022

Pull Request Test Coverage Report for Build 3107823195

  • 38 of 42 (90.48%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.01%) to 95.315%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pylint/checkers/utils.py 32 36 88.89%
Totals Coverage Status
Change from base Build 3105240153: -0.01%
Covered Lines: 17109
Relevant Lines: 17950

💛 - Coveralls

@github-actions

This comment has been minimized.

@jacobtylerwalls
Copy link
Member

Noticed the first Django result is a false positive (string formatting, not modulo):
https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/templatetags/i18n.py#L190

clavedeluna
clavedeluna previously approved these changes Sep 22, 2022
Copy link
Contributor

@clavedeluna clavedeluna left a comment

Choose a reason for hiding this comment

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

Nice! And quite a bit more robust than the initial implementation 🚀

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.

Requesting a test showing that %= does not raise a false positive.

@DanielNoord
Copy link
Collaborator Author

Noticed the first Django result is a false positive (string formatting, not modulo):
https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/templatetags/i18n.py#L190

Thanks for checking! PRs like these are where the primer shines 😄

@DanielNoord
Copy link
Collaborator Author

Noticed the first Django result is a false positive (string formatting, not modulo):
https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/templatetags/i18n.py#L190

Can't just simplify that as well though?

python
Python 3.10.0 (default, Oct 27 2021, 16:20:25) [Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x = "%s"
>>> x % "my_string"
'my_string'
>>> x %= "my_string"
>>> x
'my_string'

@jacobtylerwalls
Copy link
Member

Ah, that might not be a false positive then. Still I'm worried there could be something lurking with incomplete string formatting (e.g. TypeError: not all arguments converted...). A couple tests would be nice just to show this isn't a worry.

@DanielNoord
Copy link
Collaborator Author

Ah, that might not be a false positive then. Still I'm worried there could be something lurking with incomplete string formatting (e.g. TypeError: not all arguments converted...). A couple tests would be nice just to show this isn't a worry.

I think those would be an issue without the augmented assign as well, but you're right: better safe than sorry!

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@DanielNoord
Copy link
Collaborator Author

I don't understand astroid 1, but that seems to be caused by incorrect inference of filled_args.
I checked all other primer messages and they all seem to make sense to me.

I think this is ready for review!

clavedeluna
clavedeluna previously approved these changes Sep 22, 2022
pylint/checkers/utils.py Outdated Show resolved Hide resolved
pylint/checkers/utils.py Outdated Show resolved Hide resolved
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.

There's a badly formatted message for black; Use '=' to do an augmented assign directly* (https://github.com/psf/black/blob/6ae8457a8628345c59fed22c58728ffa258a3e76/src/blib2to3/pgen2/literals.py#L51). It also happen for pandas here : https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/io/formats/test_format.py#L1535, so probably for all *.

I added a suggestion for some functional test with operators I could think of.

pylint/checkers/utils.py Outdated Show resolved Hide resolved
pylint/checkers/utils.py Show resolved Hide resolved
Co-authored-by: Mark Byrne <31762852+mbyrnepr2@users.noreply.github.com>
@DanielNoord
Copy link
Collaborator Author

There's a badly formatted message for black; Use '=' to do an augmented assign directly* (https://github.com/psf/black/blob/6ae8457a8628345c59fed22c58728ffa258a3e76/src/blib2to3/pgen2/literals.py#L51). It also happen for pandas here : https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/io/formats/test_format.py#L1535, so probably for all *.

This is incorrect formatting from GitHub. See test output for correct examples with *=.

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.

Great idea for a checker, and nice execution 👌

@github-actions
Copy link
Contributor

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

Effect on astroid:
The following messages are now emitted:

  1. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/PyCQA/astroid/blob/b867508d903719378e439ec48686565a497ec312/astroid/objects.py#L293
  2. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/PyCQA/astroid/blob/b867508d903719378e439ec48686565a497ec312/astroid/manager.py#L258
  3. consider-using-augmented-assign:
    Use '-=' to do an augmented assign directly
    https://github.com/PyCQA/astroid/blob/b867508d903719378e439ec48686565a497ec312/astroid/nodes/scoped_nodes/scoped_nodes.py#L558
  4. consider-using-augmented-assign:
    Use '-=' to do an augmented assign directly
    https://github.com/PyCQA/astroid/blob/b867508d903719378e439ec48686565a497ec312/astroid/nodes/scoped_nodes/scoped_nodes.py#L567

Effect on black:
The following messages are now emitted:

  1. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/psf/black/blob/6ae8457a8628345c59fed22c58728ffa258a3e76/src/black/__init__.py#L1018
  2. consider-using-augmented-assign:
    Use '=' to do an augmented assign directly*
    https://github.com/psf/black/blob/6ae8457a8628345c59fed22c58728ffa258a3e76/src/blib2to3/pgen2/literals.py#L51
  3. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/psf/black/blob/6ae8457a8628345c59fed22c58728ffa258a3e76/src/blib2to3/pgen2/tokenize.py#L481
  4. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/psf/black/blob/6ae8457a8628345c59fed22c58728ffa258a3e76/src/blib2to3/pgen2/tokenize.py#L482
  5. consider-using-augmented-assign:
    Use '%=' to do an augmented assign directly
    https://github.com/psf/black/blob/6ae8457a8628345c59fed22c58728ffa258a3e76/src/blib2to3/pgen2/pgen.py#L372

Effect on django:
The following messages are now emitted:

  1. consider-using-augmented-assign:
    Use '%=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/templatetags/i18n.py#L190
  2. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/contrib/admin/options.py#L1843
  3. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/contrib/admin/helpers.py#L98
  4. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/contrib/admin/helpers.py#L459
  5. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/test/utils.py#L596
  6. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/middleware/security.py#L41
  7. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/middleware/security.py#L43
  8. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/core/management/commands/compilemessages.py#L78
  9. consider-using-augmented-assign:
    Use '%=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/db/models/options.py#L248
  10. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/db/models/query.py#L1575
  11. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/db/models/query.py#L2039
  12. consider-using-augmented-assign:
    Use '%=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/db/models/fields/related.py#L358
  13. consider-using-augmented-assign:
    Use '%=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/db/models/fields/json.py#L458
  14. consider-using-augmented-assign:
    Use '%=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/db/models/fields/json.py#L460
  15. consider-using-augmented-assign:
    Use '^=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/db/models/sql/query.py#L1535
  16. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/db/models/sql/query.py#L2053
  17. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/db/models/sql/compiler.py#L2027
  18. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/db/backends/base/schema.py#L1000
  19. consider-using-augmented-assign:
    Use '%=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/db/backends/oracle/introspection.py#L169
  20. consider-using-augmented-assign:
    Use '%=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/db/backends/oracle/base.py#L531
  21. consider-using-augmented-assign:
    Use '%=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/forms/models.py#L319
  22. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/forms/widgets.py#L210
  23. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/forms/widgets.py#L948
  24. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/forms/forms.py#L495
  25. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/urls/base.py#L73
  26. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/utils/datetime_safe.py#L98
  27. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/utils/datetime_safe.py#L101
  28. consider-using-augmented-assign:
    Use '%=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/utils/duration.py#L10
  29. consider-using-augmented-assign:
    Use '%=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/utils/duration.py#L13
  30. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/utils/timezone.py#L337
  31. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/utils/numberformat.py#L84
  32. consider-using-augmented-assign:
    Use '%=' to do an augmented assign directly
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/utils/translation/__init__.py#L152

Effect on pandas:
The following messages are now emitted:

  1. consider-using-augmented-assign:
    Use '/=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/arithmetic/test_timedelta64.py#L1606
  2. consider-using-augmented-assign:
    Use '/=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/arithmetic/test_timedelta64.py#L1646
  3. consider-using-augmented-assign:
    Use '/=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/arithmetic/test_timedelta64.py#L1674
  4. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/indexing/multiindex/test_setitem.py#L225
  5. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/extension/test_external_block.py#L31
  6. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/series/test_arithmetic.py#L780
  7. consider-using-augmented-assign:
    Use '-=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/series/indexing/test_setitem.py#L918
  8. consider-using-augmented-assign:
    Use '=' to do an augmented assign directly*
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/io/formats/test_format.py#L1535
  9. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/window/test_expanding.py#L272
  10. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/window/test_rolling.py#L1473
  11. consider-using-augmented-assign:
    Use '=' to do an augmented assign directly*
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/groupby/transform/test_transform.py#L932
  12. consider-using-augmented-assign:
    Use '=' to do an augmented assign directly*
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/groupby/transform/test_transform.py#L933
  13. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/groupby/aggregate/test_other.py#L523
  14. consider-using-augmented-assign:
    Use '=' to do an augmented assign directly*
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/indexes/ranges/test_range.py#L148
  15. consider-using-augmented-assign:
    Use '=' to do an augmented assign directly*
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/indexes/ranges/test_range.py#L150
  16. consider-using-augmented-assign:
    Use '-=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/frame/test_constructors.py#L3148
  17. consider-using-augmented-assign:
    Use '-=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/frame/methods/test_reindex.py#L1187
  18. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/tseries/offsets/test_month.py#L616
  19. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/tseries/offsets/test_fiscal.py#L179
  20. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/tseries/offsets/test_fiscal.py#L337
  21. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/tseries/offsets/test_fiscal.py#L423
  22. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/tseries/offsets/test_fiscal.py#L428
  23. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/tseries/offsets/test_fiscal.py#L629
  24. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/tests/tseries/offsets/test_offsets.py#L1053
  25. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/core/frame.py#L10623
  26. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/core/frame.py#L10624
  27. consider-using-augmented-assign:
    Use '/=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/core/sample.py#L147
  28. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/core/resample.py#L503
  29. consider-using-augmented-assign:
    Use '|=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/core/arrays/boolean.py#L218
  30. consider-using-augmented-assign:
    Use '|=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/core/arrays/boolean.py#L225
  31. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/core/arrays/string_arrow.py#L393
  32. consider-using-augmented-assign:
    Use '=' to do an augmented assign directly*
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/core/arrays/period.py#L1103
  33. consider-using-augmented-assign:
    Use '|=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/core/arrays/masked.py#L597
  34. consider-using-augmented-assign:
    Use '^=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/core/arrays/masked.py#L823
  35. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/core/reshape/merge.py#L1740
  36. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/core/reshape/merge.py#L1741
  37. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/core/reshape/merge.py#L1742
  38. consider-using-augmented-assign:
    Use '-=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/core/tools/datetimes.py#L606
  39. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/core/tools/datetimes.py#L651
  40. consider-using-augmented-assign:
    Use '/=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/core/window/numba_.py#L158
  41. consider-using-augmented-assign:
    Use '&=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/core/groupby/groupby.py#L3135
  42. consider-using-augmented-assign:
    Use '&=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/core/groupby/groupby.py#L4124
  43. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/core/groupby/groupby.py#L4185
  44. consider-using-augmented-assign:
    Use '=' to do an augmented assign directly*
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/_testing/__init__.py#L378
  45. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/io/pytables.py#L2656
  46. consider-using-augmented-assign:
    Use '-=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/io/pytables.py#L4167
  47. consider-using-augmented-assign:
    Use '&=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/io/pytables.py#L4395
  48. consider-using-augmented-assign:
    Use '=' to do an augmented assign directly*
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/io/formats/format.py#L1722
  49. consider-using-augmented-assign:
    Use '|=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/io/parsers/readers.py#L1920
  50. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/util/_exceptions.py#L24
  51. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pandas-dev/pandas/blob/71fc89cd515c3c19230fbab64e979118858b808a/pandas/plotting/_matplotlib/core.py#L1689

Effect on pygame:
The following messages are now emitted:

  1. consider-using-augmented-assign:
    Use '<<=' to do an augmented assign directly
    https://github.com/pygame/pygame/blob/7e6f48306f624debac9cb2731bb9adc5a762a5c6/src_py/cursors.py#L754
  2. consider-using-augmented-assign:
    Use '<<=' to do an augmented assign directly
    https://github.com/pygame/pygame/blob/7e6f48306f624debac9cb2731bb9adc5a762a5c6/src_py/cursors.py#L755
  3. consider-using-augmented-assign:
    Use '-=' to do an augmented assign directly
    https://github.com/pygame/pygame/blob/7e6f48306f624debac9cb2731bb9adc5a762a5c6/src_py/cursors.py#L756
  4. consider-using-augmented-assign:
    Use '|=' to do an augmented assign directly
    https://github.com/pygame/pygame/blob/7e6f48306f624debac9cb2731bb9adc5a762a5c6/src_py/cursors.py#L758
  5. consider-using-augmented-assign:
    Use '|=' to do an augmented assign directly
    https://github.com/pygame/pygame/blob/7e6f48306f624debac9cb2731bb9adc5a762a5c6/src_py/cursors.py#L759
  6. consider-using-augmented-assign:
    Use '|=' to do an augmented assign directly
    https://github.com/pygame/pygame/blob/7e6f48306f624debac9cb2731bb9adc5a762a5c6/src_py/cursors.py#L761
  7. consider-using-augmented-assign:
    Use '|=' to do an augmented assign directly
    https://github.com/pygame/pygame/blob/7e6f48306f624debac9cb2731bb9adc5a762a5c6/src_py/cursors.py#L763
  8. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/pygame/pygame/blob/7e6f48306f624debac9cb2731bb9adc5a762a5c6/src_py/midi.py#L605
  9. consider-using-augmented-assign:
    Use '/=' to do an augmented assign directly
    https://github.com/pygame/pygame/blob/7e6f48306f624debac9cb2731bb9adc5a762a5c6/src_py/draw_py.py#L231

Effect on pytest:
The following messages are now emitted:

  1. consider-using-augmented-assign:
    Use '-=' to do an augmented assign directly
    https://github.com/pytest-dev/pytest/blob/59b8ec3ce11f8e94d924dc97bc1e14f380824b54/src/_pytest/assertion/util.py#L364

Effect on sentry:
The following messages are now emitted:

  1. consider-using-augmented-assign:
    Use '/=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/templatetags/sentry_helpers.py#L213
  2. consider-using-augmented-assign:
    Use '%=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/templatetags/sentry_helpers.py#L217
  3. consider-using-augmented-assign:
    Use '%=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/templatetags/sentry_helpers.py#L220
  4. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/runner/commands/devserver.py#L211
  5. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/runner/commands/devservices.py#L106
  6. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/models/debugfile.py#L592
  7. consider-using-augmented-assign:
    Use '-=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/deletions/base.py#L209
  8. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/filestore/gcs.py#L90
  9. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/release_health/metrics.py#L909
  10. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/release_health/metrics.py#L982
  11. consider-using-augmented-assign:
    Use '-=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/processing/realtime_metrics/redis.py#L171
  12. consider-using-augmented-assign:
    Use '-=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/processing/realtime_metrics/redis.py#L205
  13. consider-using-augmented-assign:
    Use '|=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/auth/helper.py#L230
  14. consider-using-augmented-assign:
    Use '=' to do an augmented assign directly*
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/utils/numbers.py#L42
  15. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/utils/snuba.py#L428
  16. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/snuba/query_subscription_consumer.py#L178
  17. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/snuba/discover.py#L118
  18. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/api/paginator.py#L403
  19. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/api/event_search.py#L203
  20. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/api/event_search.py#L229
  21. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/api/base.py#L136
  22. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/api/bases/organization_events.py#L208
  23. consider-using-augmented-assign:
    Use '+=' to do an augmented assign directly
    https://github.com/getsentry/sentry/blob/f9bf16e7d663c780c1e0c0378ae92f2a93aa326b/src/sentry/api/endpoints/organization_events_facets_performance.py#L319

This comment was generated for commit f5861b1

@DanielNoord DanielNoord enabled auto-merge (squash) September 22, 2022 19:07
@DanielNoord DanielNoord merged commit 705ac4c into pylint-dev:main Sep 22, 2022
@DanielNoord DanielNoord deleted the aug-assign branch September 22, 2022 21:32
@cdce8p
Copy link
Member

cdce8p commented Oct 11, 2022

I haven't followed the discussion around this check so it might have come up already.

Why was this not implemented as an optional extension?

From what I can tell there is no obvious benefit to using the augmented assignment over the regular one. IMO it just creates a lot of unnecessary noise. Similar checks like the one for assignment expressions are also optional.

@Pierre-Sassoulas
Copy link
Member

I think @cdce8p has a point here.

@jacobtylerwalls
Copy link
Member

Agreed.

@DanielNoord
Copy link
Collaborator Author

Agreed. I'll create a PR when I get the time.

@DanielNoord
Copy link
Collaborator Author

See opened issue for follow up question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simplifying assignment operators operation with same variable in left and right hand side of assignment
7 participants