For me the following
extras = ["extra0", "extra1"]
func_with_list_arg([
"base0",
"base1",
] + extras)
is nicer to read with a spread operator like the following
extras = ["extra0", "extra1"]
func_with_list_arg([
"base0",
"base1",
*extras,
])
Is there a lint rule in ruff or pylint that would detect this situation?
Yes, there is!
c = [3]
b = [1, 2] + c
print(b)
When I run (my configured) ruff on this, I get:
RUF005 [*] Consider
[1, 2, *c]
instead of concatenation
This is part of the ruff specific ruleset: https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf and is a rule which is actually automatically fixable.