From a2888cd65f3cc24f92a22fc3b2d7cf1adba8335d Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 6 Mar 2021 21:23:29 +0100 Subject: [PATCH] GitHub Actions: make pyupgrade mandatory and max-line-length=122 --- gamestonk_terminal/helper_funcs.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/gamestonk_terminal/helper_funcs.py b/gamestonk_terminal/helper_funcs.py index 8f5f0b5666a..2ebc983eaf7 100644 --- a/gamestonk_terminal/helper_funcs.py +++ b/gamestonk_terminal/helper_funcs.py @@ -80,10 +80,8 @@ def long_number_format(num) -> str: while abs(num) >= 1000: magnitude += 1 num /= 1000.0 - if num.is_integer(): - return "%d%s" % (num, ["", " K", " M", " B", " T", " P"][magnitude]) - - return "{:.3f}{}".format(num, ["", " K", " M", " B", " T", " P"][magnitude]) + num_str = int(num) if num.is_integer() else f"{num:.3f}" + return f"{num_str} {[' KMBTP'][magnitude]}".strip() if isinstance(num, int): num = str(num) if num.lstrip("-").isdigit(): @@ -93,10 +91,8 @@ def long_number_format(num) -> str: while abs(num) >= 1000: magnitude += 1 num /= 1000.0 - if num.is_integer(): - return "%d%s" % (num, ["", " K", " M", " B", " T", " P"][magnitude]) - - return "{:.3f}{}".format(num, ["", " K", " M", " B", " T", " P"][magnitude]) + num_str = int(num) if num.is_integer() else f"{num:.3f}" + return f"{num_str} {[' KMBTP'][magnitude]}".strip() return num