Skip to content

Commit c52f5b9

Browse files
committed
Ruff F841: fixes and noqa for unused variables
1 parent d4fd9bc commit c52f5b9

File tree

94 files changed

+258
-274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+258
-274
lines changed

duckdb/experimental/spark/sql/column.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
__all__ = ["Column"]
1313

1414

15-
def _get_expr(x: "Column" | str) -> Expression:
15+
def _get_expr(x: Union["Column", str]) -> Expression:
1616
return x.expr if isinstance(x, Column) else ConstantExpression(x)
1717

1818

scripts/get_cpp_methods.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ def get_methods(class_name: str) -> dict[str, ConnectionMethod]:
6262
),
6363
"DuckDBPyRelation": os.path.join(scripts_folder, "..", "src", "include", "duckdb_python", "pyrelation.hpp"),
6464
}
65-
# Create a dictionary to store method names and prototypes
66-
methods_dict = {}
6765

6866
path = CLASSES[class_name]
6967

tests/coverage/test_pandas_categorical_coverage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def check_create_table(category, pandas):
2323

2424
category.append("bla")
2525

26-
df_in_diff = pandas.DataFrame(
26+
df_in_diff = pandas.DataFrame( # noqa: F841
2727
{
2828
"k": pandas.Categorical(category, ordered=True),
2929
}

tests/extensions/json/test_read_json.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,4 @@ def test_read_json_options(self, duckdb_cursor, option):
122122
rel = duckdb_cursor.read_json(TestFile("example.json"), **keyword_arguments)
123123
else:
124124
rel = duckdb_cursor.read_json(TestFile("example.json"), **keyword_arguments)
125-
res = rel.fetchall()
125+
rel.fetchall()

tests/fast/api/test_3324.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@
55

66
class Test3324:
77
def test_3324(self, duckdb_cursor):
8-
create_output = duckdb_cursor.execute(
8+
duckdb_cursor.execute(
99
"""
10-
create or replace table my_table as
11-
select 'test1' as column1, 1 as column2, 'quack' as column3
10+
create or replace table my_table as
11+
select 'test1' as column1, 1 as column2, 'quack' as column3
1212
union all
13-
select 'test2' as column1, 2 as column2, 'quacks' as column3
13+
select 'test2' as column1, 2 as column2, 'quacks' as column3
1414
union all
15-
select 'test3' as column1, 3 as column2, 'quacking' as column3
15+
select 'test3' as column1, 3 as column2, 'quacking' as column3
1616
"""
1717
).fetch_df()
18-
prepare_output = duckdb_cursor.execute(
18+
duckdb_cursor.execute(
1919
"""
20-
prepare v1 as
21-
select
20+
prepare v1 as
21+
select
2222
column1
2323
, column2
24-
, column3
24+
, column3
2525
from my_table
26-
where
26+
where
2727
column1 = $1"""
2828
).fetch_df()
2929

tests/fast/api/test_config.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# simple DB API testcase
2-
1+
# ruff: noqa: F841
32
import os
43
import re
54

@@ -57,15 +56,15 @@ def test_extension_setting(self):
5756
def test_unrecognized_option(self, duckdb_cursor):
5857
success = True
5958
try:
60-
con_regular = duckdb.connect(":memory:", config={"thisoptionisprobablynotthere": "42"})
59+
duckdb.connect(":memory:", config={"thisoptionisprobablynotthere": "42"})
6160
except:
6261
success = False
6362
assert success == False
6463

6564
def test_incorrect_parameter(self, duckdb_cursor):
6665
success = True
6766
try:
68-
con_regular = duckdb.connect(":memory:", config={"default_null_order": "42"})
67+
duckdb.connect(":memory:", config={"default_null_order": "42"})
6968
except:
7069
success = False
7170
assert success == False

tests/fast/api/test_cursor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_cursor_temp_schema_closed(self):
5252
cursor.close()
5353
with pytest.raises(duckdb.CatalogException):
5454
# This table does not exist in this cursor
55-
res = other_cursor.execute("select * from tbl").fetchall()
55+
other_cursor.execute("select * from tbl").fetchall()
5656

5757
def test_cursor_temp_schema_open(self):
5858
con = duckdb.connect(":memory:")
@@ -63,7 +63,7 @@ def test_cursor_temp_schema_open(self):
6363
# cursor.close()
6464
with pytest.raises(duckdb.CatalogException):
6565
# This table does not exist in this cursor
66-
res = other_cursor.execute("select * from tbl").fetchall()
66+
other_cursor.execute("select * from tbl").fetchall()
6767

6868
def test_cursor_temp_schema_both(self):
6969
con = duckdb.connect(":memory:")
@@ -99,7 +99,7 @@ def test_cursor_closed(self):
9999
con = duckdb.connect(":memory:")
100100
con.close()
101101
with pytest.raises(duckdb.ConnectionException):
102-
cursor = con.cursor()
102+
con.cursor()
103103

104104
def test_cursor_used_after_connection_closed(self):
105105
con = duckdb.connect(":memory:")

tests/fast/api/test_dbapi00.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ def test_fetchmany_default(self, duckdb_cursor, integers):
2020
truth_value = len(duckdb_cursor.execute("select * from integers").fetchall())
2121

2222
duckdb_cursor.execute("Select * from integers")
23-
# by default 'size' is 1
24-
arraysize = 1
2523
list_of_results = []
2624
while True:
2725
res = duckdb_cursor.fetchmany()

tests/fast/api/test_dbapi_fetch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_multiple_fetch_df(self, duckdb_cursor):
3939

4040
def test_multiple_fetch_arrow(self, duckdb_cursor):
4141
pd = pytest.importorskip("pandas")
42-
arrow = pytest.importorskip("pyarrow")
42+
pytest.importorskip("pyarrow")
4343
con = duckdb.connect()
4444
c = con.execute("SELECT 42::BIGINT AS a")
4545
table = c.fetch_arrow_table()

tests/fast/api/test_duckdb_connection.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ def test_default_connection_from_connect(self):
5151
con = duckdb.connect(":default:", read_only=True)
5252

5353
def test_arrow(self):
54-
pyarrow = pytest.importorskip("pyarrow")
54+
pytest.importorskip("pyarrow")
5555
duckdb.execute("select [1,2,3]")
56-
result = duckdb.fetch_arrow_table()
56+
duckdb.fetch_arrow_table()
5757

5858
def test_begin_commit(self):
5959
duckdb.begin()
6060
duckdb.execute("create table tbl as select 1")
6161
duckdb.commit()
62-
res = duckdb.table("tbl")
62+
duckdb.table("tbl")
6363
duckdb.execute("drop table tbl")
6464

6565
def test_begin_rollback(self):
@@ -68,7 +68,7 @@ def test_begin_rollback(self):
6868
duckdb.rollback()
6969
with pytest.raises(duckdb.CatalogException):
7070
# Table does not exist
71-
res = duckdb.table("tbl")
71+
duckdb.table("tbl")
7272

7373
def test_cursor(self):
7474
duckdb.execute("create table tbl as select 3")
@@ -98,7 +98,7 @@ def use_cursors():
9898
def test_df(self):
9999
ref = [([1, 2, 3],)]
100100
duckdb.execute("select [1,2,3]")
101-
res_df = duckdb.fetch_df()
101+
res_df = duckdb.fetch_df() # noqa: F841
102102
res = duckdb.query("select * from res_df").fetchall()
103103
assert res == ref
104104

@@ -148,10 +148,10 @@ def test_pystatement(self):
148148
duckdb.InvalidInputException,
149149
match="Please provide either a DuckDBPyStatement or a string representing the query",
150150
):
151-
rel = duckdb.query(statements)
151+
duckdb.query(statements)
152152

153153
with pytest.raises(duckdb.BinderException, match="This type of statement can't be prepared!"):
154-
rel = duckdb.query(statements[0])
154+
duckdb.query(statements[0])
155155

156156
assert duckdb.query(statements[1]).fetchall() == [(21,)]
157157
assert duckdb.execute(statements[1]).fetchall() == [(21,)]
@@ -179,7 +179,7 @@ def test_pystatement(self):
179179

180180
def test_fetch_arrow_table(self):
181181
# Needed for 'fetch_arrow_table'
182-
pyarrow = pytest.importorskip("pyarrow")
182+
pytest.importorskip("pyarrow")
183183

184184
duckdb.execute("Create Table test (a integer)")
185185

@@ -205,7 +205,7 @@ def test_fetch_arrow_table(self):
205205
def test_fetch_df(self):
206206
ref = [([1, 2, 3],)]
207207
duckdb.execute("select [1,2,3]")
208-
res_df = duckdb.fetch_df()
208+
res_df = duckdb.fetch_df() # noqa: F841
209209
res = duckdb.query("select * from res_df").fetchall()
210210
assert res == ref
211211

@@ -222,7 +222,7 @@ def test_fetch_df_chunk(self):
222222

223223
def test_fetch_record_batch(self):
224224
# Needed for 'fetch_arrow_table'
225-
pyarrow = pytest.importorskip("pyarrow")
225+
pytest.importorskip("pyarrow")
226226

227227
duckdb.execute("CREATE table t as select range a from range(3000);")
228228
duckdb.execute("SELECT a FROM t")
@@ -236,7 +236,7 @@ def test_fetchall(self):
236236
def test_fetchdf(self):
237237
ref = [([1, 2, 3],)]
238238
duckdb.execute("select [1,2,3]")
239-
res_df = duckdb.fetchdf()
239+
res_df = duckdb.fetchdf() # noqa: F841
240240
res = duckdb.query("select * from res_df").fetchall()
241241
assert res == ref
242242

@@ -363,7 +363,7 @@ def test_wrap_shadowing(self):
363363
pd = NumpyPandas()
364364
import duckdb
365365

366-
df = pd.DataFrame({"a": [1, 2, 3]})
366+
df = pd.DataFrame({"a": [1, 2, 3]}) # noqa: F841
367367
res = duckdb.sql("from df").fetchall()
368368
assert res == [(1,), (2,), (3,)]
369369

0 commit comments

Comments
 (0)