Skip to content

Commit f6565fc

Browse files
authored
TYP: scipy-stubs (#62331)
1 parent cc40732 commit f6565fc

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

environment.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ dependencies:
9191
- sphinx
9292
- sphinx-design
9393
- sphinx-copybutton
94+
95+
# static typing
96+
- scipy-stubs
9497
- types-python-dateutil
9598
- types-PyMySQL
9699
- types-pytz

pandas/core/missing.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
)
4646

4747
if TYPE_CHECKING:
48+
from collections.abc import Callable
4849
from typing import TypeAlias
4950

5051
from pandas import Index
@@ -548,7 +549,7 @@ def _interpolate_scipy_wrapper(
548549
new_x = np.asarray(new_x)
549550

550551
# ignores some kwargs that could be passed along.
551-
alt_methods = {
552+
alt_methods: dict[str, Callable[..., np.ndarray]] = {
552553
"barycentric": interpolate.barycentric_interpolate,
553554
"krogh": interpolate.krogh_interpolate,
554555
"from_derivatives": _from_derivatives,
@@ -566,6 +567,7 @@ def _interpolate_scipy_wrapper(
566567
"cubic",
567568
"polynomial",
568569
]
570+
terp: Callable[..., np.ndarray] | None
569571
if method in interp1d_methods:
570572
if method == "polynomial":
571573
kind = order

pandas/plotting/_matplotlib/hist.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def _get_ind(y: np.ndarray, ind):
260260

261261
@classmethod
262262
# error: Signature of "_plot" incompatible with supertype "MPLPlot"
263-
def _plot( # type: ignore[override]
263+
def _plot( # type: ignore[override]
264264
cls,
265265
ax: Axes,
266266
y: np.ndarray,
@@ -277,6 +277,8 @@ def _plot( # type: ignore[override]
277277
y = remove_na_arraylike(y)
278278
gkde = gaussian_kde(y, bw_method=bw_method, weights=weights)
279279

280+
# gaussian_kde.evaluate(None) raises TypeError, so pyright requires this check
281+
assert ind is not None
280282
y = gkde.evaluate(ind)
281283
lines = MPLPlot._plot(ax, ind, y, style=style, **kwds)
282284
return lines

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ pytest-cython
6666
sphinx
6767
sphinx-design
6868
sphinx-copybutton
69+
scipy-stubs
6970
types-python-dateutil
7071
types-PyMySQL
7172
types-pytz

0 commit comments

Comments
 (0)