Skip to content

Commit ff41525

Browse files
Enforce ruff/pygrep-hooks rules (PGH) (#9729)
* Apply ruff/pygrep-hooks rule PGH004 PGH004 Use specific rule codes when using `noqa` * Enforce ruff/pygrep-hooks rules (PGH) --------- Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com>
1 parent adc2ae3 commit ff41525

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

asv_bench/benchmarks/groupby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# import flox to avoid the cost of first import
22
import cftime
3-
import flox.xarray # noqa
3+
import flox.xarray # noqa: F401
44
import numpy as np
55
import pandas as pd
66

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ extend-select = [
253253
"W",
254254
"TID", # flake8-tidy-imports (absolute imports)
255255
"I", # isort
256+
"PGH", # pygrep-hooks
256257
"UP", # Pyupgrade
257258
]
258259

xarray/core/duck_array_ops.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
import numpy as np
1818
import pandas as pd
19-
from numpy import all as array_all # noqa
20-
from numpy import any as array_any # noqa
19+
from numpy import all as array_all # noqa: F401
20+
from numpy import any as array_any # noqa: F401
2121
from numpy import concatenate as _concatenate
22-
from numpy import ( # noqa
22+
from numpy import ( # noqa: F401
2323
full_like,
2424
gradient,
2525
isclose,
@@ -30,7 +30,7 @@
3030
transpose,
3131
unravel_index,
3232
)
33-
from numpy.lib.stride_tricks import sliding_window_view # noqa
33+
from numpy.lib.stride_tricks import sliding_window_view # noqa: F401
3434
from packaging.version import Version
3535
from pandas.api.types import is_extension_array_dtype
3636

xarray/tests/test_datatree.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def test_create_full_tree(self, simple_datatree) -> None:
119119
class TestNames:
120120
def test_child_gets_named_on_attach(self) -> None:
121121
sue = DataTree()
122-
mary = DataTree(children={"Sue": sue}) # noqa
122+
mary = DataTree(children={"Sue": sue})
123123
assert mary.children["Sue"].name == "Sue"
124124

125125
def test_dataset_containing_slashes(self) -> None:
@@ -515,7 +515,7 @@ def test_setitem_new_grandchild_node(self) -> None:
515515
def test_grafted_subtree_retains_name(self) -> None:
516516
subtree = DataTree(name="original_subtree_name")
517517
root = DataTree(name="root")
518-
root["new_subtree_name"] = subtree # noqa
518+
root["new_subtree_name"] = subtree
519519
assert subtree.name == "original_subtree_name"
520520

521521
def test_setitem_new_empty_node(self) -> None:

xarray/tests/test_units.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5638,7 +5638,7 @@ def test_duck_array_ops(self):
56385638

56395639
assert_units_equal(expected, actual)
56405640
# Don't use isinstance b/c we don't want to allow subclasses through
5641-
assert type(expected.data) == type(actual.data) # noqa
5641+
assert type(expected.data) == type(actual.data) # noqa: E721
56425642

56435643

56445644
@requires_matplotlib

xarray/tutorial.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,21 @@ def _check_netcdf_engine_installed(name):
5656
version = file_formats.get(name)
5757
if version == 3:
5858
try:
59-
import scipy # noqa
59+
import scipy # noqa: F401
6060
except ImportError:
6161
try:
62-
import netCDF4 # noqa
62+
import netCDF4 # noqa: F401
6363
except ImportError as err:
6464
raise ImportError(
6565
f"opening tutorial dataset {name} requires either scipy or "
6666
"netCDF4 to be installed."
6767
) from err
6868
if version == 4:
6969
try:
70-
import h5netcdf # noqa
70+
import h5netcdf # noqa: F401
7171
except ImportError:
7272
try:
73-
import netCDF4 # noqa
73+
import netCDF4 # noqa: F401
7474
except ImportError as err:
7575
raise ImportError(
7676
f"opening tutorial dataset {name} requires either h5netcdf "
@@ -149,7 +149,7 @@ def open_dataset(
149149
if engine is None:
150150
engine = "cfgrib"
151151
try:
152-
import cfgrib # noqa
152+
import cfgrib # noqa: F401
153153
except ImportError as e:
154154
raise ImportError(
155155
"Reading this tutorial dataset requires the cfgrib package."

0 commit comments

Comments
 (0)