Обнаружено на шаге 0: `ruff format --check .` НЕ был чистым в baseline (24 файла расходились с форматом ruff). `ruff check .` был чистым. Изменение только косметическое (переносы, пустая строка после docstring модуля, склейка вызовов в пределах line-length=120 из [tool.ruff]); поведение не меняется — pytest 81/81 зелёные, `ruff check .` — без ошибок. Нужно, чтобы `ruff format --check .` стал рабочим гейтом (D13 CI).
22 lines
754 B
Python
22 lines
754 B
Python
"""JsonFileRepository — хранит FinancialModel в .json (включая version)."""
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
from application.repositories.model_repository import ModelRepository
|
|
from domain import FinancialModel
|
|
|
|
|
|
class JsonFileRepository(ModelRepository):
|
|
def load(self, path: str | Path) -> FinancialModel:
|
|
p = Path(path)
|
|
with open(p, "r", encoding="utf-8") as f:
|
|
data = json.load(f)
|
|
return FinancialModel.from_dict(data)
|
|
|
|
def save(self, model: FinancialModel, path: str | Path) -> None:
|
|
p = Path(path)
|
|
p.parent.mkdir(parents=True, exist_ok=True)
|
|
with open(p, "w", encoding="utf-8") as f:
|
|
json.dump(model.to_dict(), f, indent=2, ensure_ascii=False)
|