From 793aa79be268462df62b85944d3bc242c2a70684 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 21 Aug 2023 10:44:12 -0400 Subject: [PATCH] Allow next in FBT exclusions --- .../resources/test/fixtures/flake8_boolean_trap/FBT.py | 1 + crates/ruff/src/rules/flake8_boolean_trap/helpers.rs | 5 +++-- ..._rules__flake8_boolean_trap__tests__FBT001_FBT.py.snap | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) 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 e8a3a5a3f15c6f..eba1a03097ddfd 100644 --- a/crates/ruff/resources/test/fixtures/flake8_boolean_trap/FBT.py +++ b/crates/ruff/resources/test/fixtures/flake8_boolean_trap/FBT.py @@ -69,6 +69,7 @@ def used(do): settings.set_enable_developer_extras(True) foo.is_(True) bar.is_not(False) +next(iter([]), False) class Registry: def __init__(self) -> None: diff --git a/crates/ruff/src/rules/flake8_boolean_trap/helpers.rs b/crates/ruff/src/rules/flake8_boolean_trap/helpers.rs index 9e1e101e07ae4a..8ff583d7fbd780 100644 --- a/crates/ruff/src/rules/flake8_boolean_trap/helpers.rs +++ b/crates/ruff/src/rules/flake8_boolean_trap/helpers.rs @@ -4,7 +4,8 @@ use ruff_python_ast::{self as ast, Constant, Expr}; pub(super) fn is_allowed_func_call(name: &str) -> bool { matches!( name, - "append" + "__setattr__" + | "append" | "assertEqual" | "assertEquals" | "assertNotEqual" @@ -26,13 +27,13 @@ pub(super) fn is_allowed_func_call(name: &str) -> bool { | "int" | "is_" | "is_not" + | "next" | "param" | "pop" | "remove" | "set_blocking" | "set_enabled" | "setattr" - | "__setattr__" | "setdefault" | "str" ) diff --git a/crates/ruff/src/rules/flake8_boolean_trap/snapshots/ruff__rules__flake8_boolean_trap__tests__FBT001_FBT.py.snap b/crates/ruff/src/rules/flake8_boolean_trap/snapshots/ruff__rules__flake8_boolean_trap__tests__FBT001_FBT.py.snap index 1c38f9930ed253..b1c02ae6948a19 100644 --- a/crates/ruff/src/rules/flake8_boolean_trap/snapshots/ruff__rules__flake8_boolean_trap__tests__FBT001_FBT.py.snap +++ b/crates/ruff/src/rules/flake8_boolean_trap/snapshots/ruff__rules__flake8_boolean_trap__tests__FBT001_FBT.py.snap @@ -81,12 +81,12 @@ FBT.py:19:5: FBT001 Boolean-typed positional argument in function definition 21 | kwonly_nonvalued_nohint, | -FBT.py:86:19: FBT001 Boolean-typed positional argument in function definition +FBT.py:87:19: FBT001 Boolean-typed positional argument in function definition | -85 | # FBT001: Boolean positional arg in function definition -86 | def foo(self, value: bool) -> None: +86 | # FBT001: Boolean positional arg in function definition +87 | def foo(self, value: bool) -> None: | ^^^^^ FBT001 -87 | pass +88 | pass |