lisa.utils.optional_kwargs#
- lisa.utils.optional_kwargs(func)[source]#
Decorator used to allow another decorator to both take keyword parameters when called, and none when not called:
@optional_kwargs def decorator(func, xxx=42): ... # Both of these work: @decorator def foo(...): ... @decorator(xxx=42) def foo(...): ...
Note
This only works for keyword parameters.
Note
When decorating classmethods,
optional_kwargs()
must be above@classmethod
so it can handle it properly.