Skip to content
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

Enforce ruff/pygrep-hooks rules (PGH) #9729

Merged
merged 3 commits into from
Nov 6, 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/groupby.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# import flox to avoid the cost of first import
import cftime
import flox.xarray # noqa
import flox.xarray # noqa: F401
import numpy as np
import pandas as pd

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ extend-select = [
"W",
"TID", # flake8-tidy-imports (absolute imports)
"I", # isort
"PGH", # pygrep-hooks
"UP", # Pyupgrade
]

Expand Down
8 changes: 4 additions & 4 deletions xarray/core/duck_array_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

import numpy as np
import pandas as pd
from numpy import all as array_all # noqa
from numpy import any as array_any # noqa
from numpy import all as array_all # noqa: F401
from numpy import any as array_any # noqa: F401
from numpy import concatenate as _concatenate
from numpy import ( # noqa
from numpy import ( # noqa: F401
full_like,
gradient,
isclose,
Expand All @@ -30,7 +30,7 @@
transpose,
unravel_index,
)
from numpy.lib.stride_tricks import sliding_window_view # noqa
from numpy.lib.stride_tricks import sliding_window_view # noqa: F401
from packaging.version import Version
from pandas.api.types import is_extension_array_dtype

Expand Down
4 changes: 2 additions & 2 deletions xarray/tests/test_datatree.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def test_create_full_tree(self, simple_datatree) -> None:
class TestNames:
def test_child_gets_named_on_attach(self) -> None:
sue = DataTree()
mary = DataTree(children={"Sue": sue}) # noqa
mary = DataTree(children={"Sue": sue})
assert mary.children["Sue"].name == "Sue"

def test_dataset_containing_slashes(self) -> None:
Expand Down Expand Up @@ -515,7 +515,7 @@ def test_setitem_new_grandchild_node(self) -> None:
def test_grafted_subtree_retains_name(self) -> None:
subtree = DataTree(name="original_subtree_name")
root = DataTree(name="root")
root["new_subtree_name"] = subtree # noqa
root["new_subtree_name"] = subtree
assert subtree.name == "original_subtree_name"

def test_setitem_new_empty_node(self) -> None:
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 @@ -5638,7 +5638,7 @@ def test_duck_array_ops(self):

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


@requires_matplotlib
Expand Down
10 changes: 5 additions & 5 deletions xarray/tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ def _check_netcdf_engine_installed(name):
version = file_formats.get(name)
if version == 3:
try:
import scipy # noqa
import scipy # noqa: F401
except ImportError:
try:
import netCDF4 # noqa
import netCDF4 # noqa: F401
except ImportError as err:
raise ImportError(
f"opening tutorial dataset {name} requires either scipy or "
"netCDF4 to be installed."
) from err
if version == 4:
try:
import h5netcdf # noqa
import h5netcdf # noqa: F401
except ImportError:
try:
import netCDF4 # noqa
import netCDF4 # noqa: F401
except ImportError as err:
raise ImportError(
f"opening tutorial dataset {name} requires either h5netcdf "
Expand Down Expand Up @@ -149,7 +149,7 @@ def open_dataset(
if engine is None:
engine = "cfgrib"
try:
import cfgrib # noqa
import cfgrib # noqa: F401
except ImportError as e:
raise ImportError(
"Reading this tutorial dataset requires the cfgrib package."
Expand Down
Loading