You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In lcm.functools, we provide functions allow_only_kwargs and allow_args. These change the parameter kind of the function arguments.
They work as follows:
deff(a, /, *, b):
returna+bf(a=1, b=1) # error because a is positional-onlyf(1, 1) # error because b is keyword-onlyallow_only_kwargs(f)(a=1, b=1) # no errorallow_args(f)(1, 1) # no error
However, the type annotations of the product of these decorators are not optimal. For example, we currently cannot signal that the function returned by allow_only_kwargs has only keyword-only arguments but is otherwise identical to the input function.
Goal
General: Add more information through typing
Explicit: Add information that decorated functions are identical to the input functions except for the changed parameter kind.
In
lcm.functools
, we provide functionsallow_only_kwargs
andallow_args
. These change the parameter kind of the function arguments.They work as follows:
However, the type annotations of the product of these decorators are not optimal. For example, we currently cannot signal that the function returned by
allow_only_kwargs
has only keyword-only arguments but is otherwise identical to the input function.Goal
Links
The text was updated successfully, but these errors were encountered: