SubClasskKw Class
- class kwhelp.decorator.SubClasskKw(arg_info: Dict[str, Union[int, type, Iterable[type]]], types: Optional[Iterable[Union[type, Iterable[type]]]] = None, **kwargs)[source]
Decorator that requires args of a function to match or be a subclass of types specificed in constructor.
See also
- __init__(arg_info: Dict[str, Union[int, type, Iterable[type]]], types: Optional[Iterable[Union[type, Iterable[type]]]] = None, **kwargs)[source]
Constructor
- Parameters
arg_info (Dict[str, Union[int, type, Iterable[type]]]) – Dictionary of Key and int, type, or Iterable[type]. Each Key represents that name of an arg to match one or more types(s). If value is int then value is an index that corresponds to an item in
types
.types (Iterable[Union[type, Iterable[type]]], optional) – List of types for arg_info entries to match. Default
None
- 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
ftype (DecFuncType, optional) – Type of function that decorator is applied on. Default
DecFuncType.FUNCTION
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.