Skip to content

feat: type listen_Credits with a CreditsEvent dataclass - #39

Merged
Bre77 merged 1 commit into
mainfrom
fm/lib-creditsevent-typing
Aug 25, 2026
Merged

feat: type listen_Credits with a CreditsEvent dataclass#39
Bre77 merged 1 commit into
mainfrom
fm/lib-creditsevent-typing

Conversation

@Bre77

@Bre77 Bre77 commented Aug 25, 2026

Copy link
Copy Markdown
Member

Intent

  • listen_Credits was typed Callable[[dict[str, str | int]], None] - a bare, incomplete dict shape (it doesn't even account for the quota key, which isn't a str | int). Callers had to hand-parse the dict with no static guarantee of what keys exist.
    • Added CreditsEvent in const.py as a @dataclass, following the same construct as EnergyHistoryTotals (a from_dict classmethod building it from the event's nested dict).
    • Fields (type: str, cost: int, name: str, balance: int, quota: dict[str, Any]) are drawn from the one real fixture in tests/test_energysite_events.py (CREDITS_EVENT), all required since nothing in that sample is omitted.
    • quota is kept as dict[str, Any] rather than a nested dataclass - every observed payload ships it empty, so there's no evidence yet of its internal shape.
    • listen_Credits now returns CreditsEvent instead of the bare dict. Purely additive from the caller's perspective (a plain function still works); the callback's payload shape changes, so this is worth a version bump on release.

Replace the bare dict[str, str | int] callback type with a CreditsEvent
dataclass, following the same pattern as EnergyHistoryTotals/TeslaLocation.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Bre77 Bre77 added the fm Opened by a Firstmate crewmate label Aug 25, 2026
@Bre77
Bre77 merged commit 72a8ecd into main Aug 25, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fm Opened by a Firstmate crewmate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant