Thanks for your interest in contributing to PyBIDS!
PyBIDS is part of the BIDS ecosystem. For general guidance on contributing to BIDS projects — using Git and GitHub, our Code of Conduct, issue labels, and how contributions are recognized — please see the BIDS contributing guidelines. This document covers the parts specific to PyBIDS: setting up a development environment, running the tests, code style, and how we handle commits, pull requests, and the changelog.
- Bug reports, feature requests, and technical discussion: open an issue.
- Usage questions (where no bug is suspected): the
NeuroStars forum, under the
pybidstag.
If you are unsure whether a change is wanted, open an issue to discuss it before investing significant effort.
-
Fork the repository and clone your fork.
-
PyBIDS uses a Git submodule for test data. After cloning, initialize it:
git submodule update --init
This checks out
bids-examples, which several tests rely on. -
Testing is managed with tox (via
tox-uv), which builds isolated environments so the same commands run locally and in CI:pip install tox
For interactive development, you can also install PyBIDS in editable mode:
pip install -e . -
(Optional but recommended) Install the pre-commit hooks so style checks run on each commit:
pip install pre-commit pre-commit install
Run the test suite through tox. Environments are named py<XY>-<deps>, where
<deps> is full (standard dependencies) or pre (pre-release dependencies);
the lowest supported dependency set is available as py310-min:
tox run -e py311-full # standard run on Python 3.11
tox run -e py310-min # lowest supported dependencies
tox run -e py314-pre # pre-release dependenciesTests run under pytest, execute docstring examples (--doctest-modules), and
measure coverage over both src/ and tests/. The min environment resolves
dependencies to their lowest declared versions, following
SPEC 0; if you raise a
minimum, make sure py310-min still passes.
If you are fixing a bug, or adding a feature, it is strongly recommended to follow this pattern:
- Verify that tests pass, e.g., with:
tox -e py314-full - Write a test that fails (again, verify) because it reproduces your bug or exercises the feature that does not yet exist. This is a code-based specification of the behavior change.
- Commit the test before doing any further development.
- Fix the bug or implement the feature, and verify that tests now pass.
Some rules to keep you honest:
- You can use several commits to implement your changes, but at the end, tests must pass.
- Changes to the tests must be in their own commits and the commit message should explain why the specification has changed.
By developing in this way, you ensure that the feature works as expected, and that there will be a problem if somebody else breaks the contract you wrote.
PyBIDS is formatted and linted with ruff (line
length 99, single quotes; configured in ruff.toml). If you installed the
pre-commit hooks, ruff's linter (with autofix) and formatter run automatically;
otherwise run them manually before committing:
ruff check --fix
ruff formatDocstrings follow the numpydoc style.
We track the number of # noqa suppressions and fail CI if it grows:
tox run -e noqa-budgetPrefer fixing a lint finding over suppressing it.
Style-only commits. Keep formatting-only changes in their own commit,
separate from semantic changes, and include [ignore-rev] in the commit
message. You can add the resulting commit hash(es) to
.git-blame-ignore-revs so it stays out of git blame:
(
git log --grep "ignore-rev\]" --pretty=format:"# %ai - %ae - %s%n%H"; echo
) > .git-blame-ignore-revs(We will do this periodically, so this is not a requirement.)
- Use short, prefixed commit subjects describing one logical change:
feat:,fix:,doc:,rf:(refactor),test:,style:, orchore:. - Name branches
<type>/<short-desc>, e.g.fix/entity-parsing. - Keep each pull request focused on a single logical change; split unrelated work into separate PRs.
- Pull requests target the
mainbranch.
Pull request titles become changelog entries. At release time,
tools/update_changes.sh collects merged pull-request titles into
CHANGELOG.rst, so write a title that reads well as a one-line summary. You do
not need to edit CHANGELOG.rst yourself. The BIDS organization's
[ENH]/[FIX]/… PR-title prefixes are also welcome if you
prefer them.
Documentation lives in doc/ and is built with Sphinx:
tox run -e docsWhen you change code, check whether any docstrings or documentation describe the behavior you changed, and update them in the same pull request. Documentation-only contributions are very welcome.