Skip to content

Run coverage from pytest addopts; ship a type stub for the extension - #12

Merged
pattonw merged 4 commits into
mainfrom
chore/best-practices
Nov 5, 2026
Merged

pattonw merged 4 commits into
mainfrom
chore/best-practices

Conversation

@pattonw

@pattonw pattonw commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

uv run pytest now measures coverage

[tool.pytest.ini_options] addopts carries --cov --cov-report=term-missing, so the README's uv run pytest prints the coverage table and enforces the committed fail_under floor exactly as CI does. The CI step drops the flags it no longer needs. A single file can be run without the floor:

uv run pytest --no-cov tests/<file>.py

testpaths = ["tests"] replaces the tests argument on the command line.

Type stub and py.typed

ty was green only because two # ty: ignore[unresolved-import] comments hid the compiled module, so every call into Rust was Unknown. mwatershed/mwatershed.pyi now declares agglom_rs, cluster, cluster_weighted and cluster_arrays with the signatures from src/lib.rs (usize as np.uintp), py.typed marks the package as typed, and [tool.maturin] include ships both in the wheel. The two ignores are gone, so ty checks the wrapper's calls into the extension and the tests' calls to it. The lint job and README run ty check --error-on-warning.

Verified locally: uv run ty check --error-on-warning clean, unzip -l of the built wheel lists mwatershed/mwatershed.pyi and mwatershed/py.typed, 76 tests pass at 100% coverage.

Import time and test duration, tracked per commit

The tests job times its own uv run pytest and measures the cold import of mwatershed (benchmarks/run.py), and uploads the two numbers as an artifact from the floor-interpreter, highest-resolution cell. A new benchmark workflow runs when a tests run on main completes, downloads that artifact, creates the gh-pages branch if it is missing, and publishes with github-action-benchmark to gh-pages:dev/bench, with a comparison table in the job summary and a commit comment when a metric gets 1.5x worse. The docs gain a Benchmarks page that charts every metric from that data; the docs workflow now runs after each benchmark run (instead of on push) and copies dev/bench from gh-pages into the deployed site, so the charts carry the newest point and the action's own dashboard stays reachable under the docs site. Nothing runs the test suite twice.

The same setup runs end to end in pattonw/prototype-lib.

🤖 Generated with Claude Code

pattonw and others added 4 commits November 4, 2026 17:46
…command

`[tool.pytest.ini_options] addopts` now carries `--cov --cov-report=term-missing`,
so the README's `uv run pytest` prints the coverage table and enforces
`[tool.coverage.report] fail_under` the same way CI does. The CI step drops the
flags it no longer needs. A single-file run can skip the floor with `--no-cov`.

Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
`mwatershed/mwatershed.pyi` declares `agglom_rs`, `cluster`, `cluster_weighted`
and `cluster_arrays` with the signatures from `src/lib.rs`, and `py.typed`
marks the package as typed; `[tool.maturin] include` ships both in the
wheel. The two `# ty: ignore[unresolved-import]` comments on the extension
imports go away, so ty now checks the wrapper's calls into Rust and the
tests' calls to the extension instead of treating them as Unknown. The ty
job and README run `ty check --error-on-warning`.

Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
The tests job times its own `uv run pytest`, measures the cold import of
the package's headline modules (benchmarks/run.py), and uploads the two
numbers as an artifact from one matrix cell. The benchmark workflow runs
when a tests run on main completes, downloads that artifact, creates the
gh-pages branch if it is missing, and publishes with github-action-benchmark
to gh-pages:dev/bench, with a comparison table in the job summary and a
commit comment when a metric gets 1.5x worse. The docs gain a Benchmarks
page that charts every metric from that data, one line per metric with the
commit on hover and click; the docs workflow now runs after each benchmark
run and copies dev/bench from gh-pages into the deployed site, so the
charts carry the newest point and the action's own dashboard keeps its URL.
Nothing runs the test suite twice.

Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
@pattonw
pattonw merged commit 9b7fcdf into main Nov 5, 2026
20 checks passed
@pattonw
pattonw deleted the chore/best-practices branch November 5, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant