-
Notifications
You must be signed in to change notification settings - Fork 103
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
Solve ruff issue non-augmented assignment #8296
base: main
Are you sure you want to change the base?
Conversation
non-augmented-assignment (PLR6104)Derived from the Pylint linter. Fix is always available. This rule is in preview and is not stable. The What it doesChecks for assignments that can be replaced with augmented assignment Why is this bad?If an assignment statement consists of a binary operation in which one When performing such an operation, augmented assignments are more concise Known problemsIn some cases, this rule will not detect assignments in which the target For example, If the type of the left-hand side cannot be inferred trivially, the rule Examplex = x + 1 Use instead: x += 1 Fix safetyThis rule's fix is marked as unsafe, as augmented assignments have For example, consider the following: foo = [1]
bar = foo
foo = foo + [2]
assert (foo, bar) == ([1, 2], [1]) If the assignment is replaced with an augmented assignment, the update foo = [1]
bar = foo
foo += [2]
assert (foo, bar) == ([1, 2], [1, 2]) |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8296 +/- ##
==========================================
+ Coverage 86.92% 86.94% +0.01%
==========================================
Files 375 375
Lines 23523 23523
Branches 624 636 +12
==========================================
+ Hits 20448 20452 +4
+ Misses 2999 2998 -1
+ Partials 76 73 -3 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice changes.
The comment listing pitfalls was excellent :)
Issue
Resolves ruff issue on non-augmented assignment
Approach
ruff check --unsafe-fixes --fix .
, 👀When applicable