Replies: 1 comment 1 reply
-
This is unfortunately not yet possible. It has been suggested in the past a couple of times, since the same is already possible for Python versions using checks like It would either require some standardization work or would likely involve relying on For now you will likely need to pin the numpy version to |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm managing
pandas-stubs
. We have tests for testing typing declarations and arguments. I'd like to know if there is a way to tell the type checker to use a specific object type based on the installed version of a package.Use case is with numpy 1.26.4 versus numpy 2.0.
With numpy 1.26.4, we had a test where numpy returned
np.int_
as the result, but with numpy 2.0, it returnsnp.long
as the result. The issue is thatnp.int_
is not available in numpy 2.0, andnp.long
is not available in numpy 1.26.4. I'd like to be able to do something like:where that code would type check properly based on the installed version of
numpy
. There are runtime checks that work fine, but I'd like the code to type check fine for whichever version ofnumpy
is installed.Beta Was this translation helpful? Give feedback.
All reactions