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
TimeDelta and quantity input checking #8387
Comments
@wafels - we've tried to make Looking at the actual code in One possible solution would be to adjust the validation in the decorator to convert any non-Quantity argument to a Anyway, to do this, I think two steps are needed:
Note that both steps may be useful in themselves, although I must admit that I'm not 100% sure either is a good idea! E.g., for (2), we could also decide that the decorator should be stricter and simply insist that the input is a cc @adrn, @Cadair (decorator) and @taldcroft (timedelta) |
Just my thoughts on 2), I am strongly against having |
@Cadair - I agree very much with the sentiment of duck-typing, but just to be sure, let me a bit more concrete about problems resulting from passing objects that have a
Needless to say this behaviour is not great, but it was decided that we could not break |
A TypeError is raised when passing in a TimeDelta to a function decorated with the quantity input decorator and a time-like type annotation for the input.
The code below illustrates the issue. To me it seems natural to pass in a TimeDelta object as a way of expressing a duration, but perhaps I using TimeDelta incorrectly.
The text was updated successfully, but these errors were encountered: