Skip to content

Commit d8ebb03

Browse files
AlexWaygoodMichaReiser
authored andcommitted
Improve the error message for PLW0642 (#12866)
1 parent 2e211c5 commit d8ebb03

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

crates/ruff_linter/src/rules/pylint/rules/self_or_cls_assignment.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl Violation for SelfOrClsAssignment {
5353
let SelfOrClsAssignment { method_type } = self;
5454

5555
format!(
56-
"Confusing assignment to `{}` argument in {method_type} method",
56+
"Reassigned `{}` variable in {method_type} method",
5757
method_type.arg_name(),
5858
)
5959
}

crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0642_self_or_cls_assignment.py.snap

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
source: crates/ruff_linter/src/rules/pylint/mod.rs
33
---
4-
self_or_cls_assignment.py:4:9: PLW0642 Confusing assignment to `cls` argument in class method
4+
self_or_cls_assignment.py:4:9: PLW0642 Reassigned `cls` variable in class method
55
|
66
2 | @classmethod
77
3 | def list_fruits(cls) -> None:
@@ -12,7 +12,7 @@ self_or_cls_assignment.py:4:9: PLW0642 Confusing assignment to `cls` argument in
1212
|
1313
= help: Consider using a different variable name
1414

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

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

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

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

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

69-
self_or_cls_assignment.py:10:16: PLW0642 Confusing assignment to `cls` argument in class method
69+
self_or_cls_assignment.py:10:16: PLW0642 Reassigned `cls` variable in class method
7070
|
7171
8 | cls, blah = "apple", "orange" # PLW0642
7272
9 | blah, (cls, blah2) = "apple", ("orange", "banana") # PLW0642
@@ -77,7 +77,7 @@ self_or_cls_assignment.py:10:16: PLW0642 Confusing assignment to `cls` argument
7777
|
7878
= help: Consider using a different variable name
7979

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

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)