Repository navigation
fix: Report each failed attempt once and tag the final attempt - #46
Merged
Merged
Conversation
Co-Authored-By: Joshua Li <14209781+joshuarli@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit bd5114d. Configure here.
- Replace setup.py/setup.cfg/dev-requirements/flake8/Makefile with a uv-managed pyproject.toml (uv_build backend) and a committed uv.lock. - Require Python >=3.13; CI tests 3.13 and 3.14. - Upgrade dependencies to latest: pytest 9.1.1, sentry-sdk 3.0.0a7, wrapt 2.5.1, pytest-rerunfailures 16.7, ruff 0.17.1, ty 0.0.90. - Pin OpenTelemetry <1.44 for dev/CI: sentry-sdk 3.0.0a7 crashes at import with newer OpenTelemetry (Context.pop on an immutable Context), which is what broke every test job on this PR. - Ruff with select=ALL + preview, ty with all rules as errors; fix all findings (types, docstrings, imports) without blanket suppressions. - CI: lint/format/type-check job, uv-based test matrix, uv build for dist (artifact name unchanged for craft); pin actions to SHAs. - bump-version.sh updates pyproject.toml and uv.lock. Co-Authored-By: Joshua Li <14209781+joshuarli@users.noreply.github.com>
…ision Comparing execution_count to the rerun count missed attempts that pytest-rerunfailures does not retry for other reasons (--only-rerun, --rerun-except, a false condition, --max-suite-reruns), tagging hard failures as final_attempt:false. Collect the attempt's exceptions in pytest_runtest_makereport and capture them in pytest_runtest_logfinish, after rerunfailures has marked a retried attempt's reports as 'rerun'. An attempt with no 'rerun' report is final.
joshuarli
approved these changes
Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

With
PYTEST_SENTRY_ALWAYS_REPORT=1and pytest-rerunfailures,pytest_runtest_makereportre-captures the whole accumulated exception chain on every attempt. A test that fails N times therefore sends 1 + 2 + … + N events, and a flaky test that passes on retry re-sends all of its earlier failures, taggedpytest.result:passed. Events also can't tell "failed, will be retried" apart from "failed every attempt", so alerts onpytest.result:failedfire on flaky retries even when CI is green.This came up in getsentry/sentry's master test alerting. There, one hard-failing test produced ~20 events per CI run, and the alert went critical on most weekday afternoons while master was green.
Changes:
pytest.attempt(rerunfailures'execution_count, 1-based) andpytest.final_attempt.pytest.final_attemptistruewhen rerunfailures won't retry the test again, or always when rerunfailures isn't installed or no reruns are configured. With these tags,pytest.result:failed pytest.final_attempt:trueis a clean "this test actually failed" signal.getsentry/sentry carries the same behavior as a local plugin for now, because it's still on pytest-sentry 0.3.0 with sentry-sdk 2.x (getsentry/sentry#128233).
Tooling port (second commit)
pyproject.toml(uv_build backend) + committeduv.lockreplacesetup.py,setup.cfg,dev-requirements.txt,.flake8andMakefile.select = ["ALL"]+ preview (only formatter-conflicting / mutually exclusive rules ignored); ty with every rule as an error anderror-on-warning. All findings fixed, no blanket suppressions.ruff check,ruff format --check,ty check), uv-based test matrix,uv buildfor dist (artifact name unchanged for craft), actions pinned to SHAs.bump-version.shnow updatespyproject.tomlanduv.lock.Why every test job was failing
Not this change: sentry-sdk 3.0.0a7 crashes at import with OpenTelemetry >=1.44 (
contextvars_context.pycallsContext.pop(), andContextbecame immutable in 1.44). The lockfile constrainsopentelemetry-api/sdk<1.44via[tool.uv] constraint-dependencies(dev/CI only, not in package metadata). Downstream users on OTel >=1.44 still hit it until sentry-sdk is fixed.via @joshuarli.
--
View Junior Session [Sentry]