Skip to content

Commit fcc8606

Browse files
authored
🐴 work around false positive overload-overlap mypy errors on numpy>=2.2 (#782)
2 parents cc3afc8 + 941cb8a commit fcc8606

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

scipy-stubs/cluster/vq.pyi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,12 @@ def _missing_raise() -> None: ... # undocumented
108108

109109
_valid_miss_meth: Final[dict[str, Callable[[], None]]] = ... # undocumented
110110

111+
# NOTE: There is a false positive `overload-overlap` mypy error that only occurs with `numpy<2.2`
112+
# mypy: disable-error-code=overload-overlap
113+
111114
#
112115
@overload # float32
113-
def kmeans2( # type: ignore[overload-overlap]
116+
def kmeans2(
114117
data: onp.CanArrayND[np.float32],
115118
k: int | _ToFloat32_2D,
116119
iter: int = 10,

scipy-stubs/ndimage/_fourier.pyi

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,12 @@ def _get_output_fourier(output: None, input: _InputC128) -> onp.ArrayND[np.compl
4444
def _get_output_fourier(output: None, input: onp.ToComplex128_ND) -> onp.ArrayND[_Scalar]: ...
4545

4646
# undocumented
47-
@overload # output: complex64 array or scalar-type
48-
def _get_output_fourier_complex( # type: ignore[overload-overlap]
49-
output: onp.ArrayND[np.complex64] | type[np.complex64], input: onp.ToComplex128_ND
50-
) -> onp.ArrayND[np.complex64]: ...
51-
@overload # output: complex128 array or scalar-type
47+
@overload # output: complex64 | complex128 array or scalar-type
5248
def _get_output_fourier_complex(
53-
output: onp.ArrayND[np.complex128] | type[np.complex128], input: onp.ToComplex128_ND
54-
) -> onp.ArrayND[np.complex128]: ...
49+
output: onp.ArrayND[_OutputScalarComplexT] | type[_OutputScalarComplexT], input: onp.ToComplex128_ND
50+
) -> onp.ArrayND[_OutputScalarComplexT]: ...
5551
@overload # ~complex64
5652
def _get_output_fourier_complex(output: None, input: _InputC64) -> onp.ArrayND[np.complex64]: ...
57-
@overload # ~complex128 | +floating
58-
def _get_output_fourier_complex(output: None, input: _InputC128 | onp.ToFloat64_ND) -> onp.ArrayND[np.complex128]: ...
5953
@overload # fallback
6054
def _get_output_fourier_complex(output: None, input: onp.ToComplex128_ND) -> onp.ArrayND[_ScalarComplex]: ...
6155

scipy-stubs/stats/_quantile.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ _QuantileMethod: TypeAlias = Literal[
2020

2121
###
2222

23+
# NOTE: There is a false positive `overload-overlap` mypy error that only occurs with `numpy<2.2`
24+
# mypy: disable-error-code=overload-overlap
25+
2326
@overload
2427
def quantile(
2528
x: onp.ToFloatStrict1D,

scipy-stubs/stats/_stats.pyi

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,12 @@ def _studentized_range_pdf_logconst(k: float, df: float) -> float: ... # undocu
9595
def genhyperbolic_pdf(x: float, p: float, a: float, b: float) -> float: ... # undocumented
9696
def genhyperbolic_logpdf(x: float, p: float, a: float, b: float) -> float: ... # undocumented
9797

98+
# NOTE: There are two false positive `overload-overlap` mypy errors that only occur with `numpy>=2.2`.
99+
# mypy: disable-error-code=overload-overlap
100+
98101
# keep in sync with `gaussian_kernel_estimate_log`
99102
@overload
100-
def gaussian_kernel_estimate( # type: ignore[overload-overlap]
103+
def gaussian_kernel_estimate(
101104
points: onp.Array2D[_AsReal],
102105
values: onp.Array2D[_Real],
103106
xi: onp.Array2D[_AsReal],
@@ -126,7 +129,7 @@ def gaussian_kernel_estimate(
126129

127130
# keep in sync with `gaussian_kernel_estimate`
128131
@overload
129-
def gaussian_kernel_estimate_log( # type: ignore[overload-overlap]
132+
def gaussian_kernel_estimate_log(
130133
points: onp.Array2D[_AsReal],
131134
values: onp.Array2D[_Real],
132135
xi: onp.Array2D[_AsReal],

0 commit comments

Comments
 (0)