Skip to content

refactor: dynamic typing hardening - #54

Merged
deviantintegral merged 5 commits into
mainfrom
dynamic-typing-hardening-v2
Mar 2, 2026
Merged

deviantintegral merged 5 commits into
mainfrom
dynamic-typing-hardening-v2

Conversation

@deviantintegral

Copy link
Copy Markdown
Owner

No description provided.

deviantintegral and others added 5 commits March 1, 2026 19:39
Plan to harden codebase against dynamic-typing pitfalls including
magic numbers, stringly-typed patterns, unnamed tuples, and plain
dicts with known schemas.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…verrides

Phase 1 of dynamic typing hardening:
- Add 11 named constants to const.py replacing magic numbers across
  client.py, cli.py, and TUI modules
- Add kebab_name() utility and centralized display_name() overrides
  in models.py for consistent enum display across CLI and TUI
- Replace unnamed tuples with NamedTuples in cli.py, tui/app.py,
  tui/widgets.py, tui/media_theme_screen.py, tui/flame_color_screen.py,
  and tui/color_screen.py
- Replace dict return of _parse_login_page() with _B2CLoginFields
  NamedTuple in b2c_login.py
- Add _WireParam TypedDict and Literal["GET","POST"] in client.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 2 of dynamic typing hardening:
- Replace 5 hand-maintained string-to-enum lookup dicts in cli.py
  with kebab_name()-based auto-generation from enum definitions
- HeatMode lookup uses explicit member subset (NORMAL, BOOST, ECO)
- Replace fragile '"status":"400"' string matching in b2c_login.py
  with proper json.loads() parsing and try/except fallback

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 3 of dynamic typing hardening:
- Remove duplicate _FIRE_MODE_DISPLAY and _FLAME_COLOR_DISPLAY dicts
  from cli.py, replacing with centralized display_name() from models.py
- Remove duplicate _MODE_DISPLAY dict from tui/widgets.py
- Add module-level assert validating _FEATURE_LABELS field names
  against FireFeatures dataclass fields
- Add module-level assert validating _FLAME_EFFECT_SETTERS field
  names against FlameEffectParam dataclass fields

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
All 6 tasks across 3 phases completed successfully.
All 1075 tests pass with zero linting or type errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@deviantintegral deviantintegral changed the title Dynamic typing hardening v2 refactor: dynamic typing hardening Mar 2, 2026
@deviantintegral
deviantintegral marked this pull request as ready for review March 2, 2026 12:17
@deviantintegral
deviantintegral merged commit b3550dd into main Mar 2, 2026
5 of 6 checks passed
@deviantintegral
deviantintegral deleted the dynamic-typing-hardening-v2 branch March 2, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant