From 3376f50875b4bf02238780db454441f67149ca8a Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Sun, 28 Apr 2024 12:45:26 +0200 Subject: [PATCH] TYP: update supported Mypy version from 1.0.0 to 1.10.0 [skip cirrus] [skip circle] --- .github/workflows/linux.yml | 2 +- pyproject.toml | 2 +- requirements/dev.txt | 2 +- scipy/_lib/_testutils.py | 4 ++-- scipy/conftest.py | 4 ++-- scipy/optimize/_milp.py | 2 +- scipy/spatial/_ckdtree.pyi | 16 ++++++++-------- scipy/special/_orthogonal.pyi | 2 +- scipy/special/_support_alternative_backends.py | 2 +- scipy/stats/_qmc.py | 6 +++--- scipy/stats/_unuran/unuran_wrapper.pyi | 12 ++++++------ 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 80150126c180..1096e7f06e4f 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -118,7 +118,7 @@ jobs: if: matrix.python-version == '3.10' run: | # Packages that are only needed for their annotations - python -m pip install mypy==1.0.0 types-psutil typing_extensions + python -m pip install mypy==1.10.0 types-psutil typing_extensions python -m pip install pybind11 sphinx python -u dev.py mypy diff --git a/pyproject.toml b/pyproject.toml index 0a5efd36115e..826a4976c65f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,7 +98,7 @@ doc = [ "jupyterlite-pyodide-kernel", ] dev = [ - "mypy", + "mypy==1.10.0", "typing_extensions", "types-psutil", "pycodestyle", diff --git a/requirements/dev.txt b/requirements/dev.txt index 46086ccdc0fb..47aea16dfb5e 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,6 +1,6 @@ # Generated via tools/generate_requirements.py. # Do not edit this file; modify `pyproject.toml` instead and run `python tools/generate_requirements.py`. -mypy +mypy==1.10.0 typing_extensions types-psutil pycodestyle diff --git a/scipy/_lib/_testutils.py b/scipy/_lib/_testutils.py index e8a6d49d65cd..e71c665e51c7 100644 --- a/scipy/_lib/_testutils.py +++ b/scipy/_lib/_testutils.py @@ -17,8 +17,8 @@ try: # Need type: ignore[import-untyped] for mypy >= 1.6 - import cython # type: ignore[import] - from Cython.Compiler.Version import ( # type: ignore[import] + import cython # type: ignore[import-untyped] + from Cython.Compiler.Version import ( # type: ignore[import-untyped] version as cython_version, ) except ImportError: diff --git a/scipy/conftest.py b/scipy/conftest.py index 62fd6d745dcf..90713b01376e 100644 --- a/scipy/conftest.py +++ b/scipy/conftest.py @@ -116,7 +116,7 @@ def check_fpu_mode(request): pass try: - import torch # type: ignore[import] + import torch # type: ignore[import-not-found] xp_available_backends.update({'pytorch': torch}) # can use `mps` or `cpu` torch.set_default_device(SCIPY_DEVICE) @@ -124,7 +124,7 @@ def check_fpu_mode(request): pass try: - import cupy # type: ignore[import] + import cupy # type: ignore[import-not-found] xp_available_backends.update({'cupy': cupy}) except ImportError: pass diff --git a/scipy/optimize/_milp.py b/scipy/optimize/_milp.py index fd9ecf52083f..c1d74499d5b5 100644 --- a/scipy/optimize/_milp.py +++ b/scipy/optimize/_milp.py @@ -2,7 +2,7 @@ import numpy as np from scipy.sparse import csc_array, vstack, issparse from scipy._lib._util import VisibleDeprecationWarning -from ._highs._highs_wrapper import _highs_wrapper # type: ignore[import] +from ._highs._highs_wrapper import _highs_wrapper # type: ignore[import-not-found] from ._constraints import LinearConstraint, Bounds from ._optimize import OptimizeResult from ._linprog_highs import _highs_to_scipy_status_message diff --git a/scipy/spatial/_ckdtree.pyi b/scipy/spatial/_ckdtree.pyi index 7b16a0f73614..c6624b79a6a6 100644 --- a/scipy/spatial/_ckdtree.pyi +++ b/scipy/spatial/_ckdtree.pyi @@ -73,7 +73,7 @@ class cKDTree(Generic[_BoxType]): # The latter gives us more flexibility in setting the generic parameter # though. @overload - def __new__( # type: ignore[misc] + def __new__( # type: ignore[overload-overlap] cls, data: npt.ArrayLike, leafsize: int = ..., @@ -127,7 +127,7 @@ class cKDTree(Generic[_BoxType]): ) -> list[list[int]]: ... @overload - def query_pairs( # type: ignore[misc] + def query_pairs( # type: ignore[overload-overlap] self, r: float, p: float = ..., @@ -144,7 +144,7 @@ class cKDTree(Generic[_BoxType]): ) -> npt.NDArray[np.intp]: ... @overload - def count_neighbors( # type: ignore[misc] + def count_neighbors( # type: ignore[overload-overlap] self, other: cKDTree, r: _ArrayLike0D, @@ -153,7 +153,7 @@ class cKDTree(Generic[_BoxType]): cumulative: bool = ..., ) -> int: ... @overload - def count_neighbors( # type: ignore[misc] + def count_neighbors( # type: ignore[overload-overlap] self, other: cKDTree, r: _ArrayLike0D, @@ -162,7 +162,7 @@ class cKDTree(Generic[_BoxType]): cumulative: bool = ..., ) -> np.float64: ... @overload - def count_neighbors( # type: ignore[misc] + def count_neighbors( # type: ignore[overload-overlap] self, other: cKDTree, r: npt.ArrayLike, @@ -181,7 +181,7 @@ class cKDTree(Generic[_BoxType]): ) -> npt.NDArray[np.float64]: ... @overload - def sparse_distance_matrix( # type: ignore[misc] + def sparse_distance_matrix( # type: ignore[overload-overlap] self, other: cKDTree, max_distance: float, @@ -189,7 +189,7 @@ class cKDTree(Generic[_BoxType]): output_type: Literal["dok_matrix"] = ..., ) -> dok_matrix: ... @overload - def sparse_distance_matrix( # type: ignore[misc] + def sparse_distance_matrix( # type: ignore[overload-overlap] self, other: cKDTree, max_distance: float, @@ -197,7 +197,7 @@ class cKDTree(Generic[_BoxType]): output_type: Literal["coo_matrix"] = ..., ) -> coo_matrix: ... @overload - def sparse_distance_matrix( # type: ignore[misc] + def sparse_distance_matrix( # type: ignore[overload-overlap] self, other: cKDTree, max_distance: float, diff --git a/scipy/special/_orthogonal.pyi b/scipy/special/_orthogonal.pyi index 84da71ee3473..9388513e8735 100644 --- a/scipy/special/_orthogonal.pyi +++ b/scipy/special/_orthogonal.pyi @@ -288,7 +288,7 @@ class orthopoly1d(np.poly1d): @overload def __call__(self, x: _ArrayLike0D) -> Any: ... @overload - def __call__(self, x: np.poly1d) -> np.poly1d: ... # type: ignore[misc] + def __call__(self, x: np.poly1d) -> np.poly1d: ... # type: ignore[overload-overlap] @overload def __call__(self, x: np.typing.ArrayLike) -> np.ndarray: ... diff --git a/scipy/special/_support_alternative_backends.py b/scipy/special/_support_alternative_backends.py index f1b8ba28c2fe..1aa54969063e 100644 --- a/scipy/special/_support_alternative_backends.py +++ b/scipy/special/_support_alternative_backends.py @@ -21,7 +21,7 @@ def get_array_special_func(f_name, xp, n_array_args): elif is_torch(xp): f = getattr(xp.special, f_name, None) elif is_cupy(xp): - import cupyx # type: ignore[import] + import cupyx # type: ignore[import-not-found] f = getattr(cupyx.scipy.special, f_name, None) elif xp.__name__ == f"{array_api_compat_prefix}.jax": f = getattr(xp.scipy.special, f_name, None) diff --git a/scipy/stats/_qmc.py b/scipy/stats/_qmc.py index 484cc1367c03..1aea6a694c8f 100644 --- a/scipy/stats/_qmc.py +++ b/scipy/stats/_qmc.py @@ -668,7 +668,7 @@ def n_primes(n: IntNumber) -> list[int]: 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, - 953, 967, 971, 977, 983, 991, 997][:n] # type: ignore[misc] + 953, 967, 971, 977, 983, 991, 997][:n] if len(primes) < n: big_number = 2000 @@ -1508,7 +1508,7 @@ def _random_oa_lhs(self, n: IntNumber = 4) -> np.ndarray: oa_lhs_sample /= p - return oa_lhs_sample[:, :self.d] # type: ignore + return oa_lhs_sample[:, :self.d] class Sobol(QMCEngine): @@ -1767,7 +1767,7 @@ def _random( ) sample = np.concatenate( [self._first_point, sample] - )[:n] # type: ignore[misc] + )[:n] else: _draw( n=n, num_gen=self.num_generated - 1, dim=self.d, diff --git a/scipy/stats/_unuran/unuran_wrapper.pyi b/scipy/stats/_unuran/unuran_wrapper.pyi index 96b6d4e65edf..46387c5891c6 100644 --- a/scipy/stats/_unuran/unuran_wrapper.pyi +++ b/scipy/stats/_unuran/unuran_wrapper.pyi @@ -18,7 +18,7 @@ class UNURANError(RuntimeError): class Method: @overload - def rvs(self, size: None = ...) -> float | int: ... # type: ignore[misc] + def rvs(self, size: None = ...) -> float | int: ... # type: ignore[overload-overlap] @overload def rvs(self, size: int | tuple[int, ...] = ...) -> np.ndarray: ... def set_random_state(self, random_state: SeedType) -> None: ... @@ -50,7 +50,7 @@ class TransformedDensityRejection(Method): @property def squeeze_area(self) -> float: ... @overload - def ppf_hat(self, u: ArrayLike0D) -> float: ... # type: ignore[misc] + def ppf_hat(self, u: ArrayLike0D) -> float: ... # type: ignore[overload-overlap] @overload def ppf_hat(self, u: npt.ArrayLike) -> np.ndarray: ... @@ -99,11 +99,11 @@ class NumericalInversePolynomial(Method): @property def intervals(self) -> int: ... @overload - def ppf(self, u: ArrayLike0D) -> float: ... # type: ignore[misc] + def ppf(self, u: ArrayLike0D) -> float: ... # type: ignore[overload-overlap] @overload def ppf(self, u: npt.ArrayLike) -> np.ndarray: ... @overload - def cdf(self, x: ArrayLike0D) -> float: ... # type: ignore[misc] + def cdf(self, x: ArrayLike0D) -> float: ... # type: ignore[overload-overlap] @overload def cdf(self, x: npt.ArrayLike) -> np.ndarray: ... def u_error(self, sample_size: int = ...) -> UError: ... @@ -135,7 +135,7 @@ class NumericalInverseHermite(Method): @property def intervals(self) -> int: ... @overload - def ppf(self, u: ArrayLike0D) -> float: ... # type: ignore[misc] + def ppf(self, u: ArrayLike0D) -> float: ... # type: ignore[overload-overlap] @overload def ppf(self, u: npt.ArrayLike) -> np.ndarray: ... def qrvs(self, @@ -174,6 +174,6 @@ class DiscreteGuideTable(Method): guide_factor: float = ..., random_state: SeedType = ...) -> None: ... @overload - def ppf(self, u: ArrayLike0D) -> float: ... # type: ignore[misc] + def ppf(self, u: ArrayLike0D) -> float: ... # type: ignore[overload-overlap] @overload def ppf(self, u: npt.ArrayLike) -> np.ndarray: ...