Skip to content

Commit c62340c

Browse files
authored
Fix DeprecationWarning: Plural value must be an integer, got float (#147)
2 parents e7c75ef + fe227a6 commit c62340c

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/humanize/time.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,8 @@ def precisedelta(
590590
for unit, fmt in zip(reversed(Unit), fmts):
591591
singular_txt, plural_txt, fmt_value = fmt
592592
if fmt_value > 0 or (not texts and unit == min_unit):
593-
fmt_txt = _ngettext(singular_txt, plural_txt, fmt_value)
593+
_fmt_value = 2 if 1 < fmt_value < 2 else int(fmt_value)
594+
fmt_txt = _ngettext(singular_txt, plural_txt, _fmt_value)
594595
if unit == min_unit and math.modf(fmt_value)[0] > 0:
595596
fmt_txt = fmt_txt.replace("%d", format)
596597
elif unit == YEARS:

0 commit comments

Comments
 (0)