CodeVetter · Repo Unpack · Behavior traces
TheAlgorithms/Python
Three flows characterize the system. (1) PR validation: a contributor push triggers ruff, then the build job syncs uv deps on 3.14t and runs pytest-run-parallel doctests across the tree with a long --ignore list, emitting coverage; ty runs non-blocking in parallel; project_euler changes additionally trigger doctest+answer validation. (2) Merge/push: directory_writer regenerates DIRECTORY.md and force-pushes; sphinx rebuilds and deploys Pages. (3) Euler answer check: pytest parametrizes over solution files, imports each with importlib, calls solution(), hashes, compares to JSON. A fourth operational flow is the daily hacktoberfest tracker refresh.
- PR flow step order: actions/checkout → setup-uv (cache on uv.lock) → setup-python from .python-version (3.14t, prereleases allowed) → conditional apt install libhdf5-dev for keras on pre-release Python → `uv sync --group=test` → `uv run --with=pytest-run-parallel pytest ...` → on success regenerate DIRECTORY.md via tee.
- The pytest invocation ignores 13 paths (cv2-dependent computer_vision files, digital_image_processing/, tensorflow/qiskit/MNIST-dependent modules, network-bound web_programming files, project_euler/, docs/conf.py, validate_solutions.py) before running doctests with coverage.
- Ruff gate: ruff.yml runs `uvx ruff check --output-format=github .` on push/PR to master using pyproject.toml's lint.select list of ~45 rule families (target py314), with a long lint.ignore list of deferred FIX ME/DO NOT FIX rules.
- ty type-check is advisory: workflow sets continue-on-error: true and invokes `ty check --exit-zero` pinned to regular-GIL Python 3.14, emitting ::error annotations without failing; pyproject [tool.ty] pre-ignores a dozen rule kinds as the baseline is cleaned.
- Euler CI trace: project_euler.yml is path-filtered to project_euler/**, the workflow file, and validate_solutions.py; job 1 runs `pytest --doctest-modules --cov=project_euler/ project_euler/`, job 2 runs `pytest scripts/validate_solutions.py` with GITHUB_TOKEN.
- Inside validate_solutions: at import time PROBLEM_ANSWERS is loaded from scripts/project_euler_answers.json; collect_solution_file_paths() → all_solution_file_paths() iterates problem_* dirs skipping files starting with '_' or 'test'; parametrized test_project_euler → convert_path_to_module → spec.loader.exec_module → module.solution() → sha256(answer) == expected.
- DIRECTORY.md trace on push: directory_writer.yml → checkout fetch-depth:0 → setup-python → `scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md` → git config actor → commit -am 'updating DIRECTORY.md' || true → push --force HEAD:$GITHUB_REF || true.
- build_directory_md.py print order: good_file_paths() yields sorted paths → a numbered 'Table of Contents' of top-level sections with md_anchor() slugs → print_path() emits '##' headings for new top dirs and nested bullets → each file becomes a titled link with underscores→spaces and %20-escaped URLs.
- Hacktoberfest bot trace (scheduled): checkout → pip install httpx2 → python scripts/hacktoberfest_prep_update.py (exit code captured, not fatal) → on schedule/dispatch, diff check docs/hacktober_2026_prep.md → gh auth setup-git → switch -c rolling branch → force-push → gh pr create if none open → propagate script exit code.
- The prep script intentionally exits non-zero on/after 2026-10-01 (HACKTOBERFEST_START) so the workflow fails loudly as a retirement signal; transient API failures raise BestEffortError which callers degrade rather than fail.
- Module self-run convention: algorithm files end with `if __name__ == '__main__':` calling doctest.testmod() and/or printing solution() results — e.g. bubble_sort.py runs a 10k-iteration timeit benchmark comparing iterative vs recursive.
- Devcontainer trace: devcontainer_ci.yml only triggers on .devcontainer/** or its own workflow path, and runs devcontainers/ci@v0.3 with push:never and runCmd 'true' — a smoke test that the image builds.