strat-gameplay-webapp/backend/app/api/routes/health.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

49 lines
1.1 KiB
Python

import logging
import pendulum
from fastapi import APIRouter
from app.config import get_settings
logger = logging.getLogger(f"{__name__}.health")
router = APIRouter()
settings = get_settings()
@router.get("/health")
async def health_check():
"""Health check endpoint"""
return {
"status": "healthy",
"timestamp": pendulum.now("UTC").to_iso8601_string(),
"environment": settings.app_env,
"version": "1.0.0",
}
@router.get("/health/db")
async def database_health():
"""Database health check"""
from sqlalchemy import text
from app.database.session import engine
try:
async with engine.connect() as conn:
await conn.execute(text("SELECT 1"))
return {
"status": "healthy",
"database": "connected",
"timestamp": pendulum.now("UTC").to_iso8601_string(),
}
except Exception as e:
logger.error(f"Database health check failed: {e}")
return {
"status": "unhealthy",
"database": "disconnected",
"error": str(e),
"timestamp": pendulum.now("UTC").to_iso8601_string(),
}