Commit 764c3d28 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Common - Type Checkers:

- Minor Type Hint corrections
parent e13b8edd
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -30,7 +30,7 @@ def chk_attribute(name : str, container : Dict, container_name : str, **kwargs):
    if 'default' in kwargs: return kwargs['default']
    if 'default' in kwargs: return kwargs['default']
    raise AttributeError('Missing object({:s}) in container({:s})'.format(str(name), str(container_name)))
    raise AttributeError('Missing object({:s}) in container({:s})'.format(str(name), str(container_name)))


def chk_type(name : str, value : Any, type_or_types : Union[type, Set[type]] = set()) -> Any:
def chk_type(name : str, value : Any, type_or_types : Union[type, Set[type], Tuple[type]] = set()) -> Any:
    if isinstance(value, type_or_types): return value
    if isinstance(value, type_or_types): return value
    msg = '{}({}) is of a wrong type({}). Accepted type_or_types({}).'
    msg = '{}({}) is of a wrong type({}). Accepted type_or_types({}).'
    raise TypeError(msg.format(str(name), str(value), type(value).__name__, str(type_or_types)))
    raise TypeError(msg.format(str(name), str(value), type(value).__name__, str(type_or_types)))