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

TYP: update supported Mypy version from 1.0.0 to 1.10.0 #20600

Merged
merged 1 commit into from
Apr 28, 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 .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ doc = [
"jupyterlite-pyodide-kernel",
]
dev = [
"mypy",
"mypy==1.10.0",
"typing_extensions",
"types-psutil",
"pycodestyle",
Expand Down
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions scipy/_lib/_testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions scipy/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ 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)
except ImportError:
pass

try:
import cupy # type: ignore[import]
import cupy # type: ignore[import-not-found]
xp_available_backends.update({'cupy': cupy})
except ImportError:
pass
Expand Down
2 changes: 1 addition & 1 deletion scipy/optimize/_milp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions scipy/spatial/_ckdtree.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ...,
Expand Down Expand Up @@ -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 = ...,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -181,23 +181,23 @@ 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,
p: float = ...,
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,
p: float = ...,
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,
Expand Down
2 changes: 1 addition & 1 deletion scipy/special/_orthogonal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...

Expand Down
2 changes: 1 addition & 1 deletion scipy/special/_support_alternative_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions scipy/stats/_qmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions scipy/stats/_unuran/unuran_wrapper.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down Expand Up @@ -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: ...

Expand Down Expand Up @@ -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: ...
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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: ...
Loading