Coverage for src/copytrading_engine/parsing/routes.py: 88%
14 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-11-16 16:55 +0000
« prev ^ index » next coverage.py v7.16.2, created at 2026-11-16 16:55 +0000
1"""Immutable parsing routes loaded from external JSON configuration."""
3from collections.abc import Mapping
4from dataclasses import dataclass
5from types import MappingProxyType
8@dataclass(frozen=True, slots=True)
9class Route:
10 """How one guru's posts are read: the owner's playbook, which guru and profile revision the
11 reading belongs to, and how long a re-post of one of the guru's calls counts as the same call
12 (None: never). The guru's trading habits live in the playbook (ADR-0010)."""
14 playbook: str = ""
15 guru_id: str | None = None
16 profile_revision: str | None = None
17 repeat_window_minutes: int | None = None
19 def __post_init__(self) -> None:
20 if (self.guru_id is None) != (self.profile_revision is None): 20 ↛ 21line 20 didn't jump to line 21 because the condition on line 20 was never true
21 raise ValueError("Guru identity and profile revision must be recorded together")
24def freeze_routes(routes: Mapping[str, Route]) -> Mapping[str, Route]:
25 return MappingProxyType(dict(routes))