depbisect
Find the dependency update that broke your Python tests.
You ran uv lock --upgrade, merged a Renovate PR, or CI rebuilt with fresh wheels overnight.
Nineteen packages changed. The tests fail. Which change did it?
depbisect answers that automatically. It builds throwaway environments that mix the old and the
new lockfile, runs your test command in each of them, and narrows the difference down with
delta debugging. You get the culprit, the
exact release that introduced the failure, and the smallest verified fix.
$ depbisect -- pytest -q
depbisect 0.1.0
good : git:HEAD:uv.lock (19 packages)
bad : uv.lock (21 packages)
diff : 19 changed (2 added, 17 upgraded)
project: installing . in editable mode (disable with --no-project)
test : pytest -q
env : uv · python 3.13.18 · .depbisect
[ 1] baseline good set as locked ........................ PASS 0.9s
[ 2] baseline bad set as locked ......................... FAIL 0.8s
[ 3] cause good + 10 of 19 changes ................... PASS 0.7s
[ 4] cause good + 10 of 19 changes ................... FAIL 0.7s
[ 5] cause good + 8 of 19 changes .................... PASS 0.6s
[ 6] cause good + 4 of 19 changes .................... FAIL 0.6s
[ 7] cause good + typing-extensions + typing-inspection .. PASS 0.5s
[ 8] cause good + urllib3 + werkzeug ................. FAIL 0.5s
[ 9] cause good + urllib3 ............................ PASS 0.4s
[10] cause good + werkzeug ........................... FAIL 0.4s
[11] fix bad, revert werkzeug ...................... PASS 1.0s
[12] version good + werkzeug 3.1.0 ..................... FAIL 0.7s
[13] version good + werkzeug 3.0.3 ..................... FAIL 0.4s
[14] version good + werkzeug 3.0.1 ..................... FAIL 0.4s
[15] version good + werkzeug 3.0.0 ..................... FAIL 0.4s
Culprit:
werkzeug 2.3.8 -> 3.1.9 major upgrade
Applying this change to the good set is enough to reproduce the failure.
Release bisection:
werkzeug 3.0.0 is the first release that fails (last good: 2.3.8)
release page: https://pypi.org/project/werkzeug/3.0.0/
Smallest fix for the bad set:
werkzeug==2.3.8
or as a constraint: werkzeug<3.0.0
(verified: the bad set passes with this revert)
Failure output (last lines)
| from demoapp import app
| src/demoapp/__init__.py:1: in <module>
| from flask import Flask, jsonify
| .depbisect/venv/lib/python3.13/site-packages/flask/__init__.py:5: in <module>
| from .app import Flask as Flask
| .depbisect/venv/lib/python3.13/site-packages/flask/app.py:30: in <module>
| from werkzeug.urls import url_quote
| E ImportError: cannot import name 'url_quote' from 'werkzeug.urls' (/tmp/demoapp/.depbisect/venv/lib/python3.13/site-packages/werkzeug/urls.py)
| =========================== short test summary info ============================
| ERROR tests/test_health.py
| !!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
| 1 error in 0.22s
19 changes, 15 test runs, 9s
That is a real run: a Flask 2.2 app after uv lock --upgrade, with no configuration at all.
Nineteen changed packages, 15 test runs, 9 seconds.
Why this exists
git bisectsearches commits. When one commit (uv lock --upgrade, a Dependabot group PR, a rebuilt Docker image) changes many packages at once, it can only point at that commit.- Tools such as
where-brokeorscript-bisectsearch the history of one package you already suspect. With twenty changes you do not know which one to suspect. - For npm there is
npm-bisect. For Python lockfiles there was nothing that searches the set of changed packages, so people do it by hand: pin half, reinstall, rerun, repeat.
depbisect automates exactly that manual loop, and does it better than by hand:
| Interactions | Some failures need two changes together (new numpy and old pandas). Delta debugging finds the minimal combination, not just single packages. |
| Consistent mixes | Applying pydantic 2.10 without its exact pydantic-core pin would fail for the wrong reason. depbisect reads the Requires-Dist metadata of both environments and pulls in required partner changes automatically. |
| Exact release | Once a single culprit is known, its releases in between are bisected too, so you learn that werkzeug 3.0.0 broke it, not just "something up to 3.1.9". |
| Verified fix | The suggested revert is run against the bad set before it is shown to you. |
| Fast | With uv every trial is a uv pip sync from the local cache, typically under a second. Identical package sets are never tested twice. |
Install
depbisect needs Python 3.9 or newer. uv is strongly recommended
(it is used automatically when found); without it depbisect falls back to venv + pip, which
works but is much slower.
# run without installing
uvx --from git+https://github.com/DevIntense/depbisect depbisect -- pytest
# or install it
pipx install git+https://github.com/DevIntense/depbisect
pip install git+https://github.com/DevIntense/depbisect
Usage
depbisect [--good SPEC] [--bad SPEC] [options] -- <test command>
The test command decides: exit code 0 means pass, 125 means "cannot test this one, skip it"
(as in git bisect run), anything else means fail. A single argument is run through the shell,
so -- "pytest -x && python smoke.py" works.
Zero configuration
In a git repository with a lockfile, the defaults are the lockfile as committed at HEAD
(good) and the lockfile in your working tree (bad). This is the
"I just upgraded and now it is broken" case:
uv lock --upgrade # or: poetry update, pip-compile -U, ...
pytest # fails
depbisect -- pytest -x # tells you why
Where the package sets come from
| Spec | Meaning |
|---|---|
uv.lock |
uv lockfile, with markers, forks, extras and dependency groups resolved for the test interpreter |
poetry.lock |
Poetry lockfile |
pylock.toml, pylock.*.toml |
standard lockfile (PEP 751) |
Pipfile.lock |
Pipenv lockfile |
requirements.txt (any other name) |
exact pins as written by pip freeze, uv pip compile or pip-compile, hashes and markers allowed |
git:REF:PATH |
any of the above as it was at a git revision, e.g. git:main:uv.lock or git:v1.4.0:requirements.txt |
env:PATH |
the packages installed in a virtualenv or interpreter, e.g. env:.venv or env:/usr/bin/python3 |
| a directory | the first lockfile found in it |
Mix them freely: --good git:main:uv.lock --bad env:.venv compares what main locks with what
is actually installed in your venv.
Options
| Option | |
|---|---|
-g, --good SPEC / -b, --bad SPEC |
the working and the failing package set |
--python PY |
interpreter or version for the test environments (3.12, /usr/bin/python3.11) |
-e, --editable PATH |
install your own project in editable mode (repeatable). Detected automatically for uv.lock and Poetry projects; --no-project turns that off |
--with REQ |
extra requirement for every run, e.g. --with pytest when your lockfile has no test runner |
--fail-pattern REGEX |
only count a failure if the output matches. Other failures count as unresolved, so an unrelated breakage in a mixed set cannot mislead the search |
--timeout SECONDS |
time limit per test run; a hang counts as a failure |
--repeat N |
run the test N times per trial, any failure counts (for flaky regressions) |
--phase cause|fix|both |
only search what breaks it, only search the smallest repair, or both (default) |
--no-versions |
skip the release bisection of the culprit |
--allow-inconsistent |
also test mixed sets whose declared requirements cannot be satisfied |
--backend auto|uv|pip |
how environments are built |
--workdir DIR |
scratch directory for the environment and the per trial logs (default .depbisect, git ignored automatically) |
--json FILE / --markdown FILE |
machine readable and Markdown reports. On GitHub Actions the Markdown report is also added to the job summary |
--list |
only print the changes between good and bad |
-v, --verbose / --no-color |
show the reason for every trial / plain output |
Exit codes: 0 culprit found, 1 error, 2 usage error, 3 not reproducible (the good set
does not pass or the bad set does not fail), 4 inconclusive.
Recipes
Narrow the failure down to one error. Mixed environments can fail in ways that have nothing to do with your problem. Tell depbisect what your problem looks like:
depbisect --fail-pattern "AttributeError: .*has no attribute 'url_quote'" -- pytest tests/test_api.py
A Dependabot or Renovate PR is red.
git fetch origin main
depbisect --good git:origin/main:uv.lock --bad uv.lock -- pytest -x
It works on my machine but not in the fresh CI image.
pip freeze > ci-freeze.txt # in CI, then download it
depbisect --good env:.venv --bad ci-freeze.txt -- pytest -x
Private package index. Indexes listed in the lockfile or in --index-url /
--extra-index-url lines of a requirements file are passed on to the installer.
Your own code must be installed. uv.lock and Poetry projects are detected and installed in
editable mode automatically. For anything else, pass -e . (or -e packages/core -e packages/api
in a monorepo).
GitHub Action
Run depbisect when the tests of a dependency update PR fail and get the answer in the job summary:
on: pull_request
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-python@v7
with:
python-version: "3.12"
- run: pip install uv && uv sync --locked && uv run pytest
- name: Which dependency broke it?
if: failure() && github.event_name == 'pull_request'
uses: DevIntense/depbisect@v0.1.0
with:
command: pytest -x
Inputs: command (required), good (default: the lockfile at the PR's base commit), bad
(default: the lockfile in the checkout), lockfile (default: detected), python, args
(any other options). Outputs: status, culprit (for example werkzeug 2.3.8 -> 3.1.9),
first-bad-version and report (path of the JSON report).
How it works
- Baselines. The good set must pass and the bad set must fail, otherwise there is nothing to search and depbisect stops with exit code 3 and the logs.
- Cause.
ddmin(Zeller and Hildebrandt, 2002) over the changed packages applied to the good set. For a single culprit this behaves like a binary search; for culprits that only fail together it returns the minimal combination. Every selection is first closed over declared requirements so that mixed environments stay installable and consistent. - Fix. The same search in the other direction: the smallest set of reverts that makes the bad set pass. Usually that is the culprit itself, but not always (for an interaction, reverting one of the two is enough).
- Release. For a single upgraded culprit, the releases between the good and the bad version
are listed from the package index (non-yanked, no pre-releases unless an end is one) and
bisected. Releases that cannot be installed for your interpreter are skipped like
git bisect skip, and reported if they leave the answer ambiguous.
Each trial is one uv pip sync of an exact package set into a single scratch virtualenv
(pip install --no-deps into a fresh venv with the pip backend), followed by your command with
that environment activated. Every trial has a log in .depbisect/logs/ with the exact package
list, the installer output and the test output.
Limitations
- Python only. Package sets must be fully pinned; ranges in a requirements file are treated as fixed opaque values.
- The failure must be reproducible on your machine and interpreter. Use
--repeatfor flaky failures and--fail-patternto ignore unrelated ones. - Lockfile entries for other platforms are filtered with the markers of the test interpreter, so a Windows only failure has to be bisected on Windows.
- Mixed environments are checked against declared requirements only. A package that is
incompatible without saying so can still produce a failure in a mix that does not exist in
either lockfile;
--fail-patternis the safeguard. - Release bisection queries the JSON Simple API of the index (PyPI and most modern indexes).
Development
uv venv && uv pip install -e . pytest ruff
pytest # unit tests, offline, < 1 s
DEPBISECT_INTEGRATION=1 pytest -m integration # real environments, needs network and uv
ruff check src tests
The example in examples/flask-werkzeug3 reproduces the real
Flask 2.2 / Werkzeug 3.0 breakage from September 2023.
License
MIT
Metadata
Release files for depbisect 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| depbisect-0.1.0.tar.gz | 39.0 kB | With provenance | Details for depbisect-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| depbisect-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for depbisect-0.1.0-py3-none-any.whl |
Total release size: 74.9 kB
Release files / depbisect-0.1.0.tar.gz
| Download URL | depbisect-0.1.0.tar.gz |
|---|---|
| Size | 39.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
552faf2cc3b42b4963adff6a8413b0266dce526ca9a9c636a88e87ac51a1af10
|
|
BLAKE2b-256 checksum How to use checksums |
37781809e05a200e5d6964ed003ffe68e821c2b510a556bd2cc65b6ffb23b3f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logRelease files / depbisect-0.1.0-py3-none-any.whl
| Download URL | depbisect-0.1.0-py3-none-any.whl |
|---|---|
| Size | 35.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e616f0803153209c0e53ae68d82445a8aaefa5f2bfc427f220d1868ca97d364d
|
|
BLAKE2b-256 checksum How to use checksums |
e9d0634d904ef1adfef093ea52adda74db8b39c9fc1be6a979031dd95ffffa3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logSecurity for depbisect 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for depbisect-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.