SubClass Class
- class kwhelp.decorator.SubClass(*args: Union[type, Iterable[type]], **kwargs)[source]
Decorator that requires args of a function to match or be a subclass of types specificed in constructor.
See also
- __init__(*args: Union[type, Iterable[type]], **kwargs)[source]
Constructor
- Parameters
args (Union[type, Iterable[type]]) – One or more types or Iterator[type] for validation.
- Keyword Arguments
type_instance_check (bool, optional) – If
Truethen args are tested also forisinstance()if type does not match, rather then just type check. IfFalsethen values willl only be tested as type. DefaultTrueftype (DecFuncType, optional) – Type of function that decorator is applied on. Default
DecFuncType.FUNCTIONopt_return (object, optional) – Return value when decorator is invalid. By default an error is rasied when validation fails. If
opt_returnis supplied then it will be return when validation fails and no error will be raised.opt_inst_only (bool, optional) – If
Truethen validation will requires all values being tested to be an instance of a class. IfFalsevaladition will test class instance and class type. DefaultTrueopt_all_args (bool, optional) – If
Truethen the last subclass type passed into constructor will define any remaining args. This allows for one subclass to define required match of all arguments that decorator is applied to. DefaultFalseopt_args_filter (DecArgEnum, optional) – Filters the arguments that are validated. Default
DecArgEnum.ALL.opt_logger (Union[Logger, LoggerAdapter], optional) – Logger that logs exceptions when validation fails.