diff --git a/crates/ruff_linter/src/rules/ruff/rules/quadratic_list_summation.rs b/crates/ruff_linter/src/rules/ruff/rules/quadratic_list_summation.rs index 53d4bf44cecd5..6e123e1960c6d 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/quadratic_list_summation.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/quadratic_list_summation.rs @@ -46,6 +46,14 @@ use crate::importer::ImportRequest; /// functools.reduce(operator.iadd, lists, []) /// ``` /// +/// ## Fix safety +/// +/// This fix is always marked as unsafe because `sum` uses the `__add__` magic method while +/// `operator.iadd` uses the `__iadd__` magic method, and these behave differently on lists. +/// The former requires the right summand to be a list, whereas the latter allows for any iterable. +/// Therefore, the fix could inadvertently cause code that previously raised an error to silently +/// succeed. Moreover, the fix could remove comments from the original code. +/// /// ## References /// - [_How Not to Flatten a List of Lists in Python_](https://mathieularose.com/how-not-to-flatten-a-list-of-lists-in-python) /// - [_How do I make a flat list out of a list of lists?_](https://stackoverflow.com/questions/952914/how-do-i-make-a-flat-list-out-of-a-list-of-lists/953097#953097)