from typing import Any, Callable, Tuple def change_errors_to_none( errors: Tuple[Exception] = (KeyError, AttributeError, TypeError), default_result: Any = None ) -> Callable: # TODO add logger warning def decorator(f: Callable) -> Callable: def wrapped(*args, **kwargs) -> Any: result = default_result try: result = f(*args, **kwargs) except errors: pass return result return wrapped return decorator