Getting started¶
diffract finds how the public API of a Python package changed between two git refs. It gives the Conventional Commit type for that change.
Install diffract¶
diffract supports only Python 3.14 and later.
You can also use uv:
Do your first check¶
- Go to the root of a git repository.
- Make sure that the Python packages are in
src/. If they are in a different directory, read Configuration. - Run
diffract.
diffract compares HEAD~1 with HEAD. Then it writes the result:
To compare other refs, give the two refs:
How diffract gives the commit types¶
diffract uses sheridan-iceberg to get the public API at each ref. Then it compares the two APIs and finds the changed files. It gives the group of possible types. The first rule that applies gives the result:
| Change | Group | Possible types |
|---|---|---|
| A public name was removed, or had a breaking change (for example, a parameter was removed) | feat! |
feat! (breaking) |
| A public name was added, or had a change that adds to it (for example, a new optional parameter) | feat |
feat |
A .py or .pyi file in the source directory changed, and no public name changed |
code |
fix, refactor, perf, style, docs |
A .py or .pyi file in the test directory changed |
test |
test |
| All other changes | other |
docs, ci, chore, build |
diffract compares the public API and the file paths only. Thus it cannot tell a fix from
a refactor, or docs from ci. API changes lists the changes to the
public API that diffract finds.
A file in the test directory is a test file, also when the test directory is in the
source directory. A commit that changes source files and test files is in the code
group.
Next steps¶
- CLI and exit codes: all the options of the
diffractcommand. - commit-msg hook: check each commit message on your computer.
- GitHub Actions: check each pull request title in CI.
- JSON output: read the result in a script.
- API reference: use diffract from Python.