---
source: crates/ruff_linter/src/rules/pylint/mod.rs
---
PLR6104 [*] Use `+=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:16:1
   |
14 | mat1, mat2 = None, None
15 |
16 | some_string = some_string + "a very long end of string"
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17 | index = index - 1
18 | a_list = a_list + ["to concat"]
   |
help: Replace with augmented assignment
   |
15 |
   - some_string = some_string + "a very long end of string"
16 + some_string += "a very long end of string"
17 | index = index - 1
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `-=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:17:1
   |
16 | some_string = some_string + "a very long end of string"
17 | index = index - 1
   | ^^^^^^^^^^^^^^^^^
18 | a_list = a_list + ["to concat"]
19 | some_set = some_set | {"to concat"}
   |
help: Replace with augmented assignment
   |
16 | some_string = some_string + "a very long end of string"
   - index = index - 1
17 + index -= 1
18 | a_list = a_list + ["to concat"]
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `+=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:18:1
   |
16 | some_string = some_string + "a very long end of string"
17 | index = index - 1
18 | a_list = a_list + ["to concat"]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19 | some_set = some_set | {"to concat"}
20 | to_multiply = to_multiply * 5
   |
help: Replace with augmented assignment
   |
17 | index = index - 1
   - a_list = a_list + ["to concat"]
18 + a_list += ["to concat"]
19 | some_set = some_set | {"to concat"}
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `|=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:19:1
   |
17 | index = index - 1
18 | a_list = a_list + ["to concat"]
19 | some_set = some_set | {"to concat"}
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20 | to_multiply = to_multiply * 5
21 | to_multiply = 5 * to_multiply
   |
help: Replace with augmented assignment
   |
18 | a_list = a_list + ["to concat"]
   - some_set = some_set | {"to concat"}
19 + some_set |= {"to concat"}
20 | to_multiply = to_multiply * 5
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `*=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:20:1
   |
18 | a_list = a_list + ["to concat"]
19 | some_set = some_set | {"to concat"}
20 | to_multiply = to_multiply * 5
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21 | to_multiply = 5 * to_multiply
22 | to_multiply = to_multiply * to_multiply
   |
help: Replace with augmented assignment
   |
19 | some_set = some_set | {"to concat"}
   - to_multiply = to_multiply * 5
20 + to_multiply *= 5
21 | to_multiply = 5 * to_multiply
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `*=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:21:1
   |
19 | some_set = some_set | {"to concat"}
20 | to_multiply = to_multiply * 5
21 | to_multiply = 5 * to_multiply
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22 | to_multiply = to_multiply * to_multiply
23 | to_divide = to_divide / 5
   |
help: Replace with augmented assignment
   |
20 | to_multiply = to_multiply * 5
   - to_multiply = 5 * to_multiply
21 + to_multiply *= 5
22 | to_multiply = to_multiply * to_multiply
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `*=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:22:1
   |
20 | to_multiply = to_multiply * 5
21 | to_multiply = 5 * to_multiply
22 | to_multiply = to_multiply * to_multiply
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
23 | to_divide = to_divide / 5
24 | to_divide = to_divide // 5
   |
help: Replace with augmented assignment
   |
21 | to_multiply = 5 * to_multiply
   - to_multiply = to_multiply * to_multiply
22 + to_multiply *= to_multiply
23 | to_divide = to_divide / 5
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `/=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:23:1
   |
21 | to_multiply = 5 * to_multiply
22 | to_multiply = to_multiply * to_multiply
23 | to_divide = to_divide / 5
   | ^^^^^^^^^^^^^^^^^^^^^^^^^
24 | to_divide = to_divide // 5
25 | to_cube = to_cube**3
   |
help: Replace with augmented assignment
   |
22 | to_multiply = to_multiply * to_multiply
   - to_divide = to_divide / 5
23 + to_divide /= 5
24 | to_divide = to_divide // 5
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `//=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:24:1
   |
22 | to_multiply = to_multiply * to_multiply
23 | to_divide = to_divide / 5
24 | to_divide = to_divide // 5
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^
25 | to_cube = to_cube**3
26 | to_cube = 3**to_cube
   |
help: Replace with augmented assignment
   |
23 | to_divide = to_divide / 5
   - to_divide = to_divide // 5
24 + to_divide //= 5
25 | to_cube = to_cube**3
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `**=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:25:1
   |
23 | to_divide = to_divide / 5
24 | to_divide = to_divide // 5
25 | to_cube = to_cube**3
   | ^^^^^^^^^^^^^^^^^^^^
26 | to_cube = 3**to_cube
27 | to_cube = to_cube**to_cube
   |
help: Replace with augmented assignment
   |
24 | to_divide = to_divide // 5
   - to_cube = to_cube**3
25 + to_cube **= 3
26 | to_cube = 3**to_cube
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `**=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:27:1
   |
25 | to_cube = to_cube**3
26 | to_cube = 3**to_cube
27 | to_cube = to_cube**to_cube
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^
28 | timeDiffSeconds = timeDiffSeconds % 60
29 | flags = flags & 0x1
   |
help: Replace with augmented assignment
   |
26 | to_cube = 3**to_cube
   - to_cube = to_cube**to_cube
27 + to_cube **= to_cube
28 | timeDiffSeconds = timeDiffSeconds % 60
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `%=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:28:1
   |
26 | to_cube = 3**to_cube
27 | to_cube = to_cube**to_cube
28 | timeDiffSeconds = timeDiffSeconds % 60
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29 | flags = flags & 0x1
30 | flags = flags | 0x1
   |
help: Replace with augmented assignment
   |
27 | to_cube = to_cube**to_cube
   - timeDiffSeconds = timeDiffSeconds % 60
28 + timeDiffSeconds %= 60
29 | flags = flags & 0x1
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `&=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:29:1
   |
27 | to_cube = to_cube**to_cube
28 | timeDiffSeconds = timeDiffSeconds % 60
29 | flags = flags & 0x1
   | ^^^^^^^^^^^^^^^^^^^
30 | flags = flags | 0x1
31 | flags = flags ^ 0x1
   |
help: Replace with augmented assignment
   |
28 | timeDiffSeconds = timeDiffSeconds % 60
   - flags = flags & 0x1
29 + flags &= 0x1
30 | flags = flags | 0x1
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `|=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:30:1
   |
28 | timeDiffSeconds = timeDiffSeconds % 60
29 | flags = flags & 0x1
30 | flags = flags | 0x1
   | ^^^^^^^^^^^^^^^^^^^
31 | flags = flags ^ 0x1
32 | flags = flags << 1
   |
help: Replace with augmented assignment
   |
29 | flags = flags & 0x1
   - flags = flags | 0x1
30 + flags |= 0x1
31 | flags = flags ^ 0x1
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `^=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:31:1
   |
29 | flags = flags & 0x1
30 | flags = flags | 0x1
31 | flags = flags ^ 0x1
   | ^^^^^^^^^^^^^^^^^^^
32 | flags = flags << 1
33 | flags = flags >> 1
   |
help: Replace with augmented assignment
   |
30 | flags = flags | 0x1
   - flags = flags ^ 0x1
31 + flags ^= 0x1
32 | flags = flags << 1
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `<<=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:32:1
   |
30 | flags = flags | 0x1
31 | flags = flags ^ 0x1
32 | flags = flags << 1
   | ^^^^^^^^^^^^^^^^^^
33 | flags = flags >> 1
34 | mat1 = mat1 @ mat2
   |
help: Replace with augmented assignment
   |
31 | flags = flags ^ 0x1
   - flags = flags << 1
32 + flags <<= 1
33 | flags = flags >> 1
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `>>=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:33:1
   |
31 | flags = flags ^ 0x1
32 | flags = flags << 1
33 | flags = flags >> 1
   | ^^^^^^^^^^^^^^^^^^
34 | mat1 = mat1 @ mat2
35 | a_list[1] = a_list[1] + 1
   |
help: Replace with augmented assignment
   |
32 | flags = flags << 1
   - flags = flags >> 1
33 + flags >>= 1
34 | mat1 = mat1 @ mat2
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `@=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:34:1
   |
32 | flags = flags << 1
33 | flags = flags >> 1
34 | mat1 = mat1 @ mat2
   | ^^^^^^^^^^^^^^^^^^
35 | a_list[1] = a_list[1] + 1
   |
help: Replace with augmented assignment
   |
33 | flags = flags >> 1
   - mat1 = mat1 @ mat2
34 + mat1 @= mat2
35 | a_list[1] = a_list[1] + 1
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `+=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:35:1
   |
33 | flags = flags >> 1
34 | mat1 = mat1 @ mat2
35 | a_list[1] = a_list[1] + 1
   | ^^^^^^^^^^^^^^^^^^^^^^^^^
36 |
37 | a_list[0:2] = a_list[0:2] * 3
   |
help: Replace with augmented assignment
   |
34 | mat1 = mat1 @ mat2
   - a_list[1] = a_list[1] + 1
35 + a_list[1] += 1
36 |
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `*=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:37:1
   |
35 | a_list[1] = a_list[1] + 1
36 |
37 | a_list[0:2] = a_list[0:2] * 3
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38 | a_list[:2] = a_list[:2] * 3
39 | a_list[1:] = a_list[1:] * 3
   |
help: Replace with augmented assignment
   |
36 |
   - a_list[0:2] = a_list[0:2] * 3
37 + a_list[0:2] *= 3
38 | a_list[:2] = a_list[:2] * 3
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `*=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:38:1
   |
37 | a_list[0:2] = a_list[0:2] * 3
38 | a_list[:2] = a_list[:2] * 3
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
39 | a_list[1:] = a_list[1:] * 3
40 | a_list[:] = a_list[:] * 3
   |
help: Replace with augmented assignment
   |
37 | a_list[0:2] = a_list[0:2] * 3
   - a_list[:2] = a_list[:2] * 3
38 + a_list[:2] *= 3
39 | a_list[1:] = a_list[1:] * 3
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `*=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:39:1
   |
37 | a_list[0:2] = a_list[0:2] * 3
38 | a_list[:2] = a_list[:2] * 3
39 | a_list[1:] = a_list[1:] * 3
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
40 | a_list[:] = a_list[:] * 3
   |
help: Replace with augmented assignment
   |
38 | a_list[:2] = a_list[:2] * 3
   - a_list[1:] = a_list[1:] * 3
39 + a_list[1:] *= 3
40 | a_list[:] = a_list[:] * 3
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `*=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:40:1
   |
38 | a_list[:2] = a_list[:2] * 3
39 | a_list[1:] = a_list[1:] * 3
40 | a_list[:] = a_list[:] * 3
   | ^^^^^^^^^^^^^^^^^^^^^^^^^
41 |
42 | index = index * (index + 10)
   |
help: Replace with augmented assignment
   |
39 | a_list[1:] = a_list[1:] * 3
   - a_list[:] = a_list[:] * 3
40 + a_list[:] *= 3
41 |
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `*=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:42:1
   |
40 | a_list[:] = a_list[:] * 3
41 |
42 | index = index * (index + 10)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: Replace with augmented assignment
   |
41 |
   - index = index * (index + 10)
42 + index *= (index + 10)
43 |
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `+=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:47:9
   |
45 | class T:
46 |     def t(self):
47 |         self.a = self.a + 1
   |         ^^^^^^^^^^^^^^^^^^^
   |
help: Replace with augmented assignment
   |
46 |     def t(self):
   -         self.a = self.a + 1
47 +         self.a += 1
48 |
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `+=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:51:1
   |
50 | obj = T()
51 | obj.a = obj.a + 1
   | ^^^^^^^^^^^^^^^^^
   |
help: Replace with augmented assignment
   |
50 | obj = T()
   - obj.a = obj.a + 1
51 + obj.a += 1
52 |
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `+=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:54:1
   |
54 | a = a+-1
   | ^^^^^^^^
55 |
56 | # Regression tests for https://github.com/astral-sh/ruff/issues/11672
   |
help: Replace with augmented assignment
   |
53 |
   - a = a+-1
54 + a += -1
55 |
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `+=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:58:1
   |
56 | # Regression tests for https://github.com/astral-sh/ruff/issues/11672
57 | test = 0x5
58 | test = test + 0xBA
   | ^^^^^^^^^^^^^^^^^^
59 |
60 | test2 = b""
   |
help: Replace with augmented assignment
   |
57 | test = 0x5
   - test = test + 0xBA
58 + test += 0xBA
59 |
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `+=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:61:1
   |
60 | test2 = b""
61 | test2 = test2 + b"\000"
   | ^^^^^^^^^^^^^^^^^^^^^^^
62 |
63 | test3 = ""
   |
help: Replace with augmented assignment
   |
60 | test2 = b""
   - test2 = test2 + b"\000"
61 + test2 += b"\000"
62 |
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `+=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:64:1
   |
63 |   test3 = ""
64 | / test3 = test3 + (   a := R""
65 | |                          f"oo"   )
   | |__________________________________^
66 |
67 |   test4 = []
   |
help: Replace with augmented assignment
   |
63 | test3 = ""
   - test3 = test3 + (   a := R""
64 + test3 += (   a := R""
65 |                          f"oo"   )
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `+=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:68:1
   |
67 |   test4 = []
68 | / test4 = test4 + ( e
69 | |                   for e in
70 | |                   range(10)
71 | |                   )
   | |___________________^
72 |
73 |   test5 = test5 + (
   |
help: Replace with augmented assignment
   |
67 | test4 = []
   - test4 = test4 + ( e
68 + test4 += ( e
69 |                   for e in
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `+=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:73:1
   |
71 |                     )
72 |
73 | / test5 = test5 + (
74 | |     4
75 | |     *
76 | |     10
77 | | )
   | |_^
78 |
79 |   test6 = test6 + \
   |
help: Replace with augmented assignment
   |
72 |
   - test5 = test5 + (
73 + test5 += (
74 |     4
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `+=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:79:1
   |
77 |   )
78 |
79 | / test6 = test6 + \
80 | |         (
81 | |             4
82 | |             *
83 | |             10
84 | |         )
   | |_________^
85 |
86 |   test7 = \
   |
help: Replace with augmented assignment
   |
78 |
   - test6 = test6 + \
   -         (
79 + test6 += (
80 |             4
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `+=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:86:1
   |
84 |           )
85 |
86 | / test7 = \
87 | |         100 \
88 | |     + test7
   | |___________^
89 |
90 |   test8 = \
   |
help: Replace with augmented assignment
   |
85 |
   - test7 = \
   -         100 \
   -     + test7
86 + test7 += 100
87 |
   |
note: This is an unsafe fix and may change runtime behavior

PLR6104 [*] Use `+=` to perform an augmented assignment directly
  --> non_augmented_assignment.py:90:1
   |
88 |       + test7
89 |
90 | / test8 = \
91 | |     886 \
92 | |     + \
93 | |  \
94 | |     test8
   | |_________^
   |
help: Replace with augmented assignment
   |
89 |
   - test8 = \
   -     886 \
   -     + \
   -  \
   -     test8
90 + test8 += 886
91 |
   |
note: This is an unsafe fix and may change runtime behavior
