We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
fractions.Fraction
2 parents 74dcc60 + 99c196e commit 94fc781Copy full SHA for 94fc781
1 file changed
src/humanize/number.py
@@ -5,7 +5,6 @@
5
import math
6
import re
7
import sys
8
-from fractions import Fraction
9
from typing import TYPE_CHECKING
10
11
from .i18n import _gettext as _
@@ -359,6 +358,8 @@ def fractional(value: NumberOrString) -> str:
359
358
return _format_not_finite(number)
360
except (TypeError, ValueError):
361
return str(value)
+ from fractions import Fraction
362
+
363
whole_number = int(number)
364
frac = Fraction(number - whole_number).limit_denominator(1000)
365
numerator = frac.numerator
0 commit comments