more cleanup

This commit is contained in:
Vithor Jaeger 2022-09-22 15:20:20 -04:00
parent 976c7e580f
commit 8363b315c3
31 changed files with 7 additions and 2 deletions

View File

@ -15,6 +15,12 @@ class BaseModel(ABC):
super().__init__()
self.load(data)
def __str__(self) -> str:
return f"<{self.__class__.__name__}: {self.id}>"
def __repr__(self) -> str:
return self.__str__()
def load(self, data: dict) -> None:
"""Loads `data` into the current model."""
self.id = data.pop("id", "")

View File

@ -2,7 +2,6 @@ from __future__ import annotations
import re
import datetime
from typing import Union
def camel_to_snake(name: str) -> str:
@ -12,7 +11,7 @@ def camel_to_snake(name: str) -> str:
def to_datetime(
str_datetime: str, format: str = "%Y-%m-%d %H:%M:%S"
) -> Union[datetime.datetime, str]:
) -> datetime.datetime | str:
str_datetime = str_datetime.split(".")[0]
try:
return datetime.datetime.strptime(str_datetime, format)