-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can typeguard be an optional dependency? #199
Comments
So it's worth noting that typeguard v4 has some known bugs + some IMO questionable design decisions. For example, evaluating code inside of I don't know if typeguard v3 is safe or not -- I haven't evaluated this carefully. I do note that it only existed for a short window of time, so at the very least I think it's probably not as battle-nested as the v2.13.3 release we pin to. You could try asking the Pandera maintainers if they'd be able to support typeguard v2.13.3? That would certainly be the cleanest option. Unfortunately beartype isn't an option for jaxtyping, as it does not yet support full |
Thank you for answering. I've asked the Pandera maintainers if this is would be possible. Along these lines would it be possible to have PyTree types and hence Typeguard as an extra dependency? We are planning to use it to type Torch tensors only. This would also be useful for Numpy and Tensorflow users. To install Pytree it would be something like:
and in the pyproject.toml
This would avoid installing typeguard for only one check and eventual incompatibilities with other typing libraries for a feature that in many cases might not be needed. I understand that this might be a breaking change though. |
Yup, that would unfortunately be a breaking change. FWIW I'm actually considering using pandera alongside jaxtyping for some of my own use cases, at some point in the next few months. So it might be that I have some interest in solving this problem for own use cases too... Let's see what the Pandera maintainers say, and hopefully between us we can figure out how to be compatible with each other. |
This would be a great change, if possible. I'm currently dealing with an issue where a transitive dependency (linear-operator, which is based on PyTorch) uses jaxtyping but another package I need to depend on uses the latest tyepguard. Unfortunately, the only solution I have to deal with this is to jettison some important code into a standalone package/service, which is very suboptimal for my use case. |
So if you're using PyTorch and not JAX, then you can probably afford to ignore jaxtyping's needs here and simply install whatever version of typeguard makes the other package happy. jaxtyping's own use of typeguard is used as part of handling PyTrees, which are (at least for jaxtyping) a JAX-only concept. That said I agree this situation is unfortunate. I'm noodling around with some ideas at the moment that may resolve this, we'll see where they end up. |
I'm using poetry as my package manager, which for better or worse is quite the stickler about version ranges. |
Ah! FWIW I've had all kinds of issues with Poetry in the past. These days I use |
I'll explore it, as reading the documentation I see it supports overrides. Super handy! |
Hi @patrick-kidger I was wondering, even if you use uv you cannot easily ignore the deendencies of jaxtyping when u do |
Thank you, it's great to be here! :D So having poked at this for a while now, I'm coming to the conclusion that in the short term, the best thing to do is simply to vendor a copy of typeguard v2.13.3 internally, and in doing so drop the dependency. I'll aim to make this change soon-ish! |
@JuanFMontesinos uv dependency overrides might get things working for you in the meantime: https://docs.astral.sh/uv/reference/settings/#override-dependencies (or --override for the "uv pip" commands) But this being vendored would be much appreciated, thanks Patrick! |
Dear @tmct |
Sorry, I misunderstood! Perhaps there is a feature request to uv in this... |
Okay, done in #266 ! Can you give that a go and let me know if things still work smoothly for you? |
Hi @patrick-kidger Thanks a lot. |
Curently typeguard is fixed to version 2.13.3 but this version is very old and many packages have already moved past it. For example we are trying to add jaxtyping to our codebase but it has a conflict with pandera that uses typeguard>=3.
As jaxtyping can be used with other typecheckers like beartype, is it possible to make the typeguard dependency optional?
The text was updated successfully, but these errors were encountered: