Skip to content

Commit

Permalink
Add sqlalchemy methods to boolean-trap exclusion list (#7874)
Browse files Browse the repository at this point in the history
Closes #7869.
  • Loading branch information
charliermarsh committed Oct 9, 2023
1 parent 016e162 commit 97e9440
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def used(do):
foo.is_(True)
bar.is_not(False)
next(iter([]), False)
sa.func.coalesce(tbl.c.valid, False)


class Registry:
def __init__(self) -> None:
Expand Down
4 changes: 4 additions & 0 deletions crates/ruff_linter/src/rules/flake8_boolean_trap/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub(super) fn is_allowed_func_call(name: &str) -> bool {
| "assertNotEquals"
| "bool"
| "bytes"
// | "coalesce"
| "count"
| "failIfEqual"
| "failUnlessEqual"
Expand All @@ -22,12 +23,15 @@ pub(super) fn is_allowed_func_call(name: &str) -> bool {
| "getboolean"
| "getfloat"
| "getint"
| "ifnull"
| "index"
| "insert"
| "int"
| "is_"
| "is_not"
| "isnull"
| "next"
| "nvl"
| "param"
| "pop"
| "remove"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ FBT.py:19:5: FBT001 Boolean-typed positional argument in function definition
21 | kwonly_nonvalued_nohint,
|

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


Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,12 @@ FBT.py:69:38: FBT003 Boolean positional value in function call
71 | bar.is_not(False)
|

FBT.py:73:31: FBT003 Boolean positional value in function call
|
71 | bar.is_not(False)
72 | next(iter([]), False)
73 | sa.func.coalesce(tbl.c.valid, False)
| ^^^^^ FBT003
|


0 comments on commit 97e9440

Please sign in to comment.