[project]
name = "meijiaka-ai-api"
version = "1.9.1"
description = "美家卡智影 - AI 视频创作后端 API"
authors = [{ name = "Meijiaka Team" }]
readme = "README.md"
requires-python = ">=3.13"
license = { text = "MIT" }
classifiers = [
    "Development Status :: 3 - Alpha",
    "Intended Audience :: Developers",
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3.13",
]

dependencies = [
    # Web 框架 (FastAPI 0.116+ 修复 Starlette 安全漏洞)
    "fastapi>=0.115.8",
    "uvicorn[standard]~=0.32.0",
    "python-multipart>=0.0.27",
    "pyasn1>=0.6.3",  # 安全修复：间接依赖，强制升级

    # 认证 & 安全
    "passlib[bcrypt]~=1.7.4",
    "bcrypt~=4.2.0",
    
    # 数据库
    "sqlalchemy[asyncio]~=2.0.36",
    "asyncpg~=0.30.0",
    "psycopg2-binary~=2.9.10",
    "alembic~=1.14.0",

    # 缓存 & 任务队列
    "redis~=5.2.0",

    
    # 配置 & 验证
    "pydantic~=2.9.0",
    "pydantic-settings~=2.6.0",
    
    # AI / LLM
    "openai~=1.58.0",
    
    # 重试 & 容错
    "tenacity~=9.0.0",
    
    # 火山方舟官方 SDK（可选，如不需要可注释掉）
    "volcengine-python-sdk[ark]~=5.0.0",
    
    # HTTP 客户端
    "httpx>=0.28.0",
    "aiohttp>=3.14.0",  # 安全修复：修复 CVE-2025-XXXX 系列漏洞
    
    # 对象存储
    "qiniu~=7.13.0",
    
    # 工具
    "pyjwt>=2.13.0",

    "pyyaml~=6.0.2",
    "orjson>=3.11.0",  # 安全修复：修复 CVE-2025-XXXX

    # 音频时长探测（TTS 扣费用）
    "mutagen~=1.47.0",

    # 图像处理（智能抠图合成封面）
    "Pillow>=11.0.0",
]

[project.optional-dependencies]
dev = [
    "pytest>=9.0.3",
    "pytest-asyncio>=0.24.0",
    "pytest-cov>=6.0.0",
    "ruff>=0.8.0",
    "black>=26.3.1",
    "mypy>=1.14.0",
    "bandit[toml]~=1.8.0",      # 安全扫描
    "pip-audit~=2.7.0",         # 漏洞检测
    "pre-commit~=4.0.0",        # Git 钩子
]

[project.scripts]
meijiaka-api = "app.main:main"

[tool.setuptools]
packages = ["app"]

[tool.black]
line-length = 100
target-version = ["py313"]

[tool.ruff]
line-length = 100
target-version = "py313"

[tool.ruff.lint]
select = ["E", "F", "I", "N", "W", "UP", "B", "C4", "SIM"]
ignore = ["E501", "E402", "N802", "N803", "N806", "N815", "B008", "B904"]

[tool.mypy]
python_version = "3.13"
warn_return_any = false
warn_unused_configs = true
ignore_missing_imports = true
# 逐步修复历史遗留问题
warn_no_return = false
check_untyped_defs = false
disallow_untyped_defs = false
disallow_incomplete_defs = false

# ========== 重构防护网：新代码严格模式 ==========
[[tool.mypy.overrides]]
module = ["app.schemas.*", "app.crud.*", "app.scheduler.handlers.*"]
warn_return_any = true
check_untyped_defs = true
disallow_untyped_defs = true
disallow_incomplete_defs = true

# Redis 客户端 typing 问题（Awaitable[T] | T），暂不严格检查
[[tool.mypy.overrides]]
module = ["app.scheduler.registry", "app.scheduler.slot_manager"]
check_untyped_defs = false
disallow_untyped_defs = false

[tool.pytest.ini_options]
asyncio_mode = "auto"

[tool.bandit]
exclude_dirs = ["tests", "scripts"]
# B101: assert 使用 — 非安全问题，纯代码规范，跳过
skips = ["B101"]
testpaths = ["tests"]
python_files = ["test_*.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
