Contributing¶
Setup¶
$ git clone https://github.com/wzjoriv/stubpy
$ cd stubpy
$ pip install -e ".[dev]"
Developer commands¶
scripts/dev.py wraps the day-to-day tasks:
$ python scripts/dev.py --help
Command |
What it does |
|---|---|
|
Lint, tests, docs without warnings and the project’s own checks; non-zero when one fails. |
|
Runs a test tier (default |
|
Builds the HTML docs. |
|
Stubs the stubpy package with and without importing it; non-zero when a file fails or a stub does not parse. |
|
Regenerates the stubs of the pure-Python test corpus in |
|
Stubs the compiled test corpus in |
|
Builds the native modules of the compiled corpus in place, single-threaded. |
Run dev.py check before opening a pull request.
Lint¶
The project uses ruff (line length 110, target Python 3.10).
$ ruff check stubpy scripts tests
Tests¶
tests/ mirrors the package: tests/analysis/, tests/emit/, tests/resolve/,
tests/config/, tests/core/, tests/cli/, tests/compiled/, plus tests/integration/ and a few
top-level files (test_hint.py, test_merge.py). Put a new test next to the code it
covers.
$ python scripts/dev.py test
$ pytest tests/emit -q
Generated stubs¶
tests/integration/test_stubs_typecheck.py generates the stubs of corpora/drawlib (with and without
importing it) and of corpora/rasterlib (when its extensions are built) and runs mypy on them, for the current
Python and for 3.10. It skips without mypy (pip install mypy) and runs in CI in the full matrix on Python 3.12.
A new error fails the test: fix the emitter, or, when the source itself has the problem (the corpora keep a few
deliberate signature clashes), add its (error code, file) to KNOWN in the test with the reason.
Package boundaries¶
Two tests enforce the structure:
tests/test_package_boundaries.py: a module or sub-package whose name starts with_belongs to its parent package only;analysisandresolvenever importemit,core.pipelineorcore.api;emitnever importscore.pipelineorcore.api.tests/test_package_exports.py: the names instubpy.__all__match the public API.
See Architecture for the layout. Docstrings use the NumPy style for public API; one line is enough for simple internals.
Docs¶
The docs use Sphinx with Furo and MyST. The build treats warnings as errors:
$ pip install -e ".[docs]"
$ python scripts/dev.py docs --open
$ sphinx-build -b html -W --keep-going docs docs/_build/html
Every example in the guides is real stubpy output. When behaviour changes, rerun the
example and update the page. Pushes to main publish the dev docs and releases publish
stable.