---
source: crates/ruff_linter/src/rules/ruff/mod.rs
---
RUF005 Consider `[*foo]` instead of concatenation
 --> RUF005.py:4:1
  |
2 |   # Non-fixable Errors.
3 |   ###
4 | / foo + [  # This will be preserved.
5 | | ]
  | |_^
6 |   [*foo] + [  # This will be preserved.
7 |   ]
  |
help: Replace with `[*foo]`

RUF005 Consider `[*foo]` instead of concatenation
 --> RUF005.py:6:1
  |
4 |   foo + [  # This will be preserved.
5 |   ]
6 | / [*foo] + [  # This will be preserved.
7 | | ]
  | |_^
8 |   first = [
9 |       # The order
  |
help: Replace with `[*foo]`

RUF005 Consider `[*first, 4, 5, 6]` instead of concatenation
  --> RUF005.py:16:10
   |
14 |       # to preserve
15 |   ]
16 |   second = first + [
   |  __________^
17 | |     # please
18 | |     4,
19 | |     # don't
20 | |     5,
21 | |     # touch
22 | |     6,
23 | | ]
   | |_^
   |
help: Replace with `[*first, 4, 5, 6]`

RUF005 [*] Consider `[1, 2, 3, *foo]` instead of concatenation
  --> RUF005.py:39:7
   |
38 | foo = [4, 5, 6]
39 | bar = [1, 2, 3] + foo
   |       ^^^^^^^^^^^^^^^
40 | zoob = tuple(bar)
41 | quux = (7, 8, 9) + zoob
   |
help: Replace with `[1, 2, 3, *foo]`
   |
38 | foo = [4, 5, 6]
   - bar = [1, 2, 3] + foo
39 + bar = [1, 2, 3, *foo]
40 | zoob = tuple(bar)
   |
note: This is an unsafe fix and may change runtime behavior

RUF005 [*] Consider `(7, 8, 9, *zoob)` instead of concatenation
  --> RUF005.py:41:8
   |
39 | bar = [1, 2, 3] + foo
40 | zoob = tuple(bar)
41 | quux = (7, 8, 9) + zoob
   |        ^^^^^^^^^^^^^^^^
42 | spam = quux + (10, 11, 12)
43 | spom = list(spam)
   |
help: Replace with `(7, 8, 9, *zoob)`
   |
40 | zoob = tuple(bar)
   - quux = (7, 8, 9) + zoob
41 + quux = (7, 8, 9, *zoob)
42 | spam = quux + (10, 11, 12)
   |
note: This is an unsafe fix and may change runtime behavior

RUF005 [*] Consider `(*quux, 10, 11, 12)` instead of concatenation
  --> RUF005.py:42:8
   |
40 | zoob = tuple(bar)
41 | quux = (7, 8, 9) + zoob
42 | spam = quux + (10, 11, 12)
   |        ^^^^^^^^^^^^^^^^^^^
43 | spom = list(spam)
44 | eggs = spom + [13, 14, 15]
   |
help: Replace with `(*quux, 10, 11, 12)`
   |
41 | quux = (7, 8, 9) + zoob
   - spam = quux + (10, 11, 12)
42 + spam = (*quux, 10, 11, 12)
43 | spom = list(spam)
   |
note: This is an unsafe fix and may change runtime behavior

RUF005 [*] Consider `[*spom, 13, 14, 15]` instead of concatenation
  --> RUF005.py:44:8
   |
42 | spam = quux + (10, 11, 12)
43 | spom = list(spam)
44 | eggs = spom + [13, 14, 15]
   |        ^^^^^^^^^^^^^^^^^^^
45 | elatement = ("we all say",) + yay()
46 | excitement = ("we all think",) + Fun().yay()
   |
help: Replace with `[*spom, 13, 14, 15]`
   |
43 | spom = list(spam)
   - eggs = spom + [13, 14, 15]
44 + eggs = [*spom, 13, 14, 15]
45 | elatement = ("we all say",) + yay()
   |
note: This is an unsafe fix and may change runtime behavior

RUF005 [*] Consider `("we all say", *yay())` instead of concatenation
  --> RUF005.py:45:13
   |
43 | spom = list(spam)
44 | eggs = spom + [13, 14, 15]
45 | elatement = ("we all say",) + yay()
   |             ^^^^^^^^^^^^^^^^^^^^^^^
46 | excitement = ("we all think",) + Fun().yay()
47 | astonishment = ("we all feel",) + Fun.words
   |
help: Replace with `("we all say", *yay())`
   |
44 | eggs = spom + [13, 14, 15]
   - elatement = ("we all say",) + yay()
45 + elatement = ("we all say", *yay())
46 | excitement = ("we all think",) + Fun().yay()
   |
note: This is an unsafe fix and may change runtime behavior

RUF005 [*] Consider `("we all think", *Fun().yay())` instead of concatenation
  --> RUF005.py:46:14
   |
44 | eggs = spom + [13, 14, 15]
45 | elatement = ("we all say",) + yay()
46 | excitement = ("we all think",) + Fun().yay()
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47 | astonishment = ("we all feel",) + Fun.words
   |
help: Replace with `("we all think", *Fun().yay())`
   |
45 | elatement = ("we all say",) + yay()
   - excitement = ("we all think",) + Fun().yay()
46 + excitement = ("we all think", *Fun().yay())
47 | astonishment = ("we all feel",) + Fun.words
   |
note: This is an unsafe fix and may change runtime behavior

RUF005 [*] Consider `("we all feel", *Fun.words)` instead of concatenation
  --> RUF005.py:47:16
   |
45 | elatement = ("we all say",) + yay()
46 | excitement = ("we all think",) + Fun().yay()
47 | astonishment = ("we all feel",) + Fun.words
   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
48 |
49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob)
   |
help: Replace with `("we all feel", *Fun.words)`
   |
46 | excitement = ("we all think",) + Fun().yay()
   - astonishment = ("we all feel",) + Fun.words
47 + astonishment = ("we all feel", *Fun.words)
48 |
   |
note: This is an unsafe fix and may change runtime behavior

RUF005 [*] Consider iterable unpacking instead of concatenation
  --> RUF005.py:49:9
   |
47 | astonishment = ("we all feel",) + Fun.words
48 |
49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob)
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
50 |
51 | baz = () + zoob
   |
help: Replace with iterable unpacking
   |
48 |
   - chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob)
49 + chain = ["a", "b", "c", *eggs, *list(("yes", "no", "pants") + zoob)]
50 |
   |
note: This is an unsafe fix and may change runtime behavior

RUF005 [*] Consider `("yes", "no", "pants", *zoob)` instead of concatenation
  --> RUF005.py:49:39
   |
47 | astonishment = ("we all feel",) + Fun.words
48 |
49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob)
   |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
50 |
51 | baz = () + zoob
   |
help: Replace with `("yes", "no", "pants", *zoob)`
   |
48 |
   - chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob)
49 + chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants", *zoob))
50 |
   |
note: This is an unsafe fix and may change runtime behavior

RUF005 [*] Consider `(*zoob,)` instead of concatenation
  --> RUF005.py:51:7
   |
49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob)
50 |
51 | baz = () + zoob
   |       ^^^^^^^^^
52 |
53 | [] + foo + [
   |
help: Replace with `(*zoob,)`
   |
50 |
   - baz = () + zoob
51 + baz = (*zoob,)
52 |
   |
note: This is an unsafe fix and may change runtime behavior

RUF005 [*] Consider `[*foo]` instead of concatenation
  --> RUF005.py:53:1
   |
51 |   baz = () + zoob
52 |
53 | / [] + foo + [
54 | | ]
   | |_^
55 |
56 |   pylint_call = [sys.executable, "-m", "pylint"] + args + [path]
   |
help: Replace with `[*foo]`
   |
52 |
   - [] + foo + [
   - ]
53 + [*foo]
54 |
   |
note: This is an unsafe fix and may change runtime behavior

RUF005 [*] Consider `[sys.executable, "-m", "pylint", *args, path]` instead of concatenation
  --> RUF005.py:56:15
   |
54 | ]
55 |
56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path]
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2)
58 | b = a + [2, 3] + [4]
   |
help: Replace with `[sys.executable, "-m", "pylint", *args, path]`
   |
55 |
   - pylint_call = [sys.executable, "-m", "pylint"] + args + [path]
56 + pylint_call = [sys.executable, "-m", "pylint", *args, path]
57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2)
   |
note: This is an unsafe fix and may change runtime behavior

RUF005 [*] Consider iterable unpacking instead of concatenation
  --> RUF005.py:57:21
   |
56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path]
57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2)
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
58 | b = a + [2, 3] + [4]
   |
help: Replace with iterable unpacking
   |
56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path]
   - pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2)
57 + pylint_call_tuple = (sys.executable, "-m", "pylint", *args, path, path2)
58 | b = a + [2, 3] + [4]
   |
note: This is an unsafe fix and may change runtime behavior

RUF005 [*] Consider `[*a, 2, 3, 4]` instead of concatenation
  --> RUF005.py:58:5
   |
56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path]
57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2)
58 | b = a + [2, 3] + [4]
   |     ^^^^^^^^^^^^^^^^
59 |
60 | # Uses the non-preferred quote style, which should be retained.
   |
help: Replace with `[*a, 2, 3, 4]`
   |
57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2)
   - b = a + [2, 3] + [4]
58 + b = [*a, 2, 3, 4]
59 |
   |
note: This is an unsafe fix and may change runtime behavior

RUF005 [*] Consider `[*a(), 'b']` instead of concatenation
  --> RUF005.py:61:4
   |
60 | # Uses the non-preferred quote style, which should be retained.
61 | f"{a() + ['b']}"
   |    ^^^^^^^^^^^
62 |
63 | ###
   |
help: Replace with `[*a(), 'b']`
   |
60 | # Uses the non-preferred quote style, which should be retained.
   - f"{a() + ['b']}"
61 + f"{[*a(), 'b']}"
62 |
   |
note: This is an unsafe fix and may change runtime behavior
