Files
alex d94188e565 typecheck: add the mypy gate and fix every error it found
Wave 1 auto-merged two branches into semantically broken calls while ruff, format and
pytest stayed green; a type checker is the mechanical answer. Measured on the base
(434745d): 35 errors in 10 files.

- pyproject: mypy as a dev dependency plus [tool.mypy] scoped to src/ at python 3.13.
  Per-module ignore_missing_imports only for the five genuinely untyped third parties,
  each comment naming the library (yt-dlp, PySceneDetect, faster-whisper, sherpa-onnx,
  pyannote.audio); no global ignore
- .pi/verify.json: fourth gate, `uv run mypy src/`, on settle
- config: replace the StageOptions union alias (mypy cannot build it while config
  imports the option modules that import it back) with five per-stage @overloads, so
  options_for("shots").model_copy(...) types as ShotOptions; _stt_backend returns
  SttBackend instead of str
- llm: build_model/llama_server_up/build_local_model take a new ModelEndpoints protocol
  instead of Settings, so vision and synthesis hand over the DescribeOptions/
  ReportOptions value they already hold (the wave-1 drift) rather than rebuilding a
  Settings bag; vision.llama_server_up follows and drops its Settings import
- doctor: the two shadowed locals are renamed (a bool over a list[str] in _key_checks,
  a ModelAssetCheck over a CheckStatus in _diarization_checks)
- media: narrow the optional activity curve into one adaptive_curve local instead of a
  use_curve bool mypy cannot narrow through
- pipeline: the cached-turns re-attribution also requires transcript is not None
- synthesis/vision/transcribe/mcp: separate AgentRunResult names for the map and reduce
  calls, list[BinaryImage] frame parts, a str weights location in both readiness
  branches, a Segment annotation, and a literal-keyed HTTP_TRANSPORTS map

All 35 sites were type-level: no fix changes runtime behaviour on an existing path (the
vision Agent "no overload" error was a cascade of the invalid build_model argument,
proven with a probe), so there is no failing behaviour test to write; the gate itself is
the regression check. 400 passed / 2 skipped stay green and no `# type: ignore` was
added.

Closes #10
2026-11-24 10:39:18 +00:00

102 lines
2.6 KiB
TOML

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "video-analyse"
version = "0.1.0"
description = "Local-first, agent-friendly video analysis toolkit (transcript + shots + report)"
readme = "README.md"
requires-python = ">=3.13,<3.14"
license = { text = "MIT" }
authors = [{ name = "video-analyse" }]
dependencies = [
"pydantic>=2.11",
"pydantic-ai>=2.63,<3",
"pydantic-settings>=2.6",
"typer>=0.15",
"rich>=13",
"httpx>=0.27",
"faster-whisper>=1.2",
"onnx-asr[cpu,hub]>=0.12",
"sherpa-onnx>=1.10",
"scenedetect>=0.6.5",
"opencv-python-headless>=4.10",
"imagehash>=4.3",
"Pillow>=10.4",
"yt-dlp>=2025.10",
"fastmcp>=4.1",
]
[project.optional-dependencies]
pyannote = ["pyannote.audio>=4.0"]
[project.scripts]
va = "video_analyse.cli:main"
[dependency-groups]
dev = [
"mypy>=2.4.1",
"pytest>=8",
"pytest-asyncio>=0.24",
"ruff>=0.8",
]
[tool.hatch.build.targets.wheel]
packages = ["src/video_analyse"]
[tool.pytest.ini_options]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
testpaths = ["tests"]
[tool.mypy]
python_version = "3.13"
files = ["src"]
# An ignore that is no longer needed is a lie; every ignore also carries a reason.
warn_unused_ignores = true
# Only genuinely untyped third parties are exempt from the import check. Every block
# names the library, so "mypy cannot see it" never becomes a blanket permission.
[[tool.mypy.overrides]]
module = ["yt_dlp", "yt_dlp.*"] # yt-dlp ships no type hints and no stubs
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = ["scenedetect", "scenedetect.*"] # PySceneDetect ships no py.typed marker
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = ["faster_whisper", "faster_whisper.*"] # faster-whisper ships no py.typed marker
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = ["sherpa_onnx", "sherpa_onnx.*"] # sherpa-onnx ships no py.typed marker
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = ["pyannote", "pyannote.*"] # optional pyannote.audio extra is untyped
ignore_missing_imports = true
[tool.ruff]
line-length = 100
[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"UP", # pyupgrade
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"SIM", # flake8-simplify
"RUF", # ruff-specific rules
]
ignore = [
"B008", # function call in default argument (typer uses this pattern)
]
[tool.ruff.lint.per-file-ignores]
"tests/**" = ["S101"]