Skip to content

Commit e6e1ea6

Browse files
Revert naturalsize suffix ternary per review feedback
Restore if/elif/else suffix selection in naturalsize(); hugovk noted ternaries do not automatically improve readability here. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 8a7bff6 commit e6e1ea6

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/humanize/filesize.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,12 @@ def naturalsize(
8181
Returns:
8282
str: Human readable representation of a filesize.
8383
"""
84-
suffix_key = "gnu" if gnu else "binary" if binary else "decimal"
85-
suffix = suffixes[suffix_key]
84+
if gnu:
85+
suffix = suffixes["gnu"]
86+
elif binary:
87+
suffix = suffixes["binary"]
88+
else:
89+
suffix = suffixes["decimal"]
8690

8791
base = 1024 if (gnu or binary) else 1000
8892
bytes_ = float(value)

0 commit comments

Comments
 (0)