Closed
Description
opened on Jul 10, 2024
FURB187 autofix causes breaking changes when applied to function arguments
I have the FURB ruleset set to autofix but found the autofix for FURB187 was breaking code when applied to arguments of functions since it was mutating objects outside of the function scope.
Example Code
def local_reverse_print_list(some_list: list[int]):
some_list = list(reversed(some_list)) # FURB187 will fix to: some_list.reverse()
print(f"Function shows list as: {some_list}")
a_list = [1,2,3]
local_reverse_print_list(a_list)
print(f"Original list: {a_list}") # Oops - the outside list is now mutated too after the FURB187 fix
Ruff settings (relevant subset of actual settings)
[tool.ruff.lint]
# See https://docs.astral.sh/ruff/rules/
select = [
"FURB",
]
# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []
Ruff version
0.5.1
Activity