Repository navigation
Fix #239 - #1
Open
codingfrog wants to merge 1 commit into
Open
Fix #239#1codingfrog wants to merge 1 commit into
codingfrog wants to merge 1 commit into
Conversation
… in naturalsize Issue python-humanize#239 was fixed on main by 11e62ee (python-humanize#240) and a79fb3a. Add the two sub-base cases those commits don't cover: string input ("300") and a non-integer float on the GNU path (300.9 -> "300B", truncated). Both fail against the 4.12.0 f-string regression. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
codingfrog
commented
Oct 21, 2026
codingfrog
left a comment
Owner
Author
There was a problem hiding this comment.
PR review round 1
Test-only change: two new cases in the existing test_naturalsize parametrize table (tests/test_filesize.py:10-94). Codebase fit is good:
- No new helpers, constants or test functions. The cases extend the existing table rather than adding a parallel test.
- No duplicates.
["300"]is the string variant of the existing[300](line 13), in the same way["1000"](line 14) and["1", False, False](line 72) complement their int forms.[300.9, False, True]checks truncation on the GNU path, which[1.123456789, False, True](line 80) cannot tell apart from rounding. - Placement: next to the upstream float regression cases (lines 77-82) and before the commented rounding-carry block (lines 85-93), so that comment still describes only its own cases.
- The negated re-run (lines 99-105) handles both new inputs the same way it handles the existing string and float cases (
"-300"->"-300 Bytes","-300.9"->"-300B").
Non-blocking notes:
- The PR title "Fix python-humanize#239" suggests a source fix. python-humanize#239 is already closed and fixed on main (11e62ee, a79fb3a), so something like "Add regression tests for python-humanize#239 (string and GNU float input)" would be more accurate, and the PR should not use a closing keyword.
- Already on main, not introduced here: the
test_argsannotation at line 96 (list[int] | list[int | bool]) does not cover the str/float/format-string cases the table holds. Out of scope for this PR.
VERDICT: APPROVE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Build ledger: issue python-humanize#239
Issue summary
In 4.12.0,
naturalsizechanged its output for values below the base unit (1000 or 1024):naturalsize(1.123456789)returned'1.123456789 Bytes'instead of'1 Bytes'. String inputwas also affected (
"300"gave'300.0 Bytes'). The cause was the%dto f-string rewrite in python-humanize#226.Upstream status: the issue is CLOSED. It was fixed on main by 11e62ee (PR python-humanize#240,
< basebranch)and a79fb3a (
== 1"Byte" branch). Main has since rewritten this function (math.log, i18n_("%d Bytes") % int(bytes_), rounding carry), and the current main source already behaves correctly.Approach
This is now a test-only change. Iter 1 branched from stale a0602c7 and re-implemented the fix (7a324d2),
which conflicted with origin/main and did nothing there (R1.1). In iter 2 the branch was reset to
origin/main (785e5dc), so the source change drops out entirely. I kept only the two regression
cases main does not already cover. Main already has
[1.123456789] -> "1 Bytes"and["1", False, False] -> "1 Byte", so I dropped those duplicates.Files touched
test_naturalsize, placed after upstream's1.123456789float cases.Tests added (cases in
test_naturalsize)["300"] -> "300 Bytes": string input below base must not render as300.0 Bytes.The negated re-run checks
"-300 Bytes".[300.9, False, True] -> "300B": the GNU path truncates non-integer floats rather thanrounding them or showing the float repr. The negated re-run checks
"-300B".new cases fail (
'300.0 Bytes','300.9B'). Restored withgit checkout; the source is unchanged.Gate results (latest)
Decisions and trade-offs
(string coercion, GNU float) that main's tests don't exercise. If the orchestrator would
rather not open a PR for a closed issue, dropping this branch is also fine.
was done against a locally re-introduced regression instead (see Tests added).
Things the next agent must know
factory/issue-239was reset (not rebased) onto origin/main. The old commit 7a324d2 isno longer on it.
factory/issue-239-iter1-backup(-> 7a324d2) exists. I made it beforethe reset, and deleting it was denied by permissions. It is safe to delete:
git branch -D factory/issue-239-iter1-backup.int()truncation in main matches the old%d(e.g. -0.5 -> "0 Bytes", not "-0 Bytes").Review resolutions
["1"]case was dropped (main covers["1", False, False]). The negation notes are now per-case and accurate1.123456789blockIteration log
(float repr in the output) and pass with the fix. Re-ran the gates and all pass, yamlfmt
included. No code changes; HEAD is still 7a324d2.
tests, and kept
["300"]and[300.9, False, True](checked that both fail against the reintroducedregression). Gates pass. Commit 9b928c0 (test-only).