strat-gameplay-webapp/backend/app/config/base_config.py
Cal Corum a4b99ee53e CLAUDE: Replace black and flake8 with ruff for formatting and linting
Migrated to ruff for faster, modern code formatting and linting:

Configuration changes:
- pyproject.toml: Added ruff 0.8.6, removed black/flake8
- Configured ruff with black-compatible formatting (88 chars)
- Enabled comprehensive linting rules (pycodestyle, pyflakes, isort,
  pyupgrade, bugbear, comprehensions, simplify, return)
- Updated CLAUDE.md: Changed code quality commands to use ruff

Code improvements (490 auto-fixes):
- Modernized type hints: List[T] → list[T], Dict[K,V] → dict[K,V],
  Optional[T] → T | None
- Sorted all imports (isort integration)
- Removed unused imports
- Fixed whitespace issues
- Reformatted 38 files for consistency

Bug fixes:
- app/core/play_resolver.py: Fixed type hint bug (any → Any)
- tests/unit/core/test_runner_advancement.py: Removed obsolete random mock

Testing:
- All 739 unit tests passing (100%)
- No regressions introduced

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 15:33:21 -06:00

70 lines
1.9 KiB
Python

"""
Base configuration class for league-specific game rules.
Provides abstract interface that all league configs must implement.
Author: Claude
Date: 2025-10-28
"""
from abc import ABC, abstractmethod
from pydantic import BaseModel, Field
class BaseGameConfig(BaseModel, ABC):
"""
Abstract base configuration for all leagues.
Defines common game rules and requires league-specific implementations
to provide result chart names, API endpoints, and feature flags.
"""
league_id: str = Field(..., description="League identifier ('sba' or 'pd')")
version: str = Field(
default="1.0.0", description="Config version for compatibility"
)
# Basic baseball rules (same across leagues)
innings: int = Field(default=9, description="Standard innings per game")
outs_per_inning: int = Field(default=3, description="Outs required per half-inning")
@abstractmethod
def get_result_chart_name(self) -> str:
"""
Get name of result chart to use for this league.
Returns:
Chart name identifier (e.g., 'sba_standard_v1')
"""
pass
@abstractmethod
def supports_auto_mode(self) -> bool:
"""
Whether this league supports auto-resolution of outcomes.
Auto mode uses digitized player ratings to automatically generate
outcomes without human input. This is only available for leagues
with fully digitized card data.
Returns:
True if auto mode is supported, False otherwise
"""
pass
@abstractmethod
def get_api_base_url(self) -> str:
"""
Get base URL for league's external API.
Returns:
Base URL for roster/player data API
"""
pass
class Config:
"""Pydantic configuration."""
frozen = True # Immutable config - prevents accidental modification