Skip to content

Commit 9f9623c

Browse files
committed
Ruff linting
1 parent c52f5b9 commit 9f9623c

File tree

5 files changed

+32
-38
lines changed

5 files changed

+32
-38
lines changed

tests/fast/adbc/test_adbc.py

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,9 @@ def test_commit(tmp_path):
137137
driver=driver_path,
138138
entrypoint="duckdb_adbc_init",
139139
db_kwargs=db_kwargs,
140-
) as conn:
141-
with conn.cursor() as cur:
142-
cur.execute("SELECT count(*) from ingest")
143-
assert cur.fetch_arrow_table().to_pydict() == {"count_star()": [4]}
140+
) as conn, conn.cursor() as cur:
141+
cur.execute("SELECT count(*) from ingest")
142+
assert cur.fetch_arrow_table().to_pydict() == {"count_star()": [4]}
144143

145144

146145
def test_connection_get_table_schema(duck_conn):
@@ -308,11 +307,10 @@ def test_large_chunk(tmp_path):
308307
entrypoint="duckdb_adbc_init",
309308
db_kwargs=db_kwargs,
310309
autocommit=True,
311-
) as conn:
312-
with conn.cursor() as cur:
313-
cur.adbc_ingest("ingest", table, "create")
314-
cur.execute("SELECT count(*) from ingest")
315-
assert cur.fetch_arrow_table().to_pydict() == {"count_star()": [30_000]}
310+
) as conn, conn.cursor() as cur:
311+
cur.adbc_ingest("ingest", table, "create")
312+
cur.execute("SELECT count(*) from ingest")
313+
assert cur.fetch_arrow_table().to_pydict() == {"count_star()": [30_000]}
316314

317315

318316
def test_dictionary_data(tmp_path):
@@ -332,13 +330,12 @@ def test_dictionary_data(tmp_path):
332330
entrypoint="duckdb_adbc_init",
333331
db_kwargs=db_kwargs,
334332
autocommit=True,
335-
) as conn:
336-
with conn.cursor() as cur:
337-
cur.adbc_ingest("ingest", table, "create")
338-
cur.execute("from ingest")
339-
assert cur.fetch_arrow_table().to_pydict() == {
340-
"fruits": ["apple", "banana", "apple", "orange", "banana", "banana"]
341-
}
333+
) as conn, conn.cursor() as cur:
334+
cur.adbc_ingest("ingest", table, "create")
335+
cur.execute("from ingest")
336+
assert cur.fetch_arrow_table().to_pydict() == {
337+
"fruits": ["apple", "banana", "apple", "orange", "banana", "banana"]
338+
}
342339

343340

344341
def test_ree_data(tmp_path):
@@ -358,13 +355,12 @@ def test_ree_data(tmp_path):
358355
entrypoint="duckdb_adbc_init",
359356
db_kwargs=db_kwargs,
360357
autocommit=True,
361-
) as conn:
362-
with conn.cursor() as cur:
363-
cur.adbc_ingest("ingest", table, "create")
364-
cur.execute("from ingest")
365-
assert cur.fetch_arrow_table().to_pydict() == {
366-
"fruits": ["apple", "apple", "apple", "banana", "banana", "orange"]
367-
}
358+
) as conn, conn.cursor() as cur:
359+
cur.adbc_ingest("ingest", table, "create")
360+
cur.execute("from ingest")
361+
assert cur.fetch_arrow_table().to_pydict() == {
362+
"fruits": ["apple", "apple", "apple", "banana", "banana", "orange"]
363+
}
368364

369365

370366
def sorted_get_objects(catalogs):

tests/fast/api/test_connection_close.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ def test_connection_close(self, duckdb_cursor):
3030
check_exception(lambda: cursor.execute("select * from a"))
3131

3232
def test_open_and_exit(self):
33-
with pytest.raises(TypeError):
34-
with duckdb.connect() as connection:
35-
connection.execute("select 42")
36-
# This exception does not get swallowed by __exit__
37-
raise TypeError()
33+
with pytest.raises(TypeError), duckdb.connect() as connection:
34+
connection.execute("select 42")
35+
# This exception does not get swallowed by __exit__
36+
raise TypeError()
3837

3938
def test_reopen_connection(self, duckdb_cursor):
4039
fd, db = tempfile.mkstemp()

tests/fast/api/test_with_propagating_exceptions.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
class TestWithPropagatingExceptions:
77
def test_with(self):
88
# Should propagate exception raised in the 'with duckdb.connect() ..'
9-
with pytest.raises(duckdb.ParserException, match="syntax error at or near *"):
10-
with duckdb.connect() as con:
11-
print("before")
12-
con.execute("invalid")
13-
print("after")
9+
with pytest.raises(duckdb.ParserException, match="syntax error at or near *"), duckdb.connect() as con:
10+
print("before")
11+
con.execute("invalid")
12+
print("after")
1413

1514
# Does not raise an exception
1615
with duckdb.connect() as con:

tests/fast/arrow/test_arrow_replacement_scan.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ def test_arrow_table_replacement_scan(self, duckdb_cursor):
2727
)
2828
def test_arrow_pycapsule_replacement_scan(self, duckdb_cursor):
2929
tbl = pa.Table.from_pydict({"a": [1, 2, 3, 4, 5, 6, 7, 8, 9]})
30-
capsule = tbl.__arrow_c_stream__() # noqa: F841
30+
capsule = tbl.__arrow_c_stream__()
3131

3232
rel = duckdb_cursor.sql("select * from capsule")
3333
assert rel.fetchall() == [(i,) for i in range(1, 10)]
3434

35-
capsule = tbl.__arrow_c_stream__() # noqa: F841
35+
capsule = tbl.__arrow_c_stream__()
3636
rel = duckdb_cursor.sql("select * from capsule where a > 3 and a < 5")
3737
assert rel.fetchall() == [(4,)]
3838

@@ -54,7 +54,7 @@ def test_arrow_pycapsule_replacement_scan(self, duckdb_cursor):
5454

5555
def test_arrow_table_replacement_scan_view(self, duckdb_cursor):
5656
parquet_filename = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data", "userdata1.parquet")
57-
userdata_parquet_table = pq.read_table(parquet_filename) # noqa: F841
57+
userdata_parquet_table = pq.read_table(parquet_filename)
5858

5959
con = duckdb.connect()
6060

tests/fast/test_all_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,9 @@ def test_pandas(self, cur_type):
589589
warnings.simplefilter(action="ignore", category=RuntimeWarning)
590590
with suppress(TypeError):
591591
if cur_type in replacement_values:
592-
dataframe = conn.execute("select " + replacement_values[cur_type]).df() # noqa: F841
592+
dataframe = conn.execute("select " + replacement_values[cur_type]).df()
593593
elif cur_type in adjusted_values:
594-
dataframe = conn.execute(f"select {adjusted_values[cur_type]} from test_all_types()").df() # noqa: F841
594+
dataframe = conn.execute(f"select {adjusted_values[cur_type]} from test_all_types()").df()
595595
else:
596596
dataframe = conn.execute(f'select "{cur_type}" from test_all_types()').df() # noqa: F841
597597
print(cur_type)

0 commit comments

Comments
 (0)