ReturnType Class
- class kwhelp.decorator.ReturnType(*args: type, **kwargs)[source]
Decorator that decorates methods that require return value to match a type specificed.
See also
- __init__(*args: type, **kwargs)[source]
Constructor
- Parameters
args (type) – One ore more types that is used to validate return type.
- Keyword Arguments
type_instance_check (bool, optional) – If
True
then args are tested also forisinstance()
if type does not match, rather then just type check. IfFalse
then values willl only be tested as type. DefaultTrue
opt_return (object, optional) – Return value when decorator is invalid. By default an error is rasied when validation fails. If
opt_return
is supplied then it will be return when validation fails and no error will be raised.opt_logger (Union[Logger, LoggerAdapter], optional) – Logger that logs exceptions when validation fails.