More concise 'fail-under' >=
comparisons
#9514
Closed
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.
Type of Changes
Description
Change the handling of 'fail-under' from a float to a string. When fail-under's comparison is made, we can round the score to the same precision as the fail-under.
Example, if a project reports a score of 8.79, to fix all pylint warnings is a large task, so we add a CI task that ensures the score only increases on each pull request.
If I use:
The CI task will run and return a non-zero exit code. This is because the score is more precisely '8.78563061304178', and the comparison
is False. The documentation accurately describes the
>=
operator, but users can be left confused why the--fail-under
only behaves some of the time (ie when the score rounds down in the reported score).The help string for --fail-under:
Here in this pull request, I set a local variable with a score rounded to the same number of decimal places as the user provided. If the user provides an integer (or if the default value is set), I do not round the score