Skip to content

fix: handle empty format spec in __format__#7

Merged
underwoo merged 1 commit into
mainfrom
fix/issue-3-empty-format-spec
Jun 22, 2026
Merged

fix: handle empty format spec in __format__#7
underwoo merged 1 commit into
mainfrom
fix/issue-3-empty-format-spec

Conversation

@underwoo

Copy link
Copy Markdown
Owner

Fixes #3

format(fsize, "") now returns str(fsize) instead of the K-unit value, satisfying Python's data model requirement that format(x, "") == str(x).

Changes:

  • Added early guard clause if not format_spec: return str(self) at the top of FSize.__format__()
  • Updated __format__ docstring to document empty-spec behavior
  • Added test_format_empty_spec() covering bytes, MiB, and KB constructors

Verification:

Check Result
pytest (46 tests) All passed
mypy No issues
pylint Clean

Closes #3

@underwoo underwoo merged commit b450e28 into main Jun 22, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: format(fsize, "") returns K-unit value instead of str(fsize)

1 participant