feat(common): sports_celebration, sports_fetch and sports_card_wrappers, promoted from the scoreboards (sports consolidation stage 3) (#672)

Three new hardware-free modules holding code the scoreboard plugins carry
as identical copies (executable AST, docstrings stripped, checked across
every carrying plugin at ledmatrix-plugins 30455671). The bodies are the
plugins'; the changes are type annotations for the mypy ratchet, the
colour helpers losing their leading underscore as public free functions,
and two comments that described the plugins' files.

- src/common/sports_celebration.py: SportsCelebrationMixin, the score/win
  takeover drawn by afl, football, hockey, nrl and soccer
  (_draw_celebration_layout and the palette, backdrop, scenery, confetti,
  crest and _fit_font steps, with their class constants), plus the colour
  helpers (logo_palette, lift_color, cap_luminance, mix_color, ...). Only
  the drawing: _start_celebration, _check_for_goal/_check_for_score,
  _check_for_win and display() differ between the plugins and stay there.
- src/common/sports_fetch.py: SportsFetchMixin, the four SportsCore methods
  identical in all nine scoreboards: _fetch_season_directly,
  _background_fetches_espn_ranges, _needs_previous_day and
  _wants_live_odds, with _LOOKBACK_CUTOFF_HOUR and _LIVE_ODDS_LOOKAHEAD.
  _get_timezone, _extract_game_details and _fetch_data are as identical
  and stay behind, for the reasons sports_shared gives (a per-plugin
  import; the abstract contract); so does SportsUpcoming.__init__, since
  no src/common mixin has a constructor.
- src/common/sports_card_wrappers.py: SportsCardWrappersMixin, the
  seventeen sports_card delegations the eight game renderers carry (15 in
  all eight, 2 in all but football, whose own versions override them).
  _schema_font_size/_resolve_font_size look identical but read each
  plugin's own _SCHEMA_PATH, so they stay.

Each mixin has no __init__ and creates no attributes (the host contract is
declared as annotations only), defines no name the mixins beside it
define, and documents the attributes it reads; a host-contract test
parses each and fails on an undocumented read. A method kept on a
plugin's class wins over the mixin's.

Tests: behaviour ported from the plugins' celebration, odds, lookback and
date-range tests against stub hosts carrying exactly the contract, with
crests drawn by the test (test_sports_celebration.py, test_sports_fetch.py,
test_sports_card_wrappers.py), and test_sports_stage3_parity.py, which with
LEDMATRIX_PLUGINS set compares every body with every plugin copy that is
left (58 pass against the plugins today; a copy that is gone counts as
adopted). All three modules are on the mypy ratchet, in
src/common/README.md, the CHANGELOG's Unreleased section and
SPORTS_UNIFICATION's module table. Nothing in core uses them yet.

Full suite: the same 67 failing test ids as main (Windows-only), 77 more
passing.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chuck
2026-09-29 12:38:40 -04:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 7f96075076
commit 1e4c890d59
11 changed files with 2013 additions and 1 deletions
+26
View File
@@ -19,6 +19,32 @@ accepts both, but the store flags the old spelling as deprecated
## Unreleased
### New modules
A plugin may import these via `src.*` once it floors on the release that
ships them. All three hold code the scoreboard plugins carry as identical
copies, moved without behaviour change under the plugins' own method names;
each docstring lists what the host class must provide. The plugins delete
their copies when they floor on that release.
- `src/common/sports_celebration.py` — `SportsCelebrationMixin`, the
score/win celebration takeover drawn by afl, football, hockey, nrl and
soccer (`_draw_celebration_layout` and the palette, backdrop, scenery,
confetti and crest steps behind it), plus its colour helpers as free
functions: `logo_palette`, `lift_color`, `cap_luminance`, `mix_color`,
`scale_color`, `dim_rgba`, `rgb_luminance`, `rgb_saturation`,
`color_distance`. Only the drawing: when to celebrate, the phrase and the
scenery stay in each plugin.
- `src/common/sports_fetch.py` — `SportsFetchMixin`, four `SportsCore`
methods identical in all nine scoreboards: `_fetch_season_directly`,
`_background_fetches_espn_ranges`, `_needs_previous_day` and
`_wants_live_odds` (with `_LOOKBACK_CUTOFF_HOUR` and
`_LIVE_ODDS_LOOKAHEAD`).
- `src/common/sports_card_wrappers.py` — `SportsCardWrappersMixin`, the
seventeen `sports_card` delegations the eight scoreboard game renderers
carry (`_vs_text`, `_element_color`, `_format_game_date`, ...): the methods
`SportsGameRendererMixin` expects its host to provide.
## 3.6.2
A fix to `src.common.favorite_team_check` (#670).