mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-19 10:01:15 +00:00
[pylint
] - remove AugAssign errors from self-cls-assignment
(W0642
) (#12957)
This commit is contained in:
parent
81a2220ce1
commit
4881d32c80
3 changed files with 10 additions and 35 deletions
|
@ -3,7 +3,7 @@ class Fruit:
|
||||||
def list_fruits(cls) -> None:
|
def list_fruits(cls) -> None:
|
||||||
cls = "apple" # PLW0642
|
cls = "apple" # PLW0642
|
||||||
cls: Fruit = "apple" # PLW0642
|
cls: Fruit = "apple" # PLW0642
|
||||||
cls += "orange" # PLW0642
|
cls += "orange" # OK, augmented assignments are ignored
|
||||||
*cls = "banana" # PLW0642
|
*cls = "banana" # PLW0642
|
||||||
cls, blah = "apple", "orange" # PLW0642
|
cls, blah = "apple", "orange" # PLW0642
|
||||||
blah, (cls, blah2) = "apple", ("orange", "banana") # PLW0642
|
blah, (cls, blah2) = "apple", ("orange", "banana") # PLW0642
|
||||||
|
@ -16,7 +16,7 @@ class Fruit:
|
||||||
def print_color(self) -> None:
|
def print_color(self) -> None:
|
||||||
self = "red" # PLW0642
|
self = "red" # PLW0642
|
||||||
self: Self = "red" # PLW0642
|
self: Self = "red" # PLW0642
|
||||||
self += "blue" # PLW0642
|
self += "blue" # OK, augmented assignments are ignored
|
||||||
*self = "blue" # PLW0642
|
*self = "blue" # PLW0642
|
||||||
self, blah = "red", "blue" # PLW0642
|
self, blah = "red", "blue" # PLW0642
|
||||||
blah, (self, blah2) = "apple", ("orange", "banana") # PLW0642
|
blah, (self, blah2) = "apple", ("orange", "banana") # PLW0642
|
||||||
|
|
|
@ -1112,9 +1112,6 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Stmt::AugAssign(aug_assign @ ast::StmtAugAssign { target, .. }) => {
|
Stmt::AugAssign(aug_assign @ ast::StmtAugAssign { target, .. }) => {
|
||||||
if checker.enabled(Rule::SelfOrClsAssignment) {
|
|
||||||
pylint::rules::self_or_cls_assignment(checker, target);
|
|
||||||
}
|
|
||||||
if checker.enabled(Rule::GlobalStatement) {
|
if checker.enabled(Rule::GlobalStatement) {
|
||||||
if let Expr::Name(ast::ExprName { id, .. }) = target.as_ref() {
|
if let Expr::Name(ast::ExprName { id, .. }) = target.as_ref() {
|
||||||
pylint::rules::global_statement(checker, id);
|
pylint::rules::global_statement(checker, id);
|
||||||
|
|
|
@ -8,7 +8,7 @@ self_or_cls_assignment.py:4:9: PLW0642 Reassigned `cls` variable in class method
|
||||||
4 | cls = "apple" # PLW0642
|
4 | cls = "apple" # PLW0642
|
||||||
| ^^^ PLW0642
|
| ^^^ PLW0642
|
||||||
5 | cls: Fruit = "apple" # PLW0642
|
5 | cls: Fruit = "apple" # PLW0642
|
||||||
6 | cls += "orange" # PLW0642
|
6 | cls += "orange" # OK, augmented assignments are ignored
|
||||||
|
|
|
|
||||||
= help: Consider using a different variable name
|
= help: Consider using a different variable name
|
||||||
|
|
||||||
|
@ -18,26 +18,15 @@ self_or_cls_assignment.py:5:9: PLW0642 Reassigned `cls` variable in class method
|
||||||
4 | cls = "apple" # PLW0642
|
4 | cls = "apple" # PLW0642
|
||||||
5 | cls: Fruit = "apple" # PLW0642
|
5 | cls: Fruit = "apple" # PLW0642
|
||||||
| ^^^ PLW0642
|
| ^^^ PLW0642
|
||||||
6 | cls += "orange" # PLW0642
|
6 | cls += "orange" # OK, augmented assignments are ignored
|
||||||
7 | *cls = "banana" # PLW0642
|
7 | *cls = "banana" # PLW0642
|
||||||
|
|
|
|
||||||
= help: Consider using a different variable name
|
= help: Consider using a different variable name
|
||||||
|
|
||||||
self_or_cls_assignment.py:6:9: PLW0642 Reassigned `cls` variable in class method
|
|
||||||
|
|
|
||||||
4 | cls = "apple" # PLW0642
|
|
||||||
5 | cls: Fruit = "apple" # PLW0642
|
|
||||||
6 | cls += "orange" # PLW0642
|
|
||||||
| ^^^ PLW0642
|
|
||||||
7 | *cls = "banana" # PLW0642
|
|
||||||
8 | cls, blah = "apple", "orange" # PLW0642
|
|
||||||
|
|
|
||||||
= help: Consider using a different variable name
|
|
||||||
|
|
||||||
self_or_cls_assignment.py:7:10: PLW0642 Reassigned `cls` variable in class method
|
self_or_cls_assignment.py:7:10: PLW0642 Reassigned `cls` variable in class method
|
||||||
|
|
|
|
||||||
5 | cls: Fruit = "apple" # PLW0642
|
5 | cls: Fruit = "apple" # PLW0642
|
||||||
6 | cls += "orange" # PLW0642
|
6 | cls += "orange" # OK, augmented assignments are ignored
|
||||||
7 | *cls = "banana" # PLW0642
|
7 | *cls = "banana" # PLW0642
|
||||||
| ^^^ PLW0642
|
| ^^^ PLW0642
|
||||||
8 | cls, blah = "apple", "orange" # PLW0642
|
8 | cls, blah = "apple", "orange" # PLW0642
|
||||||
|
@ -47,7 +36,7 @@ self_or_cls_assignment.py:7:10: PLW0642 Reassigned `cls` variable in class metho
|
||||||
|
|
||||||
self_or_cls_assignment.py:8:9: PLW0642 Reassigned `cls` variable in class method
|
self_or_cls_assignment.py:8:9: PLW0642 Reassigned `cls` variable in class method
|
||||||
|
|
|
|
||||||
6 | cls += "orange" # PLW0642
|
6 | cls += "orange" # OK, augmented assignments are ignored
|
||||||
7 | *cls = "banana" # PLW0642
|
7 | *cls = "banana" # PLW0642
|
||||||
8 | cls, blah = "apple", "orange" # PLW0642
|
8 | cls, blah = "apple", "orange" # PLW0642
|
||||||
| ^^^ PLW0642
|
| ^^^ PLW0642
|
||||||
|
@ -94,7 +83,7 @@ self_or_cls_assignment.py:17:9: PLW0642 Reassigned `self` variable in instance m
|
||||||
17 | self = "red" # PLW0642
|
17 | self = "red" # PLW0642
|
||||||
| ^^^^ PLW0642
|
| ^^^^ PLW0642
|
||||||
18 | self: Self = "red" # PLW0642
|
18 | self: Self = "red" # PLW0642
|
||||||
19 | self += "blue" # PLW0642
|
19 | self += "blue" # OK, augmented assignments are ignored
|
||||||
|
|
|
|
||||||
= help: Consider using a different variable name
|
= help: Consider using a different variable name
|
||||||
|
|
||||||
|
@ -104,26 +93,15 @@ self_or_cls_assignment.py:18:9: PLW0642 Reassigned `self` variable in instance m
|
||||||
17 | self = "red" # PLW0642
|
17 | self = "red" # PLW0642
|
||||||
18 | self: Self = "red" # PLW0642
|
18 | self: Self = "red" # PLW0642
|
||||||
| ^^^^ PLW0642
|
| ^^^^ PLW0642
|
||||||
19 | self += "blue" # PLW0642
|
19 | self += "blue" # OK, augmented assignments are ignored
|
||||||
20 | *self = "blue" # PLW0642
|
20 | *self = "blue" # PLW0642
|
||||||
|
|
|
|
||||||
= help: Consider using a different variable name
|
= help: Consider using a different variable name
|
||||||
|
|
||||||
self_or_cls_assignment.py:19:9: PLW0642 Reassigned `self` variable in instance method
|
|
||||||
|
|
|
||||||
17 | self = "red" # PLW0642
|
|
||||||
18 | self: Self = "red" # PLW0642
|
|
||||||
19 | self += "blue" # PLW0642
|
|
||||||
| ^^^^ PLW0642
|
|
||||||
20 | *self = "blue" # PLW0642
|
|
||||||
21 | self, blah = "red", "blue" # PLW0642
|
|
||||||
|
|
|
||||||
= help: Consider using a different variable name
|
|
||||||
|
|
||||||
self_or_cls_assignment.py:20:10: PLW0642 Reassigned `self` variable in instance method
|
self_or_cls_assignment.py:20:10: PLW0642 Reassigned `self` variable in instance method
|
||||||
|
|
|
|
||||||
18 | self: Self = "red" # PLW0642
|
18 | self: Self = "red" # PLW0642
|
||||||
19 | self += "blue" # PLW0642
|
19 | self += "blue" # OK, augmented assignments are ignored
|
||||||
20 | *self = "blue" # PLW0642
|
20 | *self = "blue" # PLW0642
|
||||||
| ^^^^ PLW0642
|
| ^^^^ PLW0642
|
||||||
21 | self, blah = "red", "blue" # PLW0642
|
21 | self, blah = "red", "blue" # PLW0642
|
||||||
|
@ -133,7 +111,7 @@ self_or_cls_assignment.py:20:10: PLW0642 Reassigned `self` variable in instance
|
||||||
|
|
||||||
self_or_cls_assignment.py:21:9: PLW0642 Reassigned `self` variable in instance method
|
self_or_cls_assignment.py:21:9: PLW0642 Reassigned `self` variable in instance method
|
||||||
|
|
|
|
||||||
19 | self += "blue" # PLW0642
|
19 | self += "blue" # OK, augmented assignments are ignored
|
||||||
20 | *self = "blue" # PLW0642
|
20 | *self = "blue" # PLW0642
|
||||||
21 | self, blah = "red", "blue" # PLW0642
|
21 | self, blah = "red", "blue" # PLW0642
|
||||||
| ^^^^ PLW0642
|
| ^^^^ PLW0642
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue