Skip to content

Commit

Permalink
Improve the error message for PLW0642 (#12866)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood authored and MichaReiser committed Aug 14, 2024
1 parent 6ef9566 commit f0f04f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl Violation for SelfOrClsAssignment {
let SelfOrClsAssignment { method_type } = self;

format!(
"Confusing assignment to `{}` argument in {method_type} method",
"Reassigned `{}` variable in {method_type} method",
method_type.arg_name(),
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/ruff_linter/src/rules/pylint/mod.rs
---
self_or_cls_assignment.py:4:9: PLW0642 Confusing assignment to `cls` argument in class method
self_or_cls_assignment.py:4:9: PLW0642 Reassigned `cls` variable in class method
|
2 | @classmethod
3 | def list_fruits(cls) -> None:
Expand All @@ -12,7 +12,7 @@ self_or_cls_assignment.py:4:9: PLW0642 Confusing assignment to `cls` argument in
|
= help: Consider using a different variable name

self_or_cls_assignment.py:5:9: PLW0642 Confusing assignment to `cls` argument in class method
self_or_cls_assignment.py:5:9: PLW0642 Reassigned `cls` variable in class method
|
3 | def list_fruits(cls) -> None:
4 | cls = "apple" # PLW0642
Expand All @@ -23,7 +23,7 @@ self_or_cls_assignment.py:5:9: PLW0642 Confusing assignment to `cls` argument in
|
= help: Consider using a different variable name

self_or_cls_assignment.py:6:9: PLW0642 Confusing assignment to `cls` argument in class method
self_or_cls_assignment.py:6:9: PLW0642 Reassigned `cls` variable in class method
|
4 | cls = "apple" # PLW0642
5 | cls: Fruit = "apple" # PLW0642
Expand All @@ -34,7 +34,7 @@ self_or_cls_assignment.py:6:9: PLW0642 Confusing assignment to `cls` argument in
|
= help: Consider using a different variable name

self_or_cls_assignment.py:7:10: PLW0642 Confusing assignment to `cls` argument in class method
self_or_cls_assignment.py:7:10: PLW0642 Reassigned `cls` variable in class method
|
5 | cls: Fruit = "apple" # PLW0642
6 | cls += "orange" # PLW0642
Expand All @@ -45,7 +45,7 @@ self_or_cls_assignment.py:7:10: PLW0642 Confusing assignment to `cls` argument i
|
= help: Consider using a different variable name

self_or_cls_assignment.py:8:9: PLW0642 Confusing assignment to `cls` argument in class method
self_or_cls_assignment.py:8:9: PLW0642 Reassigned `cls` variable in class method
|
6 | cls += "orange" # PLW0642
7 | *cls = "banana" # PLW0642
Expand All @@ -56,7 +56,7 @@ self_or_cls_assignment.py:8:9: PLW0642 Confusing assignment to `cls` argument in
|
= help: Consider using a different variable name

self_or_cls_assignment.py:9:16: PLW0642 Confusing assignment to `cls` argument in class method
self_or_cls_assignment.py:9:16: PLW0642 Reassigned `cls` variable in class method
|
7 | *cls = "banana" # PLW0642
8 | cls, blah = "apple", "orange" # PLW0642
Expand All @@ -66,7 +66,7 @@ self_or_cls_assignment.py:9:16: PLW0642 Confusing assignment to `cls` argument i
|
= help: Consider using a different variable name

self_or_cls_assignment.py:10:16: PLW0642 Confusing assignment to `cls` argument in class method
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
Expand All @@ -77,7 +77,7 @@ self_or_cls_assignment.py:10:16: PLW0642 Confusing assignment to `cls` argument
|
= help: Consider using a different variable name

self_or_cls_assignment.py:14:9: PLW0642 Confusing assignment to `cls` argument in class method
self_or_cls_assignment.py:14:9: PLW0642 Reassigned `cls` variable in class method
|
12 | @classmethod
13 | def add_fruits(cls, fruits, /) -> None:
Expand All @@ -88,7 +88,7 @@ self_or_cls_assignment.py:14:9: PLW0642 Confusing assignment to `cls` argument i
|
= help: Consider using a different variable name

self_or_cls_assignment.py:17:9: PLW0642 Confusing assignment to `self` argument in instance method
self_or_cls_assignment.py:17:9: PLW0642 Reassigned `self` variable in instance method
|
16 | def print_color(self) -> None:
17 | self = "red" # PLW0642
Expand All @@ -98,7 +98,7 @@ self_or_cls_assignment.py:17:9: PLW0642 Confusing assignment to `self` argument
|
= help: Consider using a different variable name

self_or_cls_assignment.py:18:9: PLW0642 Confusing assignment to `self` argument in instance method
self_or_cls_assignment.py:18:9: PLW0642 Reassigned `self` variable in instance method
|
16 | def print_color(self) -> None:
17 | self = "red" # PLW0642
Expand All @@ -109,7 +109,7 @@ self_or_cls_assignment.py:18:9: PLW0642 Confusing assignment to `self` argument
|
= help: Consider using a different variable name

self_or_cls_assignment.py:19:9: PLW0642 Confusing assignment to `self` argument in instance method
self_or_cls_assignment.py:19:9: PLW0642 Reassigned `self` variable in instance method
|
17 | self = "red" # PLW0642
18 | self: Self = "red" # PLW0642
Expand All @@ -120,7 +120,7 @@ self_or_cls_assignment.py:19:9: PLW0642 Confusing assignment to `self` argument
|
= help: Consider using a different variable name

self_or_cls_assignment.py:20:10: PLW0642 Confusing assignment to `self` argument in instance method
self_or_cls_assignment.py:20:10: PLW0642 Reassigned `self` variable in instance method
|
18 | self: Self = "red" # PLW0642
19 | self += "blue" # PLW0642
Expand All @@ -131,7 +131,7 @@ self_or_cls_assignment.py:20:10: PLW0642 Confusing assignment to `self` argument
|
= help: Consider using a different variable name

self_or_cls_assignment.py:21:9: PLW0642 Confusing assignment to `self` argument in instance method
self_or_cls_assignment.py:21:9: PLW0642 Reassigned `self` variable in instance method
|
19 | self += "blue" # PLW0642
20 | *self = "blue" # PLW0642
Expand All @@ -142,7 +142,7 @@ self_or_cls_assignment.py:21:9: PLW0642 Confusing assignment to `self` argument
|
= help: Consider using a different variable name

self_or_cls_assignment.py:22:16: PLW0642 Confusing assignment to `self` argument in instance method
self_or_cls_assignment.py:22:16: PLW0642 Reassigned `self` variable in instance method
|
20 | *self = "blue" # PLW0642
21 | self, blah = "red", "blue" # PLW0642
Expand All @@ -152,7 +152,7 @@ self_or_cls_assignment.py:22:16: PLW0642 Confusing assignment to `self` argument
|
= help: Consider using a different variable name

self_or_cls_assignment.py:23:16: PLW0642 Confusing assignment to `self` argument in instance method
self_or_cls_assignment.py:23:16: PLW0642 Reassigned `self` variable in instance method
|
21 | self, blah = "red", "blue" # PLW0642
22 | blah, (self, blah2) = "apple", ("orange", "banana") # PLW0642
Expand All @@ -163,7 +163,7 @@ self_or_cls_assignment.py:23:16: PLW0642 Confusing assignment to `self` argument
|
= help: Consider using a different variable name

self_or_cls_assignment.py:26:9: PLW0642 Confusing assignment to `self` argument in instance method
self_or_cls_assignment.py:26:9: PLW0642 Reassigned `self` variable in instance method
|
25 | def print_color(self, color, /) -> None:
26 | self = color
Expand Down

0 comments on commit f0f04f4

Please sign in to comment.