Skip to content

Commit

Permalink
Fix DeprecationWarning: Plural value must be an integer, got float (#147
Browse files Browse the repository at this point in the history
)
  • Loading branch information
hugovk committed Oct 19, 2023
2 parents e7c75ef + fe227a6 commit c62340c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/humanize/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,8 @@ def precisedelta(
for unit, fmt in zip(reversed(Unit), fmts):
singular_txt, plural_txt, fmt_value = fmt
if fmt_value > 0 or (not texts and unit == min_unit):
fmt_txt = _ngettext(singular_txt, plural_txt, fmt_value)
_fmt_value = 2 if 1 < fmt_value < 2 else int(fmt_value)
fmt_txt = _ngettext(singular_txt, plural_txt, _fmt_value)
if unit == min_unit and math.modf(fmt_value)[0] > 0:
fmt_txt = fmt_txt.replace("%d", format)
elif unit == YEARS:
Expand Down

0 comments on commit c62340c

Please sign in to comment.