Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metric: Fix precision format #159

Merged
merged 1 commit into from
Dec 9, 2023
Merged

Conversation

e-nikolov
Copy link
Contributor

Currently if I try to print a 2 digit number with precision 0, I get this error:
ValueError: Format specifier missing precision because the format results in a negative precision number.

This PR makes sure that the precision is at least 0

@hugovk
Copy link
Member

hugovk commented Dec 3, 2023

Please can you share a snippet of code that reproduces the problem, and also include tests?

Copy link

codecov bot commented Dec 3, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5cb0323) 99.19% compared to head (e5a3976) 99.19%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #159   +/-   ##
=======================================
  Coverage   99.19%   99.19%           
=======================================
  Files           9        9           
  Lines         746      746           
=======================================
  Hits          740      740           
  Misses          6        6           
Flag Coverage Δ
macos-latest 97.58% <100.00%> (ø)
ubuntu-latest 97.58% <100.00%> (ø)
windows-latest 96.11% <100.00%> (ø)

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.

@e-nikolov
Copy link
Contributor Author

@hugovk

I added a couple of tests.

A snippet that shows the problem would be something like this:

import humanize

print(humanize.metric(10, "", 0))

# expected:     10
# actual:       ValueError: Format specifier missing precision

@hugovk hugovk added the changelog: Fixed For any bug fixes label Dec 9, 2023
@hugovk hugovk changed the title metric: Fix precision format metric: Fix precision format Dec 9, 2023
@hugovk hugovk merged commit 43d6dc6 into python-humanize:main Dec 9, 2023
30 of 31 checks passed
@hugovk
Copy link
Member

hugovk commented Dec 9, 2023

Thank you!

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.

None yet

2 participants