[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",
]
