Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Update the public parse_timespan() docstring to include hr and hrs.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds hr and hrs as accepted hour aliases for parse_timespan().
Changes:
- Extends the hour alias list.
- Adds regression tests for casing, spacing, fractions, and invalid near-matches.
- The public docstring still needs to document the new aliases.
File summaries
| File | Summary |
|---|---|
humanfriendly/tests.py |
Adds regression coverage for the new hour abbreviations. |
humanfriendly/__init__.py |
Adds hr and hrs aliases; the parse_timespan() docstring omits them. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| dict(divider=1, singular='second', plural='seconds', abbreviations=['s', 'sec', 'secs']), | ||
| dict(divider=60, singular='minute', plural='minutes', abbreviations=['m', 'min', 'mins']), | ||
| dict(divider=60 * 60, singular='hour', plural='hours', abbreviations=['h']), | ||
| dict(divider=60 * 60, singular='hour', plural='hours', abbreviations=['h', 'hr', 'hrs']), |
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.
Add
hrandhrsto the existing hour aliases, matching the short singular/plural aliases already accepted for seconds and minutes.parse_timespan('1hr')now returns3600.0, andparse_timespan('2.5 HRS')returns9000.0. Matching and output formatting otherwise remain unchanged.Closes #71.
Validation on Windows/Python 3.12: the new regression fails with
InvalidTimespanbefore the change and passes afterward. It covers zero, integer and fractional values, attached/separated units, existing hour aliases, uppercase variants and an invalid near-match. The existingtest_parse_timespanandtest_format_timespanalso pass. Flake8 on both changed files andgit diff --checkpass. The full terminal/platform suite was not run for this alias-only change.