Skip to content

Commit 83f6889

Browse files
Allow next in FBT exclusions (#6729)
Closes #6711.
1 parent aafde6d commit 83f6889

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

crates/ruff/resources/test/fixtures/flake8_boolean_trap/FBT.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def used(do):
6969
settings.set_enable_developer_extras(True)
7070
foo.is_(True)
7171
bar.is_not(False)
72+
next(iter([]), False)
7273

7374
class Registry:
7475
def __init__(self) -> None:

crates/ruff/src/rules/flake8_boolean_trap/helpers.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ use ruff_python_ast::{self as ast, Constant, Expr};
44
pub(super) fn is_allowed_func_call(name: &str) -> bool {
55
matches!(
66
name,
7-
"append"
7+
"__setattr__"
8+
| "append"
89
| "assertEqual"
910
| "assertEquals"
1011
| "assertNotEqual"
@@ -26,13 +27,13 @@ pub(super) fn is_allowed_func_call(name: &str) -> bool {
2627
| "int"
2728
| "is_"
2829
| "is_not"
30+
| "next"
2931
| "param"
3032
| "pop"
3133
| "remove"
3234
| "set_blocking"
3335
| "set_enabled"
3436
| "setattr"
35-
| "__setattr__"
3637
| "setdefault"
3738
| "str"
3839
)

crates/ruff/src/rules/flake8_boolean_trap/snapshots/ruff__rules__flake8_boolean_trap__tests__FBT001_FBT.py.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ FBT.py:19:5: FBT001 Boolean-typed positional argument in function definition
8181
21 | kwonly_nonvalued_nohint,
8282
|
8383

84-
FBT.py:86:19: FBT001 Boolean-typed positional argument in function definition
84+
FBT.py:87:19: FBT001 Boolean-typed positional argument in function definition
8585
|
86-
85 | # FBT001: Boolean positional arg in function definition
87-
86 | def foo(self, value: bool) -> None:
86+
86 | # FBT001: Boolean positional arg in function definition
87+
87 | def foo(self, value: bool) -> None:
8888
| ^^^^^ FBT001
89-
87 | pass
89+
88 | pass
9090
|
9191

9292

0 commit comments

Comments
 (0)