FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

`naturaldelta`: round the value to nearest unit that makes sense by dangillet · Pull Request #272 · python-humanize/humanize · GitHub

naturaldelta: round the value to nearest unit that makes sense - #272

Merged
hugovk merged 3 commits into
python-humanize:mainfrom
dangillet:naturaldelta
Dec 20, 2025
Merged

naturaldelta: round the value to nearest unit that makes sense#272
hugovk merged 3 commits into
python-humanize:mainfrom
dangillet:naturaldelta

Conversation

Copy link
Copy Markdown
Contributor

naturaldelta used to always round down. We want instead to round to the nearest unit that makes sense.

Fixes #174

Changes proposed in this pull request:

  • naturaldelta rounds to the nearest value that makes sense
  • correctly handle cases where we are rounding up, leading to a higher unit: 60 minutes -> one hour
  • timedelta also round to the nearest value that makes sense

codecov Bot commented Nov 1, 2025
edited
Loading

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.51%. Comparing base (38c9968) to head (bac6f26).
⚠️ Report is 39 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #272   +/-   ##
=======================================
  Coverage   99.51%   99.51%           
=======================================
  Files          11       11           
  Lines         820      829    +9     
=======================================
+ Hits          816      825    +9     
  Misses          4        4           
Flag Coverage Δ
macos-latest 97.82% <100.00%> (+0.02%) ⬆️
ubuntu-latest 97.82% <100.00%> (+0.02%) ⬆️
windows-latest 95.89% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

naturaldelta used to always round down. We want instead to round to the
nearest unit that makes sense.

fix python-humanize#174
hugovk added the changelog: Fixed For any bug fixes label Nov 11, 2025
Comment thread tests/test_time.py Outdated
We used to round down. Now we round to the nearest.
Comment thread tests/test_time.py Outdated
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
hugovk changed the title naturaldelta rounds the value to the nearest unit that makes sense naturaldelta rounds the value to the nearest unit that makes sense Dec 20, 2025
hugovk changed the title naturaldelta rounds the value to the nearest unit that makes sense naturaldelta: round the value to nearest unit that makes sense Dec 20, 2025
hugovk merged commit 3dca143 into python-humanize:main Dec 20, 2025
43 checks passed

hugovk commented Dec 20, 2025

Copy link
Copy Markdown
Member

Thank you!

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

Labels

changelog: Fixed For any bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

humanize.naturaldelta() always rounds down

2 participants


Back | FazBrowse Home | New Git URL