Skip to content

Commit

Permalink
Strip trailing whitespace when no quantity is provided.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisCummins committed Jan 3, 2020
1 parent 37db739 commit 2a5dfa8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions labm8/py/humanize.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def DecimalPrefix(
DecimalScale,
min_scale=min_scale,
max_scale=max_scale,
)
).rstrip()


def BinaryPrefix(quantity, unit, precision=1, separator=" "):
Expand Down Expand Up @@ -285,7 +285,8 @@ def _Prefix(quantity, unit, precision, separator, scale_callable, **args):
0, (precision - int(math.log(abs(scaled_quantity), 10)) - 1),
)

return print_pattern % (scaled_quantity, separator, scaled_unit)
string = print_pattern % (scaled_quantity, separator, scaled_unit)
return string.rstrip()


# Prefixes and corresponding min_scale and max_scale for decimal formating.
Expand Down

0 comments on commit 2a5dfa8

Please sign in to comment.