diff --git a/crates/ruff/resources/test/fixtures/flake8_boolean_trap/FBT.py b/crates/ruff/resources/test/fixtures/flake8_boolean_trap/FBT.py index 44195828903da..eacf248284abe 100644 --- a/crates/ruff/resources/test/fixtures/flake8_boolean_trap/FBT.py +++ b/crates/ruff/resources/test/fixtures/flake8_boolean_trap/FBT.py @@ -80,3 +80,6 @@ def foo(self, value: bool) -> None: # FBT001: Boolean positional arg in function definition def foo(self, value: bool) -> None: pass + + def foo(self) -> None: + object.__setattr__(self, "flag", True) diff --git a/crates/ruff/src/rules/flake8_boolean_trap/helpers.rs b/crates/ruff/src/rules/flake8_boolean_trap/helpers.rs index 463ad690abde4..963fd62b893d7 100644 --- a/crates/ruff/src/rules/flake8_boolean_trap/helpers.rs +++ b/crates/ruff/src/rules/flake8_boolean_trap/helpers.rs @@ -28,6 +28,7 @@ pub(super) const FUNC_CALL_NAME_ALLOWLIST: &[&str] = &[ "pop", "remove", "setattr", + "__setattr__", "setdefault", "str", ];