From 9edcb678d0fe6991d3b6f85406572c70a423c99e Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Sat, 21 Oct 2023 18:09:10 +0200 Subject: [PATCH] Add `Known problems` section to explain why the fix is unsafe --- .../rules/flake8_bugbear/rules/mutable_argument_default.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/rules/mutable_argument_default.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/mutable_argument_default.rs index e0208b472a7e3..71925d0f2da08 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/rules/mutable_argument_default.rs +++ b/crates/ruff_linter/src/rules/flake8_bugbear/rules/mutable_argument_default.rs @@ -30,6 +30,12 @@ use crate::checkers::ast::Checker; /// Types outside of the standard library can be marked as immutable with the /// [`flake8-bugbear.extend-immutable-calls`] configuration option. /// +/// ## Known problems +/// Mutable argument defaults can be used intentionally to cache computation +/// results. Replacing the default with `None` or an immutable data structure +/// does not work for such usages. Instead, prefer the `@functools.lru_cache` +/// decorator from the standard library. +/// /// ## Example /// ```python /// def add_to_list(item, some_list=[]):