|
|
|
@ -1,7 +1,5 @@ |
|
|
|
|
from collections.abc import Callable |
|
|
|
|
import dataclasses |
|
|
|
|
from functools import lru_cache |
|
|
|
|
import json |
|
|
|
|
from typing import TypeVar |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -23,14 +21,3 @@ class Freezable: |
|
|
|
|
|
|
|
|
|
def cache(user_function: Callable[..., _RT], /) -> Callable[..., _RT]: |
|
|
|
|
return lru_cache(maxsize=None)(user_function) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DataClassJSONEncoder(json.JSONEncoder): |
|
|
|
|
def default(self, o): |
|
|
|
|
if dataclasses.is_dataclass(o): |
|
|
|
|
return dataclasses.asdict(o) |
|
|
|
|
return super().default(o) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def json_dump_dataclass(foo): |
|
|
|
|
return json.dumps(foo, cls=DataClassJSONEncoder) |
|
|
|
|