Add `sqlalchemy` methods to boolean-trap exclusion list (#7874)

Closes https://github.com/astral-sh/ruff/issues/7869.
This commit is contained in:
Charlie Marsh 2023-10-09 14:50:51 -04:00 committed by GitHub
parent 016e16254a
commit 97e944003b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 4 deletions

View File

@ -70,6 +70,8 @@ settings.set_enable_developer_extras(True)
foo.is_(True)
bar.is_not(False)
next(iter([]), False)
sa.func.coalesce(tbl.c.valid, False)
class Registry:
def __init__(self) -> None:

View File

@ -12,6 +12,7 @@ pub(super) fn is_allowed_func_call(name: &str) -> bool {
| "assertNotEquals"
| "bool"
| "bytes"
// | "coalesce"
| "count"
| "failIfEqual"
| "failUnlessEqual"
@ -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"

View File

@ -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
|

View File

@ -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
|