Skip to content

Preserve literal text in custom filesize formats - #545

Open
longint2 wants to merge 1 commit into
python-humanize:mainfrom
longint2:fix/naturalsize-custom-format
Open

longint2 wants to merge 1 commit into
python-humanize:mainfrom
longint2:fix/naturalsize-custom-format

Conversation

@longint2

@longint2 longint2 commented Dec 6, 2026

Copy link
Copy Markdown

naturalsize(3000, format="~%.1f") raises ValueError because the suffix-promotion check tries to parse the formatted string as a float. Custom prefixes, suffixes, and escaped percent signs are valid formatting inputs.

Keep the suffix selected from the byte count when the custom formatted value is not numeric; retain the rounding-based promotion for numeric formats. Add six regressions covering literal text, negative values, and decimal/binary/GNU units.

Validation: 6 regression failures before fix; 914 tests passed after compiling translation catalogs; Ruff, Black, mypy (14 files) and diff checks passed

AI disclosure: implementation, regression tests, and this description were prepared using OpenAI Codex (GPT-6). The reported validation was executed locally.

@agentscanapp

agentscanapp Bot commented Dec 6, 2026

Copy link
Copy Markdown

Automation signals

Activity patterns show signs of automation.

View full analysis →

Evidence
  • Many forks in one day: 20 repositories forked within 24 hours

This is an automated analysis by AgentScan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant