WebSocket Message Schemas (WS-002): - Add Pydantic models for all client/server WebSocket messages - Implement discriminated unions for message type parsing - Include JoinGame, Action, Resign, Heartbeat client messages - Include GameState, ActionResult, Error, TurnStart server messages Connection Manager (WS-003): - Add Redis-backed WebSocket connection tracking - Implement user-to-sid mapping with TTL management - Support game room association and opponent lookup - Add heartbeat tracking for connection health Socket.IO Authentication (WS-004): - Add JWT-based authentication middleware - Support token extraction from multiple formats - Implement session setup with ConnectionManager integration - Add require_auth helper for event handlers Socket.IO Server Setup (WS-001): - Configure AsyncServer with ASGI mode - Register /game namespace with event handlers - Integrate with FastAPI via ASGIApp wrapper - Configure CORS from application settings Game Service (GS-001): - Add stateless GameService for game lifecycle orchestration - Create engine per-operation using rules from GameState - Implement action-based RNG seeding for deterministic replay - Add rng_seed field to GameState for replay support Architecture verified: - Core module independence (no forbidden imports) - Config from request pattern (rules in GameState) - Dependency injection (constructor deps, method config) - All 1090 tests passing Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
127 lines
2.8 KiB
TOML
127 lines
2.8 KiB
TOML
[project]
|
|
name = "mantimon-tcg-backend"
|
|
version = "0.1.0"
|
|
description = "Mantimon TCG - Backend API and Game Engine"
|
|
readme = "README.md"
|
|
requires-python = ">=3.12"
|
|
dependencies = [
|
|
"alembic>=1.18.1",
|
|
"asyncpg>=0.31.0",
|
|
"bcrypt>=5.0.0",
|
|
"email-validator>=2.3.0",
|
|
"fastapi>=0.128.0",
|
|
"httpx>=0.28.1",
|
|
"passlib>=1.7.4",
|
|
"psycopg2-binary>=2.9.11",
|
|
"pydantic>=2.12.5",
|
|
"pydantic-settings>=2.12.0",
|
|
"python-jose>=3.5.0",
|
|
"python-socketio>=5.16.0",
|
|
"redis>=7.1.0",
|
|
"sqlalchemy>=2.0.46",
|
|
"uvicorn>=0.40.0",
|
|
]
|
|
|
|
[dependency-groups]
|
|
dev = [
|
|
"beautifulsoup4>=4.12.0",
|
|
"black>=26.1.0",
|
|
"fakeredis>=2.33.0",
|
|
"httpx>=0.28.1",
|
|
"mypy>=1.19.1",
|
|
"pytest>=9.0.2",
|
|
"pytest-asyncio>=1.3.0",
|
|
"pytest-cov>=7.0.0",
|
|
"requests>=2.31.0",
|
|
"respx>=0.22.0",
|
|
"ruff>=0.14.14",
|
|
"testcontainers[postgres,redis]>=4.0.0",
|
|
]
|
|
|
|
# Black configuration
|
|
[tool.black]
|
|
line-length = 100
|
|
target-version = ["py312"]
|
|
include = '\.pyi?$'
|
|
exclude = '''
|
|
/(
|
|
\.git
|
|
| \.venv
|
|
| __pycache__
|
|
| migrations
|
|
)/
|
|
'''
|
|
|
|
# Ruff configuration (fast Python linter)
|
|
[tool.ruff]
|
|
line-length = 100
|
|
target-version = "py312"
|
|
|
|
[tool.ruff.lint]
|
|
select = [
|
|
"E", # pycodestyle errors
|
|
"W", # pycodestyle warnings
|
|
"F", # Pyflakes
|
|
"I", # isort
|
|
"B", # flake8-bugbear
|
|
"C4", # flake8-comprehensions
|
|
"UP", # pyupgrade
|
|
"SIM", # flake8-simplify
|
|
]
|
|
ignore = [
|
|
"E501", # line too long (handled by black)
|
|
"B008", # do not perform function calls in argument defaults (FastAPI Depends)
|
|
]
|
|
|
|
[tool.ruff.lint.isort]
|
|
known-first-party = ["app"]
|
|
|
|
# Pytest configuration
|
|
[tool.pytest.ini_options]
|
|
testpaths = ["tests"]
|
|
asyncio_mode = "auto"
|
|
asyncio_default_fixture_loop_scope = "session"
|
|
addopts = "-v --tb=short"
|
|
filterwarnings = [
|
|
"ignore::DeprecationWarning",
|
|
# Suppress async connection cleanup warnings from pytest-asyncio event loop mismatch
|
|
# These are harmless since we use NullPool + TRUNCATE for test isolation
|
|
"ignore:The garbage collector is trying to clean up:sqlalchemy.exc.SAWarning",
|
|
"ignore:coroutine 'Connection._cancel' was never awaited:RuntimeWarning",
|
|
]
|
|
|
|
# MyPy configuration
|
|
[tool.mypy]
|
|
python_version = "3.12"
|
|
strict = true
|
|
warn_return_any = true
|
|
warn_unused_ignores = true
|
|
disallow_untyped_defs = true
|
|
plugins = ["pydantic.mypy"]
|
|
|
|
[[tool.mypy.overrides]]
|
|
module = [
|
|
"redis.*",
|
|
"socketio.*",
|
|
"passlib.*",
|
|
]
|
|
ignore_missing_imports = true
|
|
|
|
[[tool.mypy.overrides]]
|
|
# Socket.IO handlers use untyped decorators from the library
|
|
module = "app.socketio.*"
|
|
disallow_untyped_decorators = false
|
|
|
|
# Coverage configuration
|
|
[tool.coverage.run]
|
|
source = ["app"]
|
|
branch = true
|
|
omit = ["*/tests/*", "*/__pycache__/*"]
|
|
|
|
[tool.coverage.report]
|
|
exclude_lines = [
|
|
"pragma: no cover",
|
|
"if TYPE_CHECKING:",
|
|
"raise NotImplementedError",
|
|
]
|