Skip to content

Testing, linting, and type checking

We use pytest for testing, ruff for linting and mypy for type checking. Pull requests require all three of these things to pass.

Testing

To run the tests, run the following in the base directory of the piqtree repository:

uv run pytest

Linting

To run the linting, run the following in the base directory of the piqtree repository:

uv run ruff check

Type checking

To run type checking, run the following in the base directory of the piqtree repository:

uv run mypy src tests

The C++ extension (piqtree._piqtree) is typed by the stub src/piqtree/_piqtree.pyi, which is generated by nanobind. If you change the bindings in src/piqtree/_libiqtree/_piqtree.cpp, regenerate the stub after reinstalling with uv sync:

uv run python -m nanobind.stubgen -q --exclude-values -m piqtree._piqtree -o src/piqtree/_piqtree.pyi

The CI's type checking fails if the committed stub is out of date.

Running checks across Python versions

The CI runs the above checks through nox, which uses uv to create a fresh environment from uv.lock for each supported Python version. To list the available sessions, run:

uv run nox -l

A specific session can then be run with, e.g., uv run nox -s test-3.14.