Skip to content

Conversation

Copy link
Collaborator

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the only one of these projects that actually installs scipy-stubs in CI before running type checkers on their code is optuna. I think in general we try to have mypy_primer emulate the experience these projects get in CI when they actually run type checkers on their code. That said, I can totally see that having scipy-stubs installed for these projects would make things easier for you to test scipy-stubs in your CI!

I wonder if you could do something with MYPY_PATH (and/or the equivalent pyright setting, if you're using it with pyright?) in your CI's invocation of mypy_primer so that mypy considers scipy-stubs installed for the purposes of your CI, but not for other users of mypy_primer...?

@jorenham
Copy link
Contributor Author

jorenham commented Jul 3, 2025

It looks like the only one of these projects that actually installs scipy-stubs in CI before running type checkers on their code is optuna. I think in general we try to have mypy_primer emulate the experience these projects get in CI when they actually run type checkers on their code. That said, I can totally see that having scipy-stubs installed for these projects would make things easier for you to test scipy-stubs in your CI!

Yea, most of these projects don't use scipy-stubs themselves. But most of them have scipy as a dependency, for which scipy-stubs is a lightweight type-check-only alternative (scipy-stubs doesn't require scipy to be installed). But to be honest, my main motivation is, as you correctly noted, for the (perhaps selfish) sake of scipy-stubs itself 😛.

I wonder if you could do something with MYPY_PATH (and/or the equivalent pyright setting, if you're using it with pyright?) in your CI's invocation of mypy_primer so that mypy considers scipy-stubs installed for the purposes of your CI, but not for other users of mypy_primer...?

Hmm 🤔. I don't know enough about mypy_primer's implementation to say anything sensible here, I'm afraid.

@AlexWaygood
Copy link
Collaborator

(I'm pretty new as a maintainer here; curious if the other maintainers have any thoughts!)

Copy link
Owner

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm potentially okay with this, given that we're not currently installing scipy for these projects at all...

...but if your goal is to add mypy_primer to the CI of scipy-stubs, you'll need to do a path munging thing (and adding the dep here will not help with that, in fact it may even confuse)

You can see how we set this up in numpy CI, via the --new-prepend-path and --old-prepend-path flags. Let me know it that works!

@jorenham
Copy link
Contributor Author

jorenham commented Aug 21, 2025

...but if your goal is to add mypy_primer to the CI of scipy-stubs, you'll need to do a path munging thing (and adding the dep here will not help with that, in fact it may even confuse)

You can see how we set this up in numpy CI, via the --new-prepend-path and --old-prepend-path flags. Let me know it that works!

Thanks to your advice, I think I managed to get it to work now: scipy/scipy-stubs#824


edit: it indeed works :) scipy/scipy-stubs#827

@jorenham
Copy link
Contributor Author

I reverted the bokeh changes because they only use scipy in their examples, which is excluded in their mypy config. I also updated the description to make reviewing this a bit easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants