Skip to content

Conversation

jorenham
Copy link
Contributor

I noticed that when scipy-stubs is installed, mypy reports several new errors in pandas.core.missing. At first I thought that scipy-stubs (i.e. me) was to blame, but as it turns out, these errors were there for a good reason.

Instances of scipy.interpolate.Akima1DInterpolator can only be called with der: int. If None or some list[int] is passed, it will raise a TypeError, originating at https://github.com/scipy/scipy/blob/ec99caa218bce81c7773f6983ead9fdda7eb42c6/scipy/interpolate/_ppoly.pyx#L31 .

The other error popped up in _cubicspline_interpolate, because CubicSpline only accepts certain literal strings for the bc_type parameter of the scipy.interpolate.CubicSpline constructor. But the bc_type that's passed to it, is annotated as str, which isn't assignable to these literal strings. So I figured it could be a nice opportunity to tighten up the _cubicspline_interpolate function annotations.


Note that this is only part of the story, as there were more errors like these in other places as well. So if it's ok with you, I'd like to tackle these as well in follow-up PR's (probably one or two).
And once they're all fixed, I could add scipy-stubs as dev dependency so that issues like this one could be avoided in the future. Having scipy-stubs installed in your dev env can also help quite a bit with IDE support for things like autocompletion and inline documentation and stuff.


  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

@mroeschke mroeschke added the Typing type annotations, mypy/pyright type checking label Aug 29, 2025
@mroeschke mroeschke added this to the 3.0 milestone Aug 29, 2025
@mroeschke mroeschke merged commit 6e08c29 into pandas-dev:main Aug 29, 2025
42 checks passed
@mroeschke
Copy link
Member

Thanks @jorenham

@jorenham jorenham deleted the fix-scipy-interpolate-calls branch August 29, 2025 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants