Repository navigation
fix: a negative --precision exits with a traceback - #2261
Merged
Merged
Conversation
Member
|
This is now released as part of coverage 7.16.0. |
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.
A negative
--precisionexits with a raw traceback instead of a configuration error.After:
The same applies to
coverage html --precision=-2and toprecision = -1in a.coveragerc, so it is reachable from a config file and not just a typo on the command line.should_fail_under, in this same file, already raisesConfigErrorfor an out-of-rangefail_under:so this is the missing parallel guard rather than a new convention.
ConfigErroris caught bycmdline.main()and printed as a plain message.Normal use is unaffected:
--precision=2still givesTOTAL 3 0 100.00%.Testing
test_display_covered_negative_precisionintests/test_results.py, parametrised over-1and-2.Reverting only the condition,
precision < 0toprecision < -99, so the test still imports cleanly and fails as a test rather than an error:pytest tests/test_results.pyis 47 passed.mypy coverage/results.pyisSuccess: no issues found. ruff-format is clean.Two pre-existing items I left alone, both verified identical on a stashed tree: a
RUF015finding atresults.py:44, and 8 failures intest_report.pythat need the C extension and a subprocess PATH this environment does not provide.Disclosure: written with AI assistance (Claude Code). I reproduced the traceback, checked all three entry points (CLI report, CLI html, config file), and ran the revert check myself.