Skip to content

Commit 6356b2a

Browse files
committed
Ruff E712: don't compare with True or False
1 parent 2ac0176 commit 6356b2a

17 files changed

+33
-33
lines changed

scripts/generate_connection_methods.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
def is_py_kwargs(method):
17-
return "kwargs_as_dict" in method and method["kwargs_as_dict"] == True
17+
return "kwargs_as_dict" in method and method["kwargs_as_dict"]
1818

1919

2020
def is_py_args(method):

scripts/generate_connection_wrapper_methods.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def is_py_args(method):
6767

6868

6969
def is_py_kwargs(method):
70-
return "kwargs_as_dict" in method and method["kwargs_as_dict"] == True
70+
return "kwargs_as_dict" in method and method["kwargs_as_dict"]
7171

7272

7373
def remove_section(content, start_marker, end_marker) -> tuple[list[str], list[str]]:

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def pandas_supports_arrow_backend():
109109
try:
110110
from pandas.compat import pa_version_under11p0
111111

112-
if pa_version_under11p0 == True:
112+
if pa_version_under11p0:
113113
return False
114114
except ImportError:
115115
return False

tests/fast/api/test_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_external_access(self, duckdb_cursor, pandas):
4444
con.execute("select * from df").fetchall()
4545
except Exception:
4646
query_failed = True
47-
assert query_failed == True
47+
assert query_failed
4848

4949
def test_extension_setting(self):
5050
repository = os.environ.get("LOCAL_EXTENSION_REPO")
@@ -59,15 +59,15 @@ def test_unrecognized_option(self, duckdb_cursor):
5959
duckdb.connect(":memory:", config={"thisoptionisprobablynotthere": "42"})
6060
except Exception:
6161
success = False
62-
assert success == False
62+
assert not success
6363

6464
def test_incorrect_parameter(self, duckdb_cursor):
6565
success = True
6666
try:
6767
duckdb.connect(":memory:", config={"default_null_order": "42"})
6868
except Exception:
6969
success = False
70-
assert success == False
70+
assert not success
7171

7272
def test_user_agent_default(self, duckdb_cursor):
7373
con_regular = duckdb.connect(":memory:")

tests/fast/api/test_dbapi10.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def test_description_comparisons(self):
4242
assert types[1] == STRING
4343
assert STRING == types[1] # noqa: SIM300
4444
assert types[0] != STRING
45-
assert (types[1] != STRING) == False
46-
assert (STRING != types[1]) == False # noqa: SIM300
45+
assert not (types[1] != STRING)
46+
assert not (STRING != types[1]) # noqa: SIM300
4747

4848
assert types[1] in [STRING]
4949
assert types[1] in [STRING, NUMBER]

tests/fast/arrow/test_arrow_run_end_encoding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def test_arrow_ree_projections(self, duckdb_cursor, projection):
218218

219219
# Verify that the array is run end encoded
220220
ar_type = arrow_tbl["ree"].type
221-
assert pa.types.is_run_end_encoded(ar_type) == True
221+
assert pa.types.is_run_end_encoded(ar_type)
222222

223223
# Scan the arrow table, making projections that don't cover the entire table
224224
# This should be pushed down into arrow to only provide us with the necessary columns

tests/fast/arrow/test_polars.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def test_polars_lazy_pushdown_bool(self, duckdb_cursor):
273273

274274
lazy_df = duck_tbl.pl(lazy=True)
275275
# == True
276-
assert lazy_df.filter(pl.col("a") == True).select(pl.len()).collect().item() == 2
276+
assert lazy_df.filter(pl.col("a")).select(pl.len()).collect().item() == 2
277277

278278
# IS NULL
279279
assert lazy_df.filter(pl.col("a").is_null()).select(pl.len()).collect().item() == 1
@@ -282,17 +282,17 @@ def test_polars_lazy_pushdown_bool(self, duckdb_cursor):
282282
assert lazy_df.filter(pl.col("a").is_not_null()).select(pl.len()).collect().item() == 3
283283

284284
# AND
285-
assert lazy_df.filter((pl.col("a") == True) & (pl.col("b") == True)).select(pl.len()).collect().item() == 1
285+
assert lazy_df.filter((pl.col("a")) & (pl.col("b"))).select(pl.len()).collect().item() == 1
286286

287287
# OR
288-
assert lazy_df.filter((pl.col("a") == True) | (pl.col("b") == True)).select(pl.len()).collect().item() == 3
288+
assert lazy_df.filter((pl.col("a")) | (pl.col("b"))).select(pl.len()).collect().item() == 3
289289

290290
# Validate Filters
291-
valid_filter(pl.col("a") == True)
291+
valid_filter(pl.col("a"))
292292
valid_filter(pl.col("a").is_null())
293293
valid_filter(pl.col("a").is_not_null())
294-
valid_filter((pl.col("a") == True) & (pl.col("b") == True))
295-
valid_filter((pl.col("a") == True) | (pl.col("b") == True))
294+
valid_filter((pl.col("a")) & (pl.col("b")))
295+
valid_filter((pl.col("a")) | (pl.col("b")))
296296

297297
def test_polars_lazy_pushdown_time(self, duckdb_cursor):
298298
duckdb_cursor.execute(

tests/fast/pandas/test_copy_on_write.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class TestCopyOnWrite:
3535
],
3636
)
3737
def test_copy_on_write(self, col):
38-
assert pandas.options.mode.copy_on_write == True
38+
assert pandas.options.mode.copy_on_write
3939
con = duckdb.connect()
4040
df_in = pandas.DataFrame( # noqa: F841
4141
{

tests/fast/pandas/test_df_object_resolution.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,18 +511,18 @@ def test_ubigint_object_conversion(self, pandas, duckdb_cursor):
511511
converted_col = duckdb_cursor.sql("select * from x").df()
512512
if pandas.backend == "numpy_nullable":
513513
float64 = np.dtype("float64")
514-
assert isinstance(converted_col["0"].dtype, float64.__class__) == True
514+
assert isinstance(converted_col["0"].dtype, float64.__class__)
515515
else:
516516
uint64 = np.dtype("uint64")
517-
assert isinstance(converted_col["0"].dtype, uint64.__class__) == True
517+
assert isinstance(converted_col["0"].dtype, uint64.__class__)
518518

519519
@pytest.mark.parametrize("pandas", [NumpyPandas()])
520520
def test_double_object_conversion(self, pandas, duckdb_cursor):
521521
data = [18446744073709551616, 0]
522522
x = pandas.DataFrame({"0": pandas.Series(data=data, dtype="object")})
523523
converted_col = duckdb_cursor.sql("select * from x").df()
524524
double_dtype = np.dtype("float64")
525-
assert isinstance(converted_col["0"].dtype, double_dtype.__class__) == True
525+
assert isinstance(converted_col["0"].dtype, double_dtype.__class__)
526526

527527
@pytest.mark.parametrize("pandas", [NumpyPandas(), ArrowPandas()])
528528
@pytest.mark.xfail(
@@ -569,7 +569,7 @@ def test_integer_conversion_fail(self, pandas, duckdb_cursor):
569569
converted_col = duckdb_cursor.sql("select * from x").df()
570570
print(converted_col["0"])
571571
double_dtype = np.dtype("object")
572-
assert isinstance(converted_col["0"].dtype, double_dtype.__class__) == True
572+
assert isinstance(converted_col["0"].dtype, double_dtype.__class__)
573573

574574
# Most of the time numpy.datetime64 is just a wrapper around a datetime.datetime object
575575
# But to support arbitrary precision, it can fall back to using an `int` internally

tests/fast/pandas/test_timedelta.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ def create_python_interval(
7979
equality = "select {value} = $1, {value}, $1"
8080
equality = equality.format(value=duck_interval)
8181
res, a, b = duckdb_cursor.execute(equality, [val]).fetchone()
82-
if res != True:
82+
if not res:
8383
# TODO: in some cases intervals that are identical don't compare equal. # noqa: TD002, TD003
8484
assert a == b
8585
else:
86-
assert res == True
86+
assert res

0 commit comments

Comments
 (0)