mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-07 21:25:08 +00:00
[Ruff v0.5] Fix ZeroDivisionError
s in the ecosystem check (#12027)
Seen in CI in https://github.com/astral-sh/ruff/pull/12026
This commit is contained in:
parent
a4d711f25f
commit
0a24d70bfd
1 changed files with 8 additions and 1 deletions
|
@ -153,6 +153,9 @@ def markdown_check_result(result: Result) -> str:
|
|||
# skip display. This shouldn't really happen and indicates a problem in the
|
||||
# calculation of these values. Instead of skipping entirely when `total_changes`
|
||||
# is zero, we'll attempt to report the results to help diagnose the problem.
|
||||
#
|
||||
# There's similar issues with the `max_display_per_rule` calculation immediately
|
||||
# below as well.
|
||||
project_changes / max(total_changes, 1)
|
||||
)
|
||||
* 50
|
||||
|
@ -162,7 +165,11 @@ def markdown_check_result(result: Result) -> str:
|
|||
# Limit the number of items displayed per rule to between 5 and the max for
|
||||
# the project based on the number of rules affected (less rules, more per rule)
|
||||
max_display_per_rule = max(
|
||||
5, max_display_per_project // len(rule_changes.rule_codes())
|
||||
5,
|
||||
# TODO: remove the need for the max() call here,
|
||||
# which is a workaround for if `len(rule_changes.rule_codes()) == 0`
|
||||
# (see comment in the assignment of `max_display_per_project` immediately above)
|
||||
max_display_per_project // max(len(rule_changes.rule_codes()), 1),
|
||||
)
|
||||
|
||||
# Display the diff
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue