---
source: crates/ruff_linter/src/rules/pylint/mod.rs
---
PLW0642 Reassigned `cls` variable in class method
 --> self_or_cls_assignment.py:4:9
  |
2 |     @classmethod
3 |     def list_fruits(cls) -> None:
4 |         cls = "apple"  # PLW0642
  |         ^^^
5 |         cls: Fruit = "apple"  # PLW0642
6 |         cls += "orange"  # OK, augmented assignments are ignored
  |
help: Consider using a different variable name

PLW0642 Reassigned `cls` variable in class method
 --> self_or_cls_assignment.py:5:9
  |
3 |     def list_fruits(cls) -> None:
4 |         cls = "apple"  # PLW0642
5 |         cls: Fruit = "apple"  # PLW0642
  |         ^^^
6 |         cls += "orange"  # OK, augmented assignments are ignored
7 |         *cls = "banana"  # PLW0642
  |
help: Consider using a different variable name

PLW0642 Reassigned `cls` variable in class method
 --> self_or_cls_assignment.py:7:10
  |
5 |         cls: Fruit = "apple"  # PLW0642
6 |         cls += "orange"  # OK, augmented assignments are ignored
7 |         *cls = "banana"  # PLW0642
  |          ^^^
8 |         cls, blah = "apple", "orange"  # PLW0642
9 |         blah, (cls, blah2) = "apple", ("orange", "banana")  # PLW0642
  |
help: Consider using a different variable name

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

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

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

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

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

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

PLW0642 Reassigned `self` variable in instance method
  --> self_or_cls_assignment.py:20:10
   |
18 |         self: Self = "red"  # PLW0642
19 |         self += "blue"  # OK, augmented assignments are ignored
20 |         *self = "blue"  # PLW0642
   |          ^^^^
21 |         self, blah = "red", "blue"  # PLW0642
22 |         blah, (self, blah2) = "apple", ("orange", "banana")  # PLW0642
   |
help: Consider using a different variable name

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

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

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

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

PLW0642 Reassigned `cls` variable in `__new__` method
  --> self_or_cls_assignment.py:50:9
   |
48 | class Foo:
49 |     def __new__(cls):
50 |         cls = "apple" # PLW0642
   |         ^^^
   |
help: Consider using a different variable name
