Cosmetic: improve exception traceback readability#80
Cosmetic: improve exception traceback readability#80hugovk merged 2 commits intopython-humanize:mainfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## main #80 +/- ##
==========================================
- Coverage 99.19% 99.06% -0.13%
==========================================
Files 9 9
Lines 741 745 +4
==========================================
+ Hits 735 738 +3
- Misses 6 7 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
carterbox
left a comment
There was a problem hiding this comment.
Might as well fix some grammar while we're here. Otherwise, LGTM. I agree that this PR improves traceback readability.
| tmp = Unit[minimum_unit.upper()] | ||
| if tmp not in (Unit.SECONDS, Unit.MILLISECONDS, Unit.MICROSECONDS): | ||
| raise ValueError(f"Minimum unit '{minimum_unit}' not supported") | ||
| msg = f"Minimum unit '{minimum_unit}' not supported" |
There was a problem hiding this comment.
| msg = f"Minimum unit '{minimum_unit}' not supported" | |
| msg = f"Minimum unit '{minimum_unit}' not supported." |
| raise ValueError( | ||
| "Minimum unit is suppressed and no suitable replacement was found" | ||
| ) | ||
| msg = "Minimum unit is suppressed and no suitable replacement was found" |
There was a problem hiding this comment.
| msg = "Minimum unit is suppressed and no suitable replacement was found" | |
| msg = "Minimum unit is suppressed, and no suitable replacement was found." |
|
I think the single sentence exception messages are fine without a full stop at the end. If there are two or more sentences, then it's needed. A quick search of CPython source code suggests the vast majority (~95%) do not end with a full stop: $ # Ending with a full stop
$ git grep "raise .*Error(.*\.['\"])" Lib | wc -l
79
$ # Ending with no full stop
$ git grep "raise .*Error(.*[^\.]['\"])" Lib | wc -l
1609 |
Changes proposed in this pull request: