Skip to content

Commit 5ad0a0e

Browse files
committed
Ruff B: Fixed last bugbear linting issues
1 parent 11b0851 commit 5ad0a0e

14 files changed

+37
-37
lines changed

duckdb/experimental/spark/sql/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ def approxCountDistinct(col: "ColumnOrName", rsd: Optional[float] = None) -> Col
14951495
.. deprecated:: 2.1.0
14961496
Use :func:`approx_count_distinct` instead.
14971497
"""
1498-
warnings.warn("Deprecated in 2.1, use approx_count_distinct instead.", FutureWarning)
1498+
warnings.warn("Deprecated in 2.1, use approx_count_distinct instead.", FutureWarning, stacklevel=3)
14991499
return approx_count_distinct(col, rsd)
15001500

15011501

duckdb/experimental/spark/sql/types.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ def __getitem__(self, key: Union[str, int]) -> StructField:
855855
return self.fields[key]
856856
except IndexError:
857857
msg = "StructType index out of range"
858-
raise IndexError(msg)
858+
raise IndexError(msg) # noqa: B904
859859
elif isinstance(key, slice):
860860
return StructType(self.fields[key])
861861
else:
@@ -1194,9 +1194,9 @@ def __getitem__(self, item: Any) -> Any: # noqa: D105, ANN401
11941194
idx = self.__fields__.index(item)
11951195
return super(Row, self).__getitem__(idx)
11961196
except IndexError:
1197-
raise KeyError(item)
1197+
raise KeyError(item) # noqa: B904
11981198
except ValueError:
1199-
raise ValueError(item)
1199+
raise ValueError(item) # noqa: B904
12001200

12011201
def __getattr__(self, item: str) -> Any: # noqa: D105, ANN401
12021202
if item.startswith("__"):
@@ -1207,9 +1207,9 @@ def __getattr__(self, item: str) -> Any: # noqa: D105, ANN401
12071207
idx = self.__fields__.index(item)
12081208
return self[idx]
12091209
except IndexError:
1210-
raise AttributeError(item)
1210+
raise AttributeError(item) # noqa: B904
12111211
except ValueError:
1212-
raise AttributeError(item)
1212+
raise AttributeError(item) # noqa: B904
12131213

12141214
def __setattr__(self, key: Any, value: Any) -> None: # noqa: D105, ANN401
12151215
if key != "__fields__":

duckdb/polars_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _pl_operation_to_sql(op: str) -> str:
5656
"Or": "OR",
5757
}[op]
5858
except KeyError:
59-
raise NotImplementedError(op)
59+
raise NotImplementedError(op) # noqa: B904
6060

6161

6262
def _escape_sql_identifier(identifier: str) -> str:

duckdb_packaging/_versioning.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,6 @@ def get_git_describe(
173173
)
174174
result.check_returncode()
175175
return result.stdout.strip()
176-
except FileNotFoundError:
176+
except FileNotFoundError as e:
177177
msg = "git executable can't be found"
178-
raise RuntimeError(msg)
178+
raise RuntimeError(msg) from e

duckdb_packaging/setuptools_scm_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def version_scheme(version: _VersionObject) -> str:
5656
return _bump_dev_version(str(version.tag), distance)
5757
except Exception as e:
5858
msg = f"Failed to bump version: {e}"
59-
raise RuntimeError(msg)
59+
raise RuntimeError(msg) from e
6060

6161

6262
def _tag_to_version(tag: str) -> str:

scripts/generate_import_cache_cpp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def to_string(self):
173173

174174

175175
files: list[ModuleFile] = []
176-
for name, value in json_data.items():
176+
for value in json_data.values():
177177
if value["full_path"] != value["name"]:
178178
continue
179179
files.append(ModuleFile(value))

tests/fast/api/test_duckdb_connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ def test_fetch_arrow_table(self):
186186
duckdb.execute("Create Table test (a integer)")
187187

188188
for i in range(1024):
189-
for j in range(2):
190-
duckdb.execute("Insert Into test values ('" + str(i) + "')")
189+
duckdb.execute("Insert Into test values ('" + str(i) + "')")
190+
duckdb.execute("Insert Into test values ('" + str(i) + "')")
191191
duckdb.execute("Insert Into test values ('5000')")
192192
duckdb.execute("Insert Into test values ('6000')")
193193
sql = """

tests/fast/arrow/test_2426.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_2426(self, duckdb_cursor):
1515
con.execute("Create Table test (a integer)")
1616

1717
for i in range(1024):
18-
for j in range(2):
18+
for _j in range(2):
1919
con.execute("Insert Into test values ('" + str(i) + "')")
2020
con.execute("Insert Into test values ('5000')")
2121
con.execute("Insert Into test values ('6000')")

tests/fast/arrow/test_arrow_fetch_recordbatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def test_many_chunk_sizes(self):
280280
query = duckdb_cursor.execute("SELECT a FROM t")
281281
record_batch_reader = query.fetch_record_batch(i)
282282
num_loops = int(object_size / i)
283-
for j in range(num_loops):
283+
for _j in range(num_loops):
284284
assert record_batch_reader.schema.names == ["a"]
285285
chunk = record_batch_reader.read_next_batch()
286286
assert len(chunk) == i

tests/fast/arrow/test_arrow_replacement_scan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_arrow_table_replacement_scan(self, duckdb_cursor):
1717

1818
con = duckdb.connect()
1919

20-
for i in range(5):
20+
for _i in range(5):
2121
assert con.execute("select count(*) from userdata_parquet_table").fetchone() == (1000,)
2222
assert con.execute("select count(*) from df").fetchone() == (1000,)
2323

0 commit comments

Comments
 (0)