diff --git a/.gitignore b/.gitignore index c83cce6..c1c8f92 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,7 @@ __pycache__/ # R cache lock and fresh-regeneration backup tests/_r_cache.lock -tests/_r_cache.json.bak +tests/_r_cache.bak/ # Vendored R NNS local-install build artifacts tools/NNS/src/*.o diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..3026939 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,21 @@ +# Local hooks run `python -m ...` with language: system so they use the +# project environment's interpreter — the same one that has numpy and the +# package installed. A mypy/ruff binary from a different environment produces +# spurious import-not-found noise (numpy stubs missing) that masks real errors +# CI would catch; running through the project env keeps local == CI. +repos: + - repo: local + hooks: + - id: ruff + name: ruff check (project env) + entry: python -m ruff check --force-exclude + language: system + types_or: [python, pyi] + require_serial: true + - id: mypy + name: mypy (project env) + entry: python -m mypy + language: system + types_or: [python, pyi] + pass_filenames: false + require_serial: true diff --git a/docs/install.md b/docs/install.md index e3adc7a..206f273 100644 --- a/docs/install.md +++ b/docs/install.md @@ -50,6 +50,15 @@ uv run ruff check . uv run mypy ``` +Optionally install the pre-commit hooks, which run `ruff` and `mypy` through +the project environment's interpreter so local results match CI (a `mypy` +binary from another environment lacks the project's dependencies and reports +spurious import errors): + +```bash +uv run pre-commit install +``` + The default parity suite is cache-backed and does not require `Rscript`. `Rscript` and the R `NNS` package are needed only when regenerating parity caches or running live R comparison scripts. diff --git a/docs/parity.md b/docs/parity.md index 73399d3..2b69703 100644 --- a/docs/parity.md +++ b/docs/parity.md @@ -9,8 +9,9 @@ and remains the native C++ foundation for accelerated partial-moment routines. Full package parity is **not** claimed. Parity is bounded by the committed tests and cache: -- `tests/_r_cache.json` — cache-only R result fixtures (2,406 keyed entries, - schema version `1`, `nns_version == "13.0"`), +- `tests/_r_cache/` — cache-only R result fixtures, sharded into one JSON + file per R function label (keys are `