This commit is contained in:
Auric Vente
2024-07-18 21:08:11 -06:00
parent fa1f5301ae
commit c95dab8e57
9 changed files with 120 additions and 48 deletions

View File

@@ -1,5 +1,7 @@
from __future__ import annotations
import json
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any
from .config import Config
@@ -9,18 +11,18 @@ if TYPE_CHECKING:
class Storage:
@staticmethod
def get_ants() -> None:
def get_ants() -> Any:
with Config.ants_json.open() as file:
return json.load(file)
@staticmethod
def save_ants(ants: list["Ant"]) -> None:
def save_ants(ants: list[Ant]) -> None:
objs = [ant.to_dict() for ant in ants]
with Config.ants_json.open("w") as file:
json.dump(objs, file)
@staticmethod
def get_names() -> None:
def get_names() -> Any:
with Config.names_json.open() as file:
return json.load(file)
return json.load(file)