Skip to content

fix: handle decimal string input in intword()#332

Open
jtvhd6 wants to merge 1 commit into
python-humanize:mainfrom
jtvhd6:main
Open

fix: handle decimal string input in intword()#332
jtvhd6 wants to merge 1 commit into
python-humanize:mainfrom
jtvhd6:main

Conversation

@jtvhd6

@jtvhd6 jtvhd6 commented Jun 27, 2026

Copy link
Copy Markdown

Bug: intword("12400.9") returns "12400.9" instead of "12.4 thousand" because int("12400.9") raises a ValueError in Python.
Fix: Changed value = int(value) to value = int(float(value)) so decimal strings are handled correctly, consistent with how intcomma() already handles this case.

@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.55%. Comparing base (c2c410c) to head (4f0797a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #332   +/-   ##
=======================================
  Coverage   99.55%   99.55%           
=======================================
  Files          12       12           
  Lines         900      900           
=======================================
  Hits          896      896           
  Misses          4        4           
Flag Coverage Δ
macos-latest 97.55% <100.00%> (ø)
ubuntu-latest 97.55% <100.00%> (ø)
windows-latest 95.66% <100.00%> (ø)

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

☔ View full report in Codecov by Harness.
📢 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.

@codspeed-hq

codspeed-hq Bot commented Jun 30, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 15 untouched benchmarks


Comparing jtvhd6:main (4f0797a) with main (c2c410c)

Open in CodSpeed

@hugovk hugovk added the changelog: Fixed For any bug fixes label Jun 30, 2026
@hugovk

hugovk commented Jun 30, 2026

Copy link
Copy Markdown
Member

Thanks for the PR, please could you add test cases that failed before and pass with this fix?

For example, ("1234.5", "1.2 thousand") and ("1234.9", "1.2 thousand") to test_intword.

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.

2 participants