Replaced awkward "lookback" pattern with clean "prepare → execute → save" orchestration that captures state snapshots BEFORE each play. Key improvements: - Added per-team batter indices (away_team_batter_idx, home_team_batter_idx) - Added play snapshot fields (current_batter/pitcher/catcher_lineup_id) - Added on_base_code bit field for efficient base situation queries - Created _prepare_next_play() method for snapshot preparation - Refactored start_game() with hard lineup validation requirement - Refactored resolve_play() with explicit 6-step orchestration - Updated _save_play_to_db() to use snapshots (no DB lookbacks) - Enhanced state recovery to rebuild from last play (single query) - Added defensive lineup position validator Benefits: - No special cases for first play - Single source of truth in GameState - Saves 18+ database queries per game - Fast state recovery without replay - Complete runner tracking (before/after positions) - Explicit orchestration (easy to debug) Testing: - Added 3 new test functions (lineup validation, snapshot tracking, batting order) - All 5 test suites passing (100%) - Type checking cleaned up with targeted suppressions for SQLAlchemy Documentation: - Added comprehensive "Type Checking & Common False Positives" section to CLAUDE.md - Created type-checking-guide.md and type-checking-summary.md - Added mypy.ini configuration for SQLAlchemy/Pydantic 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
37 lines
836 B
INI
37 lines
836 B
INI
[mypy]
|
|
python_version = 3.13
|
|
warn_return_any = True
|
|
warn_unused_configs = True
|
|
disallow_untyped_defs = False
|
|
check_untyped_defs = False
|
|
|
|
# SQLAlchemy plugin to handle ORM models
|
|
plugins = sqlalchemy.ext.mypy.plugin
|
|
|
|
# Ignore missing imports for third-party libraries without stubs
|
|
ignore_missing_imports = False
|
|
|
|
# Per-module options
|
|
[mypy-app.models.db_models]
|
|
# SQLAlchemy models - disable strict checking
|
|
disallow_untyped_defs = False
|
|
warn_return_any = False
|
|
|
|
[mypy-app.database.operations]
|
|
# Database operations - SQLAlchemy ORM usage
|
|
disallow_untyped_defs = False
|
|
warn_return_any = False
|
|
|
|
[mypy-app.config]
|
|
# Pydantic settings - loaded from environment
|
|
disallow_untyped_defs = False
|
|
|
|
[mypy-pendulum.*]
|
|
ignore_missing_imports = True
|
|
|
|
[mypy-sqlalchemy.*]
|
|
ignore_missing_imports = True
|
|
|
|
[mypy-asyncpg.*]
|
|
ignore_missing_imports = True
|