SubClassChecker Class

class kwhelp.checks.SubClassChecker(*args: type, **kwargs)[source]

Class that validates args is a subclass of a give type

__init__(*args: type, **kwargs)[source]

Constructor

Other Arguments:

args (type): One or more types used for Validation purposes.

Keyword Arguments
  • raise_error (bool, optional) – If True then an error will be raised if a validate() fails: Othwewise validate() will return a boolean value indicationg success or failure. Default True

  • opt_inst_only (bool, optional) – If True then validation will requires all values being tested to be an instance of a class. If False valadition will test class instance and class type. Default True

validate(*args, **kwargs) bool[source]

Validates all *args and all **kwargs against types that are passed into constructor.

Returns

True if all *args and all **kwarg match a valid class; Otherwise; False.

Return type

bool

Raises

TypeError – if raise_error is True and validation fails.

property instance_only: bool

Determines if validation requires instance of class

If True then validation will fail when a type is validated, rather then an instance of a class.

Getter

Gets instance_only.

Setter

Sets instance_only.

property raise_error: bool

Determines if errors will be raised during validation

If True then errors will be raised when validation fails.

Getter

Gets if errors can be raised.

Setter

Sets if errors can be raised.

property types: Tuple[type]

Gets the types passed into constructor that are used for validating args