Skip to content

Enforce ruff/flake8-pie rules (PIE) #9740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion asv_bench/benchmarks/dataset_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ def load(self) -> tuple:
dims=("time",),
fastpath=True,
)
for v in range(0, n_variables)
for v in range(n_variables)
}
attributes = {}

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ ignore = [
"E731",
"UP007",
"PERF20",
"PIE790", # unnecessary pass statement
"RUF001",
"RUF002",
"RUF003",
Expand All @@ -260,6 +261,7 @@ extend-select = [
"TID", # flake8-tidy-imports (absolute imports)
"I", # isort
"PERF", # Perflint
"PIE", # flake8-pie
"PGH", # pygrep-hooks
"RUF",
"UP", # Pyupgrade
Expand Down
6 changes: 3 additions & 3 deletions xarray/plot/facetgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,14 +495,14 @@ def map_plot1d(
if self._single_group:
full = tuple(
{self._single_group: x}
for x in range(0, self.data[self._single_group].size)
for x in range(self.data[self._single_group].size)
)
empty = tuple(None for x in range(self._nrow * self._ncol - len(full)))
name_d = full + empty
else:
rowcols = itertools.product(
range(0, self.data[self._row_var].size),
range(0, self.data[self._col_var].size),
range(self.data[self._row_var].size),
range(self.data[self._col_var].size),
)
name_d = tuple({self._row_var: r, self._col_var: c} for r, c in rowcols)
name_dicts = np.array(name_d).reshape(self._nrow, self._ncol)
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,7 @@ def arrays():
)

return [
da.isel(time=range(0, 18)),
da.isel(time=range(18)),
da.isel(time=range(2, 20)).rolling(time=3, center=True).mean(),
xr.DataArray([[1, 2], [1, np.nan]], dims=["x", "time"]),
xr.DataArray([[1, 2], [np.nan, np.nan]], dims=["x", "time"]),
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def concat_var_names() -> Callable:
def get_varnames(var_cnt: int = 10, list_cnt: int = 10) -> list[list[str]]:
orig = [f"d{i:02d}" for i in range(var_cnt)]
var_names = []
for _i in range(0, list_cnt):
for _i in range(list_cnt):
l1 = orig.copy()
var_names.append(l1)
return var_names
Expand Down
4 changes: 2 additions & 2 deletions xarray/tests/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ def test_groupby_iter(self) -> None:

def test_groupby_properties(self) -> None:
grouped = self.da.groupby("abc")
expected_groups = {"a": range(0, 9), "c": [9], "b": range(10, 20)}
expected_groups = {"a": range(9), "c": [9], "b": range(10, 20)}
assert expected_groups.keys() == grouped.groups.keys()
for key in expected_groups:
expected_group = expected_groups[key]
Expand Down Expand Up @@ -1936,7 +1936,7 @@ def test_resample_bad_resample_dim(self) -> None:
times = pd.date_range("2000-01-01", freq="6h", periods=10)
array = DataArray(np.arange(10), [("__resample_dim__", times)])
with pytest.raises(ValueError, match=r"Proxy resampling dimension"):
array.resample(**{"__resample_dim__": "1D"}).first() # type: ignore[arg-type]
array.resample(__resample_dim__="1D").first()

@requires_scipy
def test_resample_drop_nondim_coords(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_interp.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ def test_decompose(method: InterpOptions) -> None:
(data_ndim, interp_ndim, nscalar)
for data_ndim in range(1, 4)
for interp_ndim in range(1, data_ndim + 1)
for nscalar in range(0, interp_ndim + 1)
for nscalar in range(interp_ndim + 1)
],
)
def test_interpolate_chunk_1d(
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -3934,7 +3934,7 @@ def test_grouped_operations(self, func, variant, dtype, compute_backend):
data_array = xr.DataArray(
data=array, coords={"x": x, "y": y, "u": ("x", u)}, dims=("x", "y")
)
units = {**extract_units(data_array), **{"z": unit_registry.s, "q": None}}
units = {**extract_units(data_array), "z": unit_registry.s, "q": None}

stripped_kwargs = {
key: (
Expand Down
Loading