core.common: move Json, datetime_aware, datetime_naive, is_namedtuple, asdict to my.core.types

This commit is contained in:
Dima Gerasimov 2024-08-16 11:46:29 +03:00
parent 432c64ef56
commit e0d1dbd533
15 changed files with 78 additions and 56 deletions

View file

@ -6,6 +6,8 @@ See https://beepb00p.xyz/mypy-error-handling.html#kiss for more detail
from itertools import tee
from typing import Union, TypeVar, Iterable, List, Tuple, Type, Optional, Callable, Any, cast, Iterator, Literal
from .types import Json
T = TypeVar('T')
E = TypeVar('E', bound=Exception) # TODO make covariant?
@ -176,7 +178,6 @@ def extract_error_datetime(e: Exception) -> Optional[datetime]:
import traceback
from .common import Json
def error_to_json(e: Exception) -> Json:
estr = ''.join(traceback.format_exception(Exception, e, e.__traceback__))
return {'error': estr}