Skip to content

Commit

Permalink
[flake8] Enable flake8-bugbear extension (#4073)
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Jul 19, 2022
1 parent 2b52779 commit cf82cf3
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 20 deletions.
1 change: 1 addition & 0 deletions py-polars/build.requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ isort~=5.10.1
mypy==0.961
ghp-import==2.1.0
flake8==4.0.1
flake8-bugbear==22.7.1
sphinx==4.2.0
pydata-sphinx-theme==0.6.3
sphinx-panels==0.6.0
Expand Down
6 changes: 3 additions & 3 deletions py-polars/polars/internals/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4053,8 +4053,8 @@ def drop(self: DF, name: str | list[str]) -> DF:
if isinstance(name, list):
df = self.clone()

for name in name:
df._df.drop_in_place(name)
for n in name:
df._df.drop_in_place(n)
return df

return self._from_pydf(self._df.drop(name))
Expand Down Expand Up @@ -4192,7 +4192,7 @@ def clone(self: DF) -> DF:
def __copy__(self: DF) -> DF:
return self.clone()

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

def get_columns(self) -> list[pli.Series]:
Expand Down
2 changes: 1 addition & 1 deletion py-polars/polars/internals/lazy_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ def clone(self: LDF) -> LDF:
def __copy__(self: LDF) -> LDF:
return self.clone()

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

def filter(self: LDF, predicate: pli.Expr | str) -> LDF:
Expand Down
2 changes: 1 addition & 1 deletion py-polars/polars/internals/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2433,7 +2433,7 @@ def clone(self) -> "Series":
def __copy__(self) -> Series:
return self.clone()

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

def fill_nan(self, fill_value: str | int | float | bool | pli.Expr) -> Series:
Expand Down
2 changes: 1 addition & 1 deletion py-polars/polars/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def between(draw: Callable, type_: type, min_: Any, max_: Any) -> Any:
"""
Draw a value in a given range from a type-inferred strategy.
"""
strategy_init = getattr(from_type(type_), "function")
strategy_init = from_type(type_).function # type: ignore[attr-defined]
return draw(strategy_init(min_, max_))

@dataclass
Expand Down
2 changes: 1 addition & 1 deletion py-polars/tests/db-benchmark/various.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_windows_not_cached() -> None:
)
)
# this might fail if they are cached
for i in range(1000):
for _ in range(1000):
ldf.collect()


Expand Down
2 changes: 1 addition & 1 deletion py-polars/tests/test_df.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_init_only_columns() -> None:
assert df.shape == (0, 4)
assert df.frame_equal(truth, null_equal=True)
assert df.dtypes == [pl.Date, pl.UInt64, pl.Int8, pl.List]
assert getattr(df.schema["d"], "inner") == pl.UInt8
assert df.schema["d"].inner == pl.UInt8 # type: ignore[attr-defined]

dfe = df.cleared()
assert (df.schema == dfe.schema) and (dfe.shape == df.shape)
Expand Down
4 changes: 2 additions & 2 deletions py-polars/tests/test_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_dtype() -> None:
a = pl.Series("a", [[1, 2, 3], [2, 5], [6, 7, 8, 9]])
assert a.dtype == pl.List
assert a.inner_dtype == pl.Int64
assert getattr(a.dtype, "inner") == pl.Int64
assert a.dtype.inner == pl.Int64 # type: ignore[attr-defined]

# explicit
df = pl.DataFrame(
Expand All @@ -84,7 +84,7 @@ def test_dtype() -> None:
"dt": pl.List(pl.Date),
"dtm": pl.List(pl.Datetime),
}
assert getattr(df.schema["i"], "inner") == pl.Int8
assert df.schema["i"].inner == pl.Int8 # type: ignore[attr-defined]
assert df.rows() == [
(
[1, 2, 3],
Expand Down
4 changes: 2 additions & 2 deletions py-polars/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1054,11 +1054,11 @@ def test_comparisons_bool_series_to_int() -> None:
with pytest.raises(
TypeError, match=r"'<' not supported between instances of 'Series' and 'int'"
):
srs_bool < 2
srs_bool < 2 # noqa: B015
with pytest.raises(
TypeError, match=r"'>' not supported between instances of 'Series' and 'int'"
):
srs_bool > 2
srs_bool > 2 # noqa: B015


def test_trigonometry_functions() -> None:
Expand Down
13 changes: 5 additions & 8 deletions py-polars/tests/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,11 @@ def test_no_panic_on_nan_3067() -> None:
}
)

df.select([pl.col("total").shift().over("group")])["total"].to_list() == [
None,
1.0,
2.0,
None,
4.0,
5.0,
]
expected = [None, 1.0, 2.0, None, 4.0, 5.0]
assert (
df.select([pl.col("total").shift().over("group")])["total"].to_list()
== expected
)


def test_quantile_as_window() -> None:
Expand Down

0 comments on commit cf82cf3

Please sign in to comment.