chore(tooling): set up uv, ruff, pyright, pylint, mypy and git hooks

Replace the ad-hoc stdlib venv with a uv-managed, locked environment and
add the quality gates:

- pre-commit: ruff (lint + format), pyright, pytest at 100% coverage
- pre-push:   pylint, mypy --strict
- commit-msg: conventional commits

pytest and pyright run with pass_filenames: false so they always see the
whole project; --cov-fail-under stays in the hook rather than addopts so
single-file TDD runs are not blocked by coverage.

requires-python is >=3.12 because numpy 2.5 does not support 3.11.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-13 14:06:38 -05:00
co-authored by Claude Opus 5
parent 35b8adfa98
commit 7a62688355
11 changed files with 1729 additions and 0 deletions
+9
View File
@@ -8,3 +8,12 @@ __pycache__/
# Test audio fixtures - fetched by scripts, not committed
*.wav
# Pipeline working directories
transcripts/
out/
# Coverage
.coverage
htmlcov/
.pytest_cache/
+76
View File
@@ -0,0 +1,76 @@
# Fast gates run on commit; slow whole-project gates run on push.
# Install all three stages:
# pre-commit install --hook-type pre-commit --hook-type pre-push --hook-type commit-msg
default_install_hook_types: [pre-commit, pre-push, commit-msg]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-yaml
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-merge-conflict
- id: check-added-large-files
args: [--maxkb=512]
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v4.2.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
- repo: local
hooks:
- id: ruff-check
name: ruff (lint)
entry: uv run --locked ruff check --fix --force-exclude
language: system
types_or: [python, pyi]
require_serial: true
- id: ruff-format
name: ruff (format)
entry: uv run --locked ruff format --force-exclude
language: system
types_or: [python, pyi]
require_serial: true
# pass_filenames: a type error can surface in an unchanged file because of a
# changed one, so pyright must always see the whole project.
- id: pyright
name: pyright (types)
entry: uv run --locked pyright
language: system
types_or: [python, pyi]
pass_filenames: false
require_serial: true
# always_run + pass_filenames=false: pytest must never receive staged source
# files as arguments, and the 100% gate is only meaningful on the full suite.
- id: pytest-cov
name: pytest (100% coverage gate)
entry: uv run --locked pytest --cov --cov-fail-under=100
language: system
always_run: true
pass_filenames: false
require_serial: true
- id: pylint
name: pylint (design checks)
entry: uv run --locked pylint src tests
language: system
types: [python]
pass_filenames: false
require_serial: true
stages: [pre-push]
- id: mypy
name: mypy (strict)
entry: uv run --locked mypy
language: system
types: [python]
pass_filenames: false
require_serial: true
stages: [pre-push]
+1
View File
@@ -0,0 +1 @@
3.14
+79
View File
@@ -0,0 +1,79 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "ccn-transcribe"
version = "0.1.0"
description = "Download videos, extract FLAC, and transcribe with Whisper on whatever GPU is present."
requires-python = ">=3.12"
dependencies = [
"click>=8.1,<9",
"numpy>=2.5,<3",
"huggingface-hub>=1.31,<2",
"yt-dlp[default,deno]>=2026.8.19",
"yt-dlp-ejs>=0.8",
"openvino==2026.3.1",
"openvino-genai==2026.3.1.0",
]
[project.scripts]
ccn-transcribe = "ccn_transcribe.cli:main"
[dependency-groups]
dev = [
"pytest>=8",
"pytest-cov>=5",
"ruff>=0.6",
"pyright>=1.1.380",
"mypy>=1.11",
"pylint>=3.2",
"pre-commit>=3.8",
]
[tool.hatch.build.targets.wheel]
packages = ["src/ccn_transcribe"]
[tool.ruff]
line-length = 100
src = ["src", "tests"]
[tool.ruff.lint]
select = ["E", "F", "W", "I", "N", "UP", "B", "A", "C4", "SIM", "PTH", "RET", "ARG", "TID", "TC", "RUF"]
[tool.ruff.lint.per-file-ignores]
"tests/*" = ["ARG001", "ARG002"]
[tool.pyright]
include = ["src", "tests"]
typeCheckingMode = "strict"
venvPath = "."
venv = ".venv"
[tool.mypy]
strict = true
files = ["src", "tests"]
[tool.pylint.main]
disable = ["C0114", "C0115", "C0116", "C0301", "W0611", "W0612", "R0801"]
[tool.pytest.ini_options]
testpaths = ["tests"]
# NOTE: --cov-fail-under deliberately lives in the pre-commit hook, not here, so a
# single-file TDD run (`uv run pytest tests/test_x.py`) is not blocked by coverage.
addopts = "-q"
[tool.coverage.run]
branch = true
source = ["src/ccn_transcribe"]
[tool.coverage.report]
fail_under = 100
show_missing = true
exclude_also = [
"if TYPE_CHECKING:",
'if __name__ == "__main__":',
"@overload",
"raise NotImplementedError",
"class .*\\(Protocol\\):",
]
+1
View File
@@ -0,0 +1 @@
"""Download videos, extract FLAC, and transcribe with Whisper."""
View File
View File
Generated
+1563
View File
File diff suppressed because it is too large Load Diff