From abd2068bca8da1e1069790bb47d97b8843260d60 Mon Sep 17 00:00:00 2001 From: Michael Niklas Date: Fri, 1 Dec 2023 23:02:20 +0100 Subject: [PATCH] Update to mypy1.7 (#8501) * fix mypy1.7 errors * pin mypy to <1.8 * add entry to whats-new --- .github/workflows/ci-additional.yaml | 4 ++-- doc/whats-new.rst | 2 ++ xarray/core/alignment.py | 4 ++-- xarray/core/dataset.py | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-additional.yaml b/.github/workflows/ci-additional.yaml index 43f13f03133..cd6edcf7b3a 100644 --- a/.github/workflows/ci-additional.yaml +++ b/.github/workflows/ci-additional.yaml @@ -117,7 +117,7 @@ jobs: python xarray/util/print_versions.py - name: Install mypy run: | - python -m pip install "mypy<1.7" --force-reinstall + python -m pip install "mypy<1.8" --force-reinstall - name: Run mypy run: | @@ -171,7 +171,7 @@ jobs: python xarray/util/print_versions.py - name: Install mypy run: | - python -m pip install "mypy<1.7" --force-reinstall + python -m pip install "mypy<1.8" --force-reinstall - name: Run mypy run: | diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 817ea2c8235..14869b3a1ea 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -79,6 +79,8 @@ Internal Changes - :py:meth:`DataArray.bfill` & :py:meth:`DataArray.ffill` now use numbagg by default, which is up to 5x faster where parallelization is possible. (:pull:`8339`) By `Maximilian Roos `_. +- Update mypy version to 1.7 (:issue:`8448`, :pull:`8501`). + By `Michael Niklas `_. .. _whats-new.2023.11.0: diff --git a/xarray/core/alignment.py b/xarray/core/alignment.py index 041fe63a9f3..28857c2d26e 100644 --- a/xarray/core/alignment.py +++ b/xarray/core/alignment.py @@ -681,7 +681,7 @@ def align( ... -def align( # type: ignore[misc] +def align( *objects: T_Alignable, join: JoinOptions = "inner", copy: bool = True, @@ -1153,7 +1153,7 @@ def broadcast( ... -def broadcast( # type: ignore[misc] +def broadcast( *args: T_Alignable, exclude: str | Iterable[Hashable] | None = None ) -> tuple[T_Alignable, ...]: """Explicitly broadcast any number of DataArray or Dataset objects against diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index c65bbd6b849..5d19265e56d 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -7979,8 +7979,8 @@ def sortby( variables = variables arrays = [v if isinstance(v, DataArray) else self[v] for v in variables] aligned_vars = align(self, *arrays, join="left") - aligned_self = aligned_vars[0] - aligned_other_vars: tuple[DataArray, ...] = aligned_vars[1:] + aligned_self = cast("Self", aligned_vars[0]) + aligned_other_vars = cast(tuple[DataArray, ...], aligned_vars[1:]) vars_by_dim = defaultdict(list) for data_array in aligned_other_vars: if data_array.ndim != 1: