-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Make units.decorators._validate_arg_value
part of the public API.
#10678
Comments
Seems reasonable (though perhaps at the |
This looks like a very interesting use case. The plan for the @quantity_input(arg_in_kwargs=T.Union[u.m, T.Callable])
def func(**kwargs):
if callable(kwargs["arg_in_kwargs"]):
print("doing something")
... Where Also a possibility is that This full set of features is a number of PRs down the line and thus a whiles away. If I could suggest a provisional change, expose |
I don't think I need an intermediate solution that requires a code change. There are tow obvious intermediate solutions already that are virtually no work:
I think I do with the first one for now. However, if this use can can be supported with moderate extra complexity in the future, that would be great! |
Description
The purpose of the code in
units.decorators
is to reduce the boilerplatecode needed to check for the correct unit input. In many cases, the decorator
will do, but in more complex it will not. In the latter case, I could still save a lot
of work by reusing the building blocks of the decorator,
most importantly
units.decorators._validate_arg_value
which does the actualchecking for the decorator.
Additional context
In my package, I have a function that should accept either a quantity or a callable
that then derives a quantity in some way and, to make matters worse, the
argument I need to check might come in **kwargs.
So, I need to check the input arguments myself.
units.decorators._validate_arg_value
can do half the work if only I'm confident to rely on a private function.
The text was updated successfully, but these errors were encountered: