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

[pylint] - remove AugAssign errors from self-cls-assignment (W0642) #12957

Merged
merged 3 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ class Fruit:
def list_fruits(cls) -> None:
cls = "apple" # PLW0642
cls: Fruit = "apple" # PLW0642
cls += "orange" # PLW0642
AlexWaygood marked this conversation as resolved.
Show resolved Hide resolved
*cls = "banana" # PLW0642
cls, blah = "apple", "orange" # PLW0642
blah, (cls, blah2) = "apple", ("orange", "banana") # PLW0642
Expand All @@ -16,7 +15,6 @@ def add_fruits(cls, fruits, /) -> None:
def print_color(self) -> None:
self = "red" # PLW0642
self: Self = "red" # PLW0642
self += "blue" # PLW0642
*self = "blue" # PLW0642
self, blah = "red", "blue" # PLW0642
blah, (self, blah2) = "apple", ("orange", "banana") # PLW0642
Expand Down
3 changes: 0 additions & 3 deletions crates/ruff_linter/src/checkers/ast/analyze/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1112,9 +1112,6 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
}
}
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 let Expr::Name(ast::ExprName { id, .. }) = target.as_ref() {
pylint::rules::global_statement(checker, id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ self_or_cls_assignment.py:4:9: PLW0642 Reassigned `cls` variable in class method
4 | cls = "apple" # PLW0642
| ^^^ PLW0642
5 | cls: Fruit = "apple" # PLW0642
6 | cls += "orange" # PLW0642
6 | *cls = "banana" # PLW0642
|
= help: Consider using a different variable name

Expand All @@ -18,157 +18,135 @@ self_or_cls_assignment.py:5:9: PLW0642 Reassigned `cls` variable in class method
4 | cls = "apple" # PLW0642
5 | cls: Fruit = "apple" # PLW0642
| ^^^ PLW0642
6 | cls += "orange" # PLW0642
7 | *cls = "banana" # PLW0642
6 | *cls = "banana" # PLW0642
7 | cls, blah = "apple", "orange" # PLW0642
|
= help: Consider using a different variable name

self_or_cls_assignment.py:6:9: PLW0642 Reassigned `cls` variable in class method
self_or_cls_assignment.py:6:10: 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
6 | *cls = "banana" # PLW0642
| ^^^ PLW0642
7 | cls, blah = "apple", "orange" # PLW0642
8 | blah, (cls, blah2) = "apple", ("orange", "banana") # 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:9: PLW0642 Reassigned `cls` variable in class method
|
5 | cls: Fruit = "apple" # PLW0642
6 | cls += "orange" # PLW0642
7 | *cls = "banana" # PLW0642
| ^^^ PLW0642
8 | cls, blah = "apple", "orange" # PLW0642
9 | blah, (cls, blah2) = "apple", ("orange", "banana") # PLW0642
6 | *cls = "banana" # PLW0642
7 | cls, blah = "apple", "orange" # PLW0642
| ^^^ PLW0642
8 | blah, (cls, blah2) = "apple", ("orange", "banana") # PLW0642
9 | blah, [cls, blah2] = "apple", ("orange", "banana") # PLW0642
|
= help: Consider using a different variable name

self_or_cls_assignment.py:8:9: PLW0642 Reassigned `cls` variable in class method
|
6 | cls += "orange" # PLW0642
7 | *cls = "banana" # PLW0642
8 | cls, blah = "apple", "orange" # PLW0642
| ^^^ PLW0642
9 | blah, (cls, blah2) = "apple", ("orange", "banana") # PLW0642
10 | blah, [cls, blah2] = "apple", ("orange", "banana") # PLW0642
|
= help: Consider using a different variable name
self_or_cls_assignment.py:8:16: PLW0642 Reassigned `cls` variable in class method
|
6 | *cls = "banana" # PLW0642
7 | cls, blah = "apple", "orange" # PLW0642
8 | blah, (cls, blah2) = "apple", ("orange", "banana") # PLW0642
| ^^^ PLW0642
9 | blah, [cls, blah2] = "apple", ("orange", "banana") # PLW0642
|
= help: Consider using a different variable name

self_or_cls_assignment.py:9:16: PLW0642 Reassigned `cls` variable in class method
|
7 | *cls = "banana" # PLW0642
8 | cls, blah = "apple", "orange" # PLW0642
9 | blah, (cls, blah2) = "apple", ("orange", "banana") # PLW0642
7 | cls, blah = "apple", "orange" # PLW0642
8 | blah, (cls, blah2) = "apple", ("orange", "banana") # PLW0642
9 | blah, [cls, blah2] = "apple", ("orange", "banana") # PLW0642
| ^^^ PLW0642
10 | blah, [cls, blah2] = "apple", ("orange", "banana") # PLW0642
10 |
11 | @classmethod
|
= help: Consider using a different variable name

self_or_cls_assignment.py:10:16: PLW0642 Reassigned `cls` variable in class method
|
8 | cls, blah = "apple", "orange" # PLW0642
9 | blah, (cls, blah2) = "apple", ("orange", "banana") # PLW0642
10 | blah, [cls, blah2] = "apple", ("orange", "banana") # PLW0642
| ^^^ PLW0642
11 |
12 | @classmethod
self_or_cls_assignment.py:13:9: PLW0642 Reassigned `cls` variable in class method
|
= help: Consider using a different variable name

self_or_cls_assignment.py:14:9: PLW0642 Reassigned `cls` variable in class method
|
12 | @classmethod
13 | def add_fruits(cls, fruits, /) -> None:
14 | cls = fruits # PLW0642
11 | @classmethod
12 | def add_fruits(cls, fruits, /) -> None:
13 | cls = fruits # PLW0642
| ^^^ PLW0642
15 |
16 | def print_color(self) -> None:
|
= help: Consider using a different variable name

self_or_cls_assignment.py:17:9: PLW0642 Reassigned `self` variable in instance method
|
16 | def print_color(self) -> None:
17 | self = "red" # PLW0642
| ^^^^ PLW0642
18 | self: Self = "red" # PLW0642
19 | self += "blue" # PLW0642
14 |
15 | def print_color(self) -> None:
|
= help: Consider using a different variable name

self_or_cls_assignment.py:18:9: PLW0642 Reassigned `self` variable in instance method
self_or_cls_assignment.py:16:9: PLW0642 Reassigned `self` variable in instance method
|
16 | def print_color(self) -> None:
17 | self = "red" # PLW0642
18 | self: Self = "red" # PLW0642
15 | def print_color(self) -> None:
16 | self = "red" # PLW0642
| ^^^^ PLW0642
19 | self += "blue" # PLW0642
20 | *self = "blue" # PLW0642
17 | self: Self = "red" # PLW0642
18 | *self = "blue" # PLW0642
|
= help: Consider using a different variable name

self_or_cls_assignment.py:19:9: PLW0642 Reassigned `self` variable in instance method
self_or_cls_assignment.py:17:9: PLW0642 Reassigned `self` variable in instance method
|
17 | self = "red" # PLW0642
18 | self: Self = "red" # PLW0642
19 | self += "blue" # PLW0642
15 | def print_color(self) -> None:
16 | self = "red" # PLW0642
17 | self: Self = "red" # PLW0642
| ^^^^ PLW0642
20 | *self = "blue" # PLW0642
21 | self, blah = "red", "blue" # PLW0642
18 | *self = "blue" # PLW0642
19 | 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:18:10: PLW0642 Reassigned `self` variable in instance method
|
18 | self: Self = "red" # PLW0642
19 | self += "blue" # PLW0642
20 | *self = "blue" # PLW0642
16 | self = "red" # PLW0642
17 | self: Self = "red" # PLW0642
18 | *self = "blue" # PLW0642
| ^^^^ PLW0642
21 | self, blah = "red", "blue" # PLW0642
22 | blah, (self, blah2) = "apple", ("orange", "banana") # PLW0642
19 | self, blah = "red", "blue" # PLW0642
20 | blah, (self, blah2) = "apple", ("orange", "banana") # PLW0642
|
= help: Consider using a different variable name

self_or_cls_assignment.py:21:9: PLW0642 Reassigned `self` variable in instance method
self_or_cls_assignment.py:19:9: PLW0642 Reassigned `self` variable in instance method
|
19 | self += "blue" # PLW0642
20 | *self = "blue" # PLW0642
21 | self, blah = "red", "blue" # PLW0642
17 | self: Self = "red" # PLW0642
18 | *self = "blue" # PLW0642
19 | self, blah = "red", "blue" # PLW0642
| ^^^^ PLW0642
22 | blah, (self, blah2) = "apple", ("orange", "banana") # PLW0642
23 | blah, [self, blah2] = "apple", ("orange", "banana") # PLW0642
20 | blah, (self, blah2) = "apple", ("orange", "banana") # PLW0642
21 | blah, [self, blah2] = "apple", ("orange", "banana") # PLW0642
|
= help: Consider using a different variable name

self_or_cls_assignment.py:22:16: PLW0642 Reassigned `self` variable in instance method
self_or_cls_assignment.py:20:16: PLW0642 Reassigned `self` variable in instance method
|
20 | *self = "blue" # PLW0642
21 | self, blah = "red", "blue" # PLW0642
22 | blah, (self, blah2) = "apple", ("orange", "banana") # PLW0642
18 | *self = "blue" # PLW0642
19 | self, blah = "red", "blue" # PLW0642
20 | blah, (self, blah2) = "apple", ("orange", "banana") # PLW0642
| ^^^^ PLW0642
23 | blah, [self, blah2] = "apple", ("orange", "banana") # PLW0642
21 | blah, [self, blah2] = "apple", ("orange", "banana") # PLW0642
|
= help: Consider using a different variable name

self_or_cls_assignment.py:23:16: PLW0642 Reassigned `self` variable in instance method
self_or_cls_assignment.py:21:16: PLW0642 Reassigned `self` variable in instance method
|
21 | self, blah = "red", "blue" # PLW0642
22 | blah, (self, blah2) = "apple", ("orange", "banana") # PLW0642
23 | blah, [self, blah2] = "apple", ("orange", "banana") # PLW0642
19 | self, blah = "red", "blue" # PLW0642
20 | blah, (self, blah2) = "apple", ("orange", "banana") # PLW0642
21 | blah, [self, blah2] = "apple", ("orange", "banana") # PLW0642
| ^^^^ PLW0642
24 |
25 | def print_color(self, color, /) -> None:
22 |
23 | def print_color(self, color, /) -> None:
|
= help: Consider using a different variable name

self_or_cls_assignment.py:26:9: PLW0642 Reassigned `self` variable in instance method
self_or_cls_assignment.py:24:9: PLW0642 Reassigned `self` variable in instance method
|
25 | def print_color(self, color, /) -> None:
26 | self = color
23 | def print_color(self, color, /) -> None:
24 | self = color
| ^^^^ PLW0642
27 |
28 | def ok(self) -> None:
25 |
26 | def ok(self) -> None:
|
= help: Consider using a different variable name
Loading