tonybaloney / wily

A Python application for tracking, reporting on timing and complexity in Python code
Apache License 2.0
1.21k stars 59 forks source link

`wily rank` for revision without data raises statistics.StatisticsError #196

Closed devdanzin closed 1 year ago

devdanzin commented 1 year ago

For some revisions, like wily's own 9519747, rank finds no data to report. However, in rank() it still tries to calculate the mean for no data, resulting in:

statistics.StatisticsError: mean requires at least one data point

To Reproduce

  1. checkout wily's repo
  2. wily build
  3. wily rank -r 9519747
  4. See traceback ending like above.

Expected behavior No exception raised and either print nothing, or print an empty table listing a total of 0. Printing nothing is what wily diff does when there are no results. No users should be impacted by not printing, as it just didn't work before.

Screenshots Printing an empty table with a total of zero looks like this:

╒════════╤═════════════════════════╕
│ File   │   Maintainability Index │
╞════════╪═════════════════════════╡
│ Total  │                       0 │
╘════════╧═════════════════════════╛

Desktop (please complete the following information):

I'll submit a PR for the "prints nothing" option.