Skip to content

Commit 4c61381

Browse files
committed
Handle flake8-bugbear errors
1 parent 686353a commit 4c61381

File tree

9 files changed

+17
-20
lines changed

9 files changed

+17
-20
lines changed

py-polars/polars/internals/frame.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4053,8 +4053,8 @@ def drop(self: DF, name: str | list[str]) -> DF:
40534053
if isinstance(name, list):
40544054
df = self.clone()
40554055

4056-
for name in name:
4057-
df._df.drop_in_place(name)
4056+
for n in name:
4057+
df._df.drop_in_place(n)
40584058
return df
40594059

40604060
return self._from_pydf(self._df.drop(name))
@@ -4192,7 +4192,7 @@ def clone(self: DF) -> DF:
41924192
def __copy__(self: DF) -> DF:
41934193
return self.clone()
41944194

4195-
def __deepcopy__(self: DF, memodict: dict = {}) -> DF:
4195+
def __deepcopy__(self: DF, memo: None = None) -> DF:
41964196
return self.clone()
41974197

41984198
def get_columns(self) -> list[pli.Series]:

py-polars/polars/internals/lazy_frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ def clone(self: LDF) -> LDF:
809809
def __copy__(self: LDF) -> LDF:
810810
return self.clone()
811811

812-
def __deepcopy__(self: LDF, memodict: dict = {}) -> LDF:
812+
def __deepcopy__(self: LDF, memo: None = None) -> LDF:
813813
return self.clone()
814814

815815
def filter(self: LDF, predicate: pli.Expr | str) -> LDF:

py-polars/polars/internals/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2433,7 +2433,7 @@ def clone(self) -> "Series":
24332433
def __copy__(self) -> Series:
24342434
return self.clone()
24352435

2436-
def __deepcopy__(self, memodict: Any = {}) -> Series:
2436+
def __deepcopy__(self, memo: None = None) -> Series:
24372437
return self.clone()
24382438

24392439
def fill_nan(self, fill_value: str | int | float | bool | pli.Expr) -> Series:

py-polars/polars/testing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def between(draw: Callable, type_: type, min_: Any, max_: Any) -> Any:
357357
"""
358358
Draw a value in a given range from a type-inferred strategy.
359359
"""
360-
strategy_init = getattr(from_type(type_), "function")
360+
strategy_init = from_type(type_).function # type: ignore[attr-defined]
361361
return draw(strategy_init(min_, max_))
362362

363363
@dataclass

py-polars/tests/db-benchmark/various.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_windows_not_cached() -> None:
7070
)
7171
)
7272
# this might fail if they are cached
73-
for i in range(1000):
73+
for _ in range(1000):
7474
ldf.collect()
7575

7676

py-polars/tests/test_df.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_init_only_columns() -> None:
6464
assert df.shape == (0, 4)
6565
assert df.frame_equal(truth, null_equal=True)
6666
assert df.dtypes == [pl.Date, pl.UInt64, pl.Int8, pl.List]
67-
assert getattr(df.schema["d"], "inner") == pl.UInt8
67+
assert df.schema["d"].inner == pl.UInt8 # type: ignore[attr-defined]
6868

6969
dfe = df.cleared()
7070
assert (df.schema == dfe.schema) and (dfe.shape == df.shape)

py-polars/tests/test_lists.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_dtype() -> None:
6161
a = pl.Series("a", [[1, 2, 3], [2, 5], [6, 7, 8, 9]])
6262
assert a.dtype == pl.List
6363
assert a.inner_dtype == pl.Int64
64-
assert getattr(a.dtype, "inner") == pl.Int64
64+
assert a.dtype.inner == pl.Int64 # type: ignore[attr-defined]
6565

6666
# explicit
6767
df = pl.DataFrame(
@@ -84,7 +84,7 @@ def test_dtype() -> None:
8484
"dt": pl.List(pl.Date),
8585
"dtm": pl.List(pl.Datetime),
8686
}
87-
assert getattr(df.schema["i"], "inner") == pl.Int8
87+
assert df.schema["i"].inner == pl.Int8 # type: ignore[attr-defined]
8888
assert df.rows() == [
8989
(
9090
[1, 2, 3],

py-polars/tests/test_series.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1054,11 +1054,11 @@ def test_comparisons_bool_series_to_int() -> None:
10541054
with pytest.raises(
10551055
TypeError, match=r"'<' not supported between instances of 'Series' and 'int'"
10561056
):
1057-
srs_bool < 2
1057+
srs_bool < 2 # noqa: B015
10581058
with pytest.raises(
10591059
TypeError, match=r"'>' not supported between instances of 'Series' and 'int'"
10601060
):
1061-
srs_bool > 2
1061+
srs_bool > 2 # noqa: B015
10621062

10631063

10641064
def test_trigonometry_functions() -> None:

py-polars/tests/test_window.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,11 @@ def test_no_panic_on_nan_3067() -> None:
116116
}
117117
)
118118

119-
df.select([pl.col("total").shift().over("group")])["total"].to_list() == [
120-
None,
121-
1.0,
122-
2.0,
123-
None,
124-
4.0,
125-
5.0,
126-
]
119+
expected = [None, 1.0, 2.0, None, 4.0, 5.0]
120+
assert (
121+
df.select([pl.col("total").shift().over("group")])["total"].to_list()
122+
== expected
123+
)
127124

128125

129126
def test_quantile_as_window() -> None:

0 commit comments

Comments
 (0)