From c8f7dc635f256178313acd4983db8b265df77040 Mon Sep 17 00:00:00 2001 From: Maximilian Roos <5635139+max-sixty@users.noreply.github.com> Date: Sun, 9 Feb 2025 21:13:49 -0800 Subject: [PATCH] Upgrade mypy to 1.15 (#10041) Seems easy locally; maybe too easy and something will break in CI... --- .github/workflows/ci-additional.yaml | 4 ++-- xarray/core/groupby.py | 6 ++---- xarray/core/indexing.py | 2 +- xarray/core/resample.py | 6 ++---- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci-additional.yaml b/.github/workflows/ci-additional.yaml index e2fa49f2c9d..fef104a1ddc 100644 --- a/.github/workflows/ci-additional.yaml +++ b/.github/workflows/ci-additional.yaml @@ -116,7 +116,7 @@ jobs: python xarray/util/print_versions.py - name: Install mypy run: | - python -m pip install "mypy==1.13" --force-reinstall + python -m pip install "mypy==1.15" --force-reinstall - name: Run mypy run: | @@ -167,7 +167,7 @@ jobs: python xarray/util/print_versions.py - name: Install mypy run: | - python -m pip install "mypy==1.13" --force-reinstall + python -m pip install "mypy==1.15" --force-reinstall - name: Run mypy run: | diff --git a/xarray/core/groupby.py b/xarray/core/groupby.py index ceae79031f8..b28ba390a9f 100644 --- a/xarray/core/groupby.py +++ b/xarray/core/groupby.py @@ -1606,8 +1606,7 @@ def reduce_array(ar: DataArray) -> DataArray: return self.map(reduce_array, shortcut=shortcut) -# https://github.com/python/mypy/issues/9031 -class DataArrayGroupBy( # type: ignore[misc] +class DataArrayGroupBy( DataArrayGroupByBase, DataArrayGroupByAggregations, ImplementsArrayReduce, @@ -1774,8 +1773,7 @@ def assign(self, **kwargs: Any) -> Dataset: return self.map(lambda ds: ds.assign(**kwargs)) -# https://github.com/python/mypy/issues/9031 -class DatasetGroupBy( # type: ignore[misc] +class DatasetGroupBy( DatasetGroupByBase, DatasetGroupByAggregations, ImplementsDatasetReduce, diff --git a/xarray/core/indexing.py b/xarray/core/indexing.py index 51fc4a00421..cf9d3885f08 100644 --- a/xarray/core/indexing.py +++ b/xarray/core/indexing.py @@ -480,7 +480,7 @@ def __init__(self, key: tuple[slice | np.ndarray[Any, np.dtype[np.generic]], ... ) if ndim is None: ndim = k.ndim # type: ignore[union-attr] - elif ndim != k.ndim: + elif ndim != k.ndim: # type: ignore[union-attr] ndims = [k.ndim for k in key if isinstance(k, np.ndarray)] raise ValueError( "invalid indexer key: ndarray arguments " diff --git a/xarray/core/resample.py b/xarray/core/resample.py index 5cc98c9651c..45dea24d992 100644 --- a/xarray/core/resample.py +++ b/xarray/core/resample.py @@ -232,8 +232,7 @@ def _interpolate(self, kind="linear", **kwargs) -> T_Xarray: ) -# https://github.com/python/mypy/issues/9031 -class DataArrayResample( # type: ignore[misc] +class DataArrayResample( Resample["DataArray"], DataArrayGroupByBase, DataArrayResampleAggregations ): """DataArrayGroupBy object specialized to time resampling operations over a @@ -375,8 +374,7 @@ def asfreq(self) -> DataArray: return self.mean(None if self._dim is None else [self._dim]) -# https://github.com/python/mypy/issues/9031 -class DatasetResample( # type: ignore[misc] +class DatasetResample( Resample["Dataset"], DatasetGroupByBase, DatasetResampleAggregations ): """DatasetGroupBy object specialized to resampling a specified dimension"""