diff --git a/crates/ruff_linter/resources/test/fixtures/pylint/self_or_cls_assignment.py b/crates/ruff_linter/resources/test/fixtures/pylint/self_or_cls_assignment.py index bc92106a87d9a..fe016694fc19a 100644 --- a/crates/ruff_linter/resources/test/fixtures/pylint/self_or_cls_assignment.py +++ b/crates/ruff_linter/resources/test/fixtures/pylint/self_or_cls_assignment.py @@ -1,9 +1,9 @@ class Fruit: @classmethod def list_fruits(cls) -> None: - cls += "orange" # OK, augmented assignments are ignored cls = "apple" # PLW0642 cls: Fruit = "apple" # PLW0642 + cls += "orange" # OK, augmented assignments are ignored *cls = "banana" # PLW0642 cls, blah = "apple", "orange" # PLW0642 blah, (cls, blah2) = "apple", ("orange", "banana") # PLW0642 @@ -14,9 +14,9 @@ def add_fruits(cls, fruits, /) -> None: cls = fruits # PLW0642 def print_color(self) -> None: - self += "blue" # OK, augmented assignments are ignored self = "red" # PLW0642 self: Self = "red" # PLW0642 + self += "blue" # OK, augmented assignments are ignored *self = "blue" # PLW0642 self, blah = "red", "blue" # PLW0642 blah, (self, blah2) = "apple", ("orange", "banana") # PLW0642 diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0642_self_or_cls_assignment.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0642_self_or_cls_assignment.py.snap index 998dac141b534..315998894e2c3 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0642_self_or_cls_assignment.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0642_self_or_cls_assignment.py.snap @@ -1,32 +1,32 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -self_or_cls_assignment.py:5:9: PLW0642 Reassigned `cls` variable 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: -4 | cls += "orange" # OK, augmented assignments are ignored -5 | cls = "apple" # PLW0642 +4 | cls = "apple" # PLW0642 | ^^^ PLW0642 -6 | cls: Fruit = "apple" # PLW0642 -7 | *cls = "banana" # PLW0642 +5 | cls: Fruit = "apple" # PLW0642 +6 | cls += "orange" # OK, augmented assignments are ignored | = 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:5:9: PLW0642 Reassigned `cls` variable in class method | -4 | cls += "orange" # OK, augmented assignments are ignored -5 | cls = "apple" # PLW0642 -6 | cls: Fruit = "apple" # PLW0642 +3 | def list_fruits(cls) -> None: +4 | cls = "apple" # PLW0642 +5 | cls: Fruit = "apple" # PLW0642 | ^^^ PLW0642 +6 | cls += "orange" # OK, augmented assignments are ignored 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 | -5 | cls = "apple" # PLW0642 -6 | cls: Fruit = "apple" # PLW0642 +5 | cls: Fruit = "apple" # PLW0642 +6 | cls += "orange" # OK, augmented assignments are ignored 7 | *cls = "banana" # PLW0642 | ^^^ PLW0642 8 | cls, blah = "apple", "orange" # PLW0642 @@ -36,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 | - 6 | cls: Fruit = "apple" # PLW0642 + 6 | cls += "orange" # OK, augmented assignments are ignored 7 | *cls = "banana" # PLW0642 8 | cls, blah = "apple", "orange" # PLW0642 | ^^^ PLW0642 @@ -77,32 +77,31 @@ self_or_cls_assignment.py:14:9: PLW0642 Reassigned `cls` variable in class metho | = 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:17:9: PLW0642 Reassigned `self` variable in instance method | 16 | def print_color(self) -> None: -17 | self += "blue" # OK, augmented assignments are ignored -18 | self = "red" # PLW0642 +17 | self = "red" # PLW0642 | ^^^^ PLW0642 -19 | self: Self = "red" # PLW0642 -20 | *self = "blue" # PLW0642 +18 | self: Self = "red" # PLW0642 +19 | self += "blue" # OK, augmented assignments are ignored | = 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:18:9: PLW0642 Reassigned `self` variable in instance method | -17 | self += "blue" # OK, augmented assignments are ignored -18 | self = "red" # PLW0642 -19 | self: Self = "red" # PLW0642 +16 | def print_color(self) -> None: +17 | self = "red" # PLW0642 +18 | self: Self = "red" # PLW0642 | ^^^^ PLW0642 +19 | self += "blue" # OK, augmented assignments are ignored 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 | -18 | self = "red" # PLW0642 -19 | self: Self = "red" # PLW0642 +18 | self: Self = "red" # PLW0642 +19 | self += "blue" # OK, augmented assignments are ignored 20 | *self = "blue" # PLW0642 | ^^^^ PLW0642 21 | self, blah = "red", "blue" # PLW0642 @@ -112,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 | -19 | self: Self = "red" # PLW0642 +19 | self += "blue" # OK, augmented assignments are ignored 20 | *self = "blue" # PLW0642 21 | self, blah = "red", "blue" # PLW0642 | ^^^^ PLW0642