From 0fd23267cc756895eabd4e4af4d2a1055ace7ce9 Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Sat, 25 Nov 2023 13:06:29 +0100 Subject: [PATCH 01/19] import from the new location of `normalize_axis_index` if possible --- xarray/core/duck_array_ops.py | 8 +++++++- xarray/core/nputils.py | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/xarray/core/duck_array_ops.py b/xarray/core/duck_array_ops.py index b9f7db9737f..dd31e1895d5 100644 --- a/xarray/core/duck_array_ops.py +++ b/xarray/core/duck_array_ops.py @@ -29,7 +29,6 @@ zeros_like, # noqa ) from numpy import concatenate as _concatenate -from numpy.core.multiarray import normalize_axis_index # type: ignore[attr-defined] from numpy.lib.stride_tricks import sliding_window_view # noqa from xarray.core import dask_array_ops, dtypes, nputils @@ -37,6 +36,13 @@ from xarray.core.pycompat import array_type, is_duck_dask_array from xarray.core.utils import is_duck_array, module_available +# remove once numpy 2.0 is the oldest supported version +try: + from numpy.lib.array_utils import normalize_axis_index +except ImportError: + from numpy.core.multiarray import normalize_axis_index # type: ignore[attr-defined] + + dask_available = module_available("dask") diff --git a/xarray/core/nputils.py b/xarray/core/nputils.py index bd33b7b6d8f..31d47e84c22 100644 --- a/xarray/core/nputils.py +++ b/xarray/core/nputils.py @@ -4,9 +4,14 @@ import numpy as np import pandas as pd -from numpy.core.multiarray import normalize_axis_index # type: ignore[attr-defined] from packaging.version import Version +# remove once numpy 2.0 is the oldest supported version +try: + from numpy.lib.array_utils import normalize_axis_index +except ImportError: + from numpy.core.multiarray import normalize_axis_index # type: ignore[attr-defined] + # remove once numpy 2.0 is the oldest supported version try: from numpy.exceptions import RankWarning # type: ignore[attr-defined,unused-ignore] From f91f96145ceac935d13671a34752cf62d21cb6a9 Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Sat, 25 Nov 2023 14:09:46 +0100 Subject: [PATCH 02/19] disable build isolation for `cftime` [skip-ci] [skip-rtd] --- ci/install-upstream-wheels.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ci/install-upstream-wheels.sh b/ci/install-upstream-wheels.sh index 97ae4c2bbca..17be9cb728b 100755 --- a/ci/install-upstream-wheels.sh +++ b/ci/install-upstream-wheels.sh @@ -31,13 +31,17 @@ python -m pip install \ scipy \ matplotlib \ pandas +# without build isolation for packages compiling against numpy +python -m pip install \ + --no-deps \ + --upgrade \ + git+https://github.com/Unidata/cftime python -m pip install \ --no-deps \ --upgrade \ git+https://github.com/dask/dask \ git+https://github.com/dask/distributed \ git+https://github.com/zarr-developers/zarr \ - git+https://github.com/Unidata/cftime \ git+https://github.com/pypa/packaging \ git+https://github.com/hgrecco/pint \ git+https://github.com/pydata/bottleneck \ From b5b29ede39bbaf179c99822a974a84efd104b89c Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Sat, 25 Nov 2023 14:27:03 +0100 Subject: [PATCH 03/19] actually apply the `--no-build-isolation` [skip-ci] [skip-rtd] --- ci/install-upstream-wheels.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/install-upstream-wheels.sh b/ci/install-upstream-wheels.sh index 17be9cb728b..bd8854d2026 100755 --- a/ci/install-upstream-wheels.sh +++ b/ci/install-upstream-wheels.sh @@ -35,6 +35,7 @@ python -m pip install \ python -m pip install \ --no-deps \ --upgrade \ + --no-build-isolation \ git+https://github.com/Unidata/cftime python -m pip install \ --no-deps \ From 602663633f281e1c3995c0e8d20510d4ce706334 Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Tue, 28 Nov 2023 10:45:18 +0100 Subject: [PATCH 04/19] install `cython`, which is needed to build `cftime` --- ci/install-upstream-wheels.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/install-upstream-wheels.sh b/ci/install-upstream-wheels.sh index bd8854d2026..3fafa818416 100755 --- a/ci/install-upstream-wheels.sh +++ b/ci/install-upstream-wheels.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +# install cython for building cftime without build isolation +micromamba install "cython>=0.29.20" # temporarily (?) remove numbagg and numba pip uninstall -y numbagg conda uninstall -y numba From 2ee48624845104428a34282bde4e6a6d06b61d5f Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Tue, 28 Nov 2023 10:45:50 +0100 Subject: [PATCH 05/19] use `micromamba` instead of `conda` for removing packages --- ci/install-upstream-wheels.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ci/install-upstream-wheels.sh b/ci/install-upstream-wheels.sh index 3fafa818416..b4418250b89 100755 --- a/ci/install-upstream-wheels.sh +++ b/ci/install-upstream-wheels.sh @@ -3,10 +3,9 @@ # install cython for building cftime without build isolation micromamba install "cython>=0.29.20" # temporarily (?) remove numbagg and numba -pip uninstall -y numbagg -conda uninstall -y numba +micromamba remove -y numba numbagg # forcibly remove packages to avoid artifacts -conda uninstall -y --force \ +micromamba remove -y --force \ numpy \ scipy \ pandas \ From 007364f3391e30c9e1c5f51f08226e5e966f8d3c Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Tue, 28 Nov 2023 10:54:41 +0100 Subject: [PATCH 06/19] switch the main uninstall back to `conda` --- ci/install-upstream-wheels.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/install-upstream-wheels.sh b/ci/install-upstream-wheels.sh index b4418250b89..6e291e3980d 100755 --- a/ci/install-upstream-wheels.sh +++ b/ci/install-upstream-wheels.sh @@ -5,7 +5,7 @@ micromamba install "cython>=0.29.20" # temporarily (?) remove numbagg and numba micromamba remove -y numba numbagg # forcibly remove packages to avoid artifacts -micromamba remove -y --force \ +conda uninstall -y --force \ numpy \ scipy \ pandas \ From 1bd59ac0f86a2a021531f7e95edd5116ce629989 Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Wed, 6 Dec 2023 10:16:33 +0100 Subject: [PATCH 07/19] temporarily remove `cf_units`, `h5py`, and `netcdf4` --- ci/install-upstream-wheels.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ci/install-upstream-wheels.sh b/ci/install-upstream-wheels.sh index 6e291e3980d..7c09ffb0f68 100755 --- a/ci/install-upstream-wheels.sh +++ b/ci/install-upstream-wheels.sh @@ -4,6 +4,8 @@ micromamba install "cython>=0.29.20" # temporarily (?) remove numbagg and numba micromamba remove -y numba numbagg +# temporarily remove backends +micromamba remove -y cf_units h5py netcdf4 # forcibly remove packages to avoid artifacts conda uninstall -y --force \ numpy \ @@ -51,5 +53,5 @@ python -m pip install \ git+https://github.com/intake/filesystem_spec \ git+https://github.com/SciTools/nc-time-axis \ git+https://github.com/xarray-contrib/flox \ - git+https://github.com/h5netcdf/h5netcdf \ git+https://github.com/dgasmith/opt_einsum + # git+https://github.com/h5netcdf/h5netcdf From e94e748d6471c00a3e6d25aeb3fce55d122c35a1 Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Wed, 6 Dec 2023 10:21:15 +0100 Subject: [PATCH 08/19] also remove `hdf5` [skip-ci] --- ci/install-upstream-wheels.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/install-upstream-wheels.sh b/ci/install-upstream-wheels.sh index 7c09ffb0f68..3aa813d7ff3 100755 --- a/ci/install-upstream-wheels.sh +++ b/ci/install-upstream-wheels.sh @@ -5,7 +5,7 @@ micromamba install "cython>=0.29.20" # temporarily (?) remove numbagg and numba micromamba remove -y numba numbagg # temporarily remove backends -micromamba remove -y cf_units h5py netcdf4 +micromamba remove -y cf_units h5py hdf5 netcdf4 # forcibly remove packages to avoid artifacts conda uninstall -y --force \ numpy \ From 953994a99dd16bedc650360f8c6b9266b469aecb Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Wed, 6 Dec 2023 17:23:46 +0100 Subject: [PATCH 09/19] try building `numcodecs` from github and without build isolation --- ci/install-upstream-wheels.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci/install-upstream-wheels.sh b/ci/install-upstream-wheels.sh index 3aa813d7ff3..ddb105446fc 100755 --- a/ci/install-upstream-wheels.sh +++ b/ci/install-upstream-wheels.sh @@ -23,6 +23,7 @@ conda uninstall -y --force \ sparse \ flox \ h5netcdf \ + numcodecs \ xarray # to limit the runtime of Upstream CI python -m pip install \ @@ -35,10 +36,12 @@ python -m pip install \ matplotlib \ pandas # without build isolation for packages compiling against numpy +# TODO: remove once there are `numpy>=2.0` builds for numcodecs and cftime python -m pip install \ --no-deps \ --upgrade \ --no-build-isolation \ + git+https://github.com/zarr-developers/numcodecs \ git+https://github.com/Unidata/cftime python -m pip install \ --no-deps \ From 4313391ba9bedce933fc9fd234cc4ad044d3cda8 Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Sat, 30 Dec 2023 14:25:37 +0100 Subject: [PATCH 10/19] build `cftime` separately from `numcodecs` and install more deps [skip-ci] --- ci/install-upstream-wheels.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ci/install-upstream-wheels.sh b/ci/install-upstream-wheels.sh index ddb105446fc..a67428f3eed 100755 --- a/ci/install-upstream-wheels.sh +++ b/ci/install-upstream-wheels.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # install cython for building cftime without build isolation -micromamba install "cython>=0.29.20" +micromamba install "cython>=0.29.20" py-cpuinfo # temporarily (?) remove numbagg and numba micromamba remove -y numba numbagg # temporarily remove backends @@ -41,7 +41,11 @@ python -m pip install \ --no-deps \ --upgrade \ --no-build-isolation \ - git+https://github.com/zarr-developers/numcodecs \ + git+https://github.com/zarr-developers/numcodecs +python -m pip install \ + --no-deps \ + --upgrade \ + --no-build-isolation \ git+https://github.com/Unidata/cftime python -m pip install \ --no-deps \ From b87e8c82b79bfbabb3b225bb08a4bd7e26b6a5d1 Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Sat, 30 Dec 2023 14:40:48 +0100 Subject: [PATCH 11/19] don't uninstall packages that are already removed [skip-ci] --- ci/install-upstream-wheels.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ci/install-upstream-wheels.sh b/ci/install-upstream-wheels.sh index a67428f3eed..1791514f3e9 100755 --- a/ci/install-upstream-wheels.sh +++ b/ci/install-upstream-wheels.sh @@ -11,8 +11,6 @@ conda uninstall -y --force \ numpy \ scipy \ pandas \ - matplotlib \ - dask \ distributed \ fsspec \ zarr \ @@ -20,11 +18,8 @@ conda uninstall -y --force \ packaging \ pint \ bottleneck \ - sparse \ flox \ - h5netcdf \ - numcodecs \ - xarray + numcodecs # to limit the runtime of Upstream CI python -m pip install \ -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple \ From 6410d7145e5f3adf200c55351b9735335ee03480 Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Sat, 30 Dec 2023 14:59:11 +0100 Subject: [PATCH 12/19] also build `bottleneck` without build isolation --- ci/install-upstream-wheels.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ci/install-upstream-wheels.sh b/ci/install-upstream-wheels.sh index 1791514f3e9..b1db58b7d03 100755 --- a/ci/install-upstream-wheels.sh +++ b/ci/install-upstream-wheels.sh @@ -32,6 +32,11 @@ python -m pip install \ pandas # without build isolation for packages compiling against numpy # TODO: remove once there are `numpy>=2.0` builds for numcodecs and cftime +python -m pip install \ + --no-deps \ + --upgrade \ + --no-build-isolation \ + git+https://github.com/Unidata/cftime python -m pip install \ --no-deps \ --upgrade \ @@ -41,7 +46,7 @@ python -m pip install \ --no-deps \ --upgrade \ --no-build-isolation \ - git+https://github.com/Unidata/cftime + git+https://github.com/pydata/bottleneck python -m pip install \ --no-deps \ --upgrade \ @@ -50,7 +55,6 @@ python -m pip install \ git+https://github.com/zarr-developers/zarr \ git+https://github.com/pypa/packaging \ git+https://github.com/hgrecco/pint \ - git+https://github.com/pydata/bottleneck \ git+https://github.com/pydata/sparse \ git+https://github.com/intake/filesystem_spec \ git+https://github.com/SciTools/nc-time-axis \ From b4e126db630c59b9b6031d64bc5f5c8105f62d88 Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Fri, 12 Jan 2024 12:01:12 +0100 Subject: [PATCH 13/19] use `module_available` instead of eagerly importing --- xarray/core/duck_array_ops.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xarray/core/duck_array_ops.py b/xarray/core/duck_array_ops.py index ccd66eb8aef..2f5b3eae250 100644 --- a/xarray/core/duck_array_ops.py +++ b/xarray/core/duck_array_ops.py @@ -39,9 +39,9 @@ from xarray.core.utils import is_duck_array, module_available # remove once numpy 2.0 is the oldest supported version -try: +if module_available("numpy", minversion="2.0.0.dev0"): from numpy.lib.array_utils import normalize_axis_index -except ImportError: +else: from numpy.core.multiarray import normalize_axis_index # type: ignore[attr-defined] From be6918e815a4616cabb6384836c5d65e2dc92aac Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Fri, 12 Jan 2024 12:29:25 +0100 Subject: [PATCH 14/19] add a `minversion` kwarg to `module_available` --- xarray/core/utils.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/xarray/core/utils.py b/xarray/core/utils.py index 00c84d4c10c..7039a3f5209 100644 --- a/xarray/core/utils.py +++ b/xarray/core/utils.py @@ -74,6 +74,7 @@ import numpy as np import pandas as pd +from packaging.version import Version if TYPE_CHECKING: from xarray.core.types import Dims, ErrorOptionsWithWarn, OrderedDims, T_DuckArray @@ -1198,7 +1199,7 @@ def contains_only_chunked_or_numpy(obj) -> bool: ) -def module_available(module: str) -> bool: +def module_available(module: str, minversion: str | None = None) -> bool: """Checks whether a module is installed without importing it. Use this for a lightweight check and lazy imports. @@ -1207,13 +1208,23 @@ def module_available(module: str) -> bool: ---------- module : str Name of the module. + minversion : str, optional + Minimum version of the module Returns ------- available : bool Whether the module is installed. """ - return importlib.util.find_spec(module) is not None + if importlib.util.find_spec(module) is None: + return False + + if minversion is not None: + version = importlib.metadata.version(module) + + return Version(version) >= Version(minversion) + + return True def find_stack_level(test_mode=False) -> int: From c54b7fa73ab2b8fb6b2ae30c0a7414970b729727 Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Fri, 12 Jan 2024 14:10:21 +0100 Subject: [PATCH 15/19] use `module_available` in `nputils` as well --- xarray/core/nputils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xarray/core/nputils.py b/xarray/core/nputils.py index 488409a0df4..ca011de7778 100644 --- a/xarray/core/nputils.py +++ b/xarray/core/nputils.py @@ -11,9 +11,9 @@ from xarray.core.utils import module_available # remove once numpy 2.0 is the oldest supported version -try: +if module_available("numpy", minversion="2.0.0.dev0"): from numpy.lib.array_utils import normalize_axis_index -except ImportError: +else: from numpy.core.multiarray import normalize_axis_index # type: ignore[attr-defined] # remove once numpy 2.0 is the oldest supported version From 6f17983ab56a78fa74de5b57365542f6d50b4a8c Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Thu, 18 Jan 2024 11:27:40 +0100 Subject: [PATCH 16/19] more type ignores --- xarray/core/duck_array_ops.py | 8 ++++++-- xarray/core/nputils.py | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/xarray/core/duck_array_ops.py b/xarray/core/duck_array_ops.py index 2f5b3eae250..8831b9f2cea 100644 --- a/xarray/core/duck_array_ops.py +++ b/xarray/core/duck_array_ops.py @@ -40,9 +40,13 @@ # remove once numpy 2.0 is the oldest supported version if module_available("numpy", minversion="2.0.0.dev0"): - from numpy.lib.array_utils import normalize_axis_index + from numpy.lib.array_utils import ( + normalize_axis_index, # type: ignore[import-not-found] + ) else: - from numpy.core.multiarray import normalize_axis_index # type: ignore[attr-defined] + from numpy.core.multiarray import ( + normalize_axis_index, # type: ignore[attr-defined,no-redef] + ) dask_available = module_available("dask") diff --git a/xarray/core/nputils.py b/xarray/core/nputils.py index ca011de7778..5b8d5242df0 100644 --- a/xarray/core/nputils.py +++ b/xarray/core/nputils.py @@ -12,9 +12,13 @@ # remove once numpy 2.0 is the oldest supported version if module_available("numpy", minversion="2.0.0.dev0"): - from numpy.lib.array_utils import normalize_axis_index + from numpy.lib.array_utils import ( + normalize_axis_index, # type: ignore[import-not-found] + ) else: - from numpy.core.multiarray import normalize_axis_index # type: ignore[attr-defined] + from numpy.core.multiarray import ( + normalize_axis_index, # type: ignore[attr-defined,no-redef] + ) # remove once numpy 2.0 is the oldest supported version try: From edf069a7ead5369b47b544483d3353d54e98cdd4 Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Thu, 18 Jan 2024 12:21:30 +0100 Subject: [PATCH 17/19] move the type ignores to the import --- xarray/core/duck_array_ops.py | 8 ++++---- xarray/core/nputils.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/xarray/core/duck_array_ops.py b/xarray/core/duck_array_ops.py index 8831b9f2cea..927400a7a23 100644 --- a/xarray/core/duck_array_ops.py +++ b/xarray/core/duck_array_ops.py @@ -40,12 +40,12 @@ # remove once numpy 2.0 is the oldest supported version if module_available("numpy", minversion="2.0.0.dev0"): - from numpy.lib.array_utils import ( - normalize_axis_index, # type: ignore[import-not-found] + from numpy.lib.array_utils import ( # type: ignore[import-not-found] + normalize_axis_index, ) else: - from numpy.core.multiarray import ( - normalize_axis_index, # type: ignore[attr-defined,no-redef] + from numpy.core.multiarray import ( # type: ignore[attr-defined,no-redef] + normalize_axis_index, ) diff --git a/xarray/core/nputils.py b/xarray/core/nputils.py index 5b8d5242df0..b24846c9448 100644 --- a/xarray/core/nputils.py +++ b/xarray/core/nputils.py @@ -12,12 +12,12 @@ # remove once numpy 2.0 is the oldest supported version if module_available("numpy", minversion="2.0.0.dev0"): - from numpy.lib.array_utils import ( - normalize_axis_index, # type: ignore[import-not-found] + from numpy.lib.array_utils import ( # type: ignore[import-not-found] + normalize_axis_index, ) else: - from numpy.core.multiarray import ( - normalize_axis_index, # type: ignore[attr-defined,no-redef] + from numpy.core.multiarray import ( # type: ignore[attr-defined,no-redef] + normalize_axis_index, ) # remove once numpy 2.0 is the oldest supported version From 77f4bf4d005c44c05df0ef1907013f28731e45d5 Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Thu, 18 Jan 2024 12:50:38 +0100 Subject: [PATCH 18/19] ignore complaints about unused ignores (the point here is compatibility between multiple versions) --- xarray/core/duck_array_ops.py | 2 +- xarray/core/nputils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xarray/core/duck_array_ops.py b/xarray/core/duck_array_ops.py index 927400a7a23..bf6efd3268d 100644 --- a/xarray/core/duck_array_ops.py +++ b/xarray/core/duck_array_ops.py @@ -44,7 +44,7 @@ normalize_axis_index, ) else: - from numpy.core.multiarray import ( # type: ignore[attr-defined,no-redef] + from numpy.core.multiarray import ( # type: ignore[attr-defined,no-redef,unused-ignore] normalize_axis_index, ) diff --git a/xarray/core/nputils.py b/xarray/core/nputils.py index b24846c9448..43f965dafb1 100644 --- a/xarray/core/nputils.py +++ b/xarray/core/nputils.py @@ -16,7 +16,7 @@ normalize_axis_index, ) else: - from numpy.core.multiarray import ( # type: ignore[attr-defined,no-redef] + from numpy.core.multiarray import ( # type: ignore[attr-defined,no-redef,unused-ignore] normalize_axis_index, ) @@ -24,7 +24,7 @@ try: from numpy.exceptions import RankWarning # type: ignore[attr-defined,unused-ignore] except ImportError: - from numpy import RankWarning + from numpy import RankWarning # type: ignore[no-redef,unused-ignore] from xarray.core.options import OPTIONS from xarray.core.pycompat import is_duck_array From 6a762fd7a0719b90db616dd35a658401a2a4399a Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Thu, 18 Jan 2024 14:33:59 +0100 Subject: [PATCH 19/19] a couple of other `type: ignore` comments (only relevant for nightly) --- xarray/core/duck_array_ops.py | 2 +- xarray/core/nputils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xarray/core/duck_array_ops.py b/xarray/core/duck_array_ops.py index bf6efd3268d..af5c415cdce 100644 --- a/xarray/core/duck_array_ops.py +++ b/xarray/core/duck_array_ops.py @@ -40,7 +40,7 @@ # remove once numpy 2.0 is the oldest supported version if module_available("numpy", minversion="2.0.0.dev0"): - from numpy.lib.array_utils import ( # type: ignore[import-not-found] + from numpy.lib.array_utils import ( # type: ignore[import-not-found,unused-ignore] normalize_axis_index, ) else: diff --git a/xarray/core/nputils.py b/xarray/core/nputils.py index 43f965dafb1..ff54bccd3d2 100644 --- a/xarray/core/nputils.py +++ b/xarray/core/nputils.py @@ -12,7 +12,7 @@ # remove once numpy 2.0 is the oldest supported version if module_available("numpy", minversion="2.0.0.dev0"): - from numpy.lib.array_utils import ( # type: ignore[import-not-found] + from numpy.lib.array_utils import ( # type: ignore[import-not-found,unused-ignore] normalize_axis_index, ) else: @@ -24,7 +24,7 @@ try: from numpy.exceptions import RankWarning # type: ignore[attr-defined,unused-ignore] except ImportError: - from numpy import RankWarning # type: ignore[no-redef,unused-ignore] + from numpy import RankWarning # type: ignore[attr-defined,no-redef,unused-ignore] from xarray.core.options import OPTIONS from xarray.core.pycompat import is_duck_array