Loading src/common/type_checkers/Checkers.py +1 −1 Original line number Original line Diff line number Diff line Loading @@ -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))) Loading Loading
src/common/type_checkers/Checkers.py +1 −1 Original line number Original line Diff line number Diff line Loading @@ -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))) Loading