Skip to content

Commit 7355e15

Browse files
Kasper JungeRalphify
authored andcommitted
refactor: move _COUNT_THOUSANDS/_COUNT_MILLIONS/_SECONDS_PER_MINUTE/_MINUTES_PER_HOUR before the functions that use them
Constants were defined after format_count, which used them. Readers had to scroll past the function body to discover what the constants were. Moving them above both format_count and format_duration follows the conventional "define before use" order. Co-authored-by: Ralphify <noreply@ralphify.co>
1 parent 00199ca commit 7355e15

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/ralphify/_output.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ def warn(message: str) -> None:
8787
print(f"ralphify: warning: {message}", file=sys.stderr)
8888

8989

90+
_COUNT_THOUSANDS = 1_000
91+
_COUNT_MILLIONS = 1_000_000
92+
_SECONDS_PER_MINUTE = 60
93+
_MINUTES_PER_HOUR = 60
94+
95+
9096
def format_count(n: int) -> str:
9197
"""Format *n* as a compact human-readable count string.
9298
@@ -109,12 +115,6 @@ def format_count(n: int) -> str:
109115
return str(n)
110116

111117

112-
_COUNT_THOUSANDS = 1_000
113-
_COUNT_MILLIONS = 1_000_000
114-
_SECONDS_PER_MINUTE = 60
115-
_MINUTES_PER_HOUR = 60
116-
117-
118118
def format_duration(seconds: float) -> str:
119119
"""Format *seconds* as a compact human-readable duration string.
120120

0 commit comments

Comments
 (0)