"""Check only the self-authored Python files changed in this delivery.""" import json import subprocess from build_definition import OUT, REPO def paths(): changed = ( subprocess.check_output(["git", "diff", "--name-only", "197f3e1"], cwd=REPO) .decode() .splitlines() ) added = ( subprocess.check_output(["git", "ls-files", "--others", "--exclude-standard"], cwd=REPO) .decode() .splitlines() ) return sorted( { p for p in changed + added if p.endswith(".py") and ( p.startswith("calliope-backend/tests/") or p == "calliope-backend/src/calliope/comfyui/fixed_document.py" or p.startswith("docs/hel-892/multivideo-document-evidence/") or p == "e2e/run-multivideo-document.py" ) } ) def main(): files = paths() prefix = ["uv", "run", "--project", "calliope-backend", "--offline", "ruff"] config = ["--config", "calliope-backend/pyproject.toml"] for name, command in [("format.txt", ["format", "--check"]), ("lint.txt", ["check"])]: result = subprocess.run( prefix + command + config + files, cwd=REPO, text=True, capture_output=True ) (OUT / name).write_text(result.stdout + result.stderr) assert result.returncode == 0, result.stdout + result.stderr (OUT / "python-check-files.json").write_text( json.dumps(dict(count=len(files), files=files), ensure_ascii=False, indent=2) + "\n" ) print( f"PASS Ruff check and format for {len(files)} changed self-authored Python files; " "upstream originals excluded" ) if __name__ == "__main__": main()