From 25171be27500b84b6474d05f2f445ff6e1ffe2be Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Wed, 31 May 2023 11:34:20 +0300 Subject: [PATCH] flake8-boolean-trap: ignore __setattr__ in FBT003 --- crates/ruff/resources/test/fixtures/flake8_boolean_trap/FBT.py | 3 +++ crates/ruff/src/rules/flake8_boolean_trap/helpers.rs | 1 + 2 files changed, 4 insertions(+) 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", ];