Skip to content

Byte/Bit display abbreviations and base-unit parse_string fixes#114

Merged
timlnx merged 2 commits intomasterfrom
bitbyte-whatever
Apr 18, 2026
Merged

Byte/Bit display abbreviations and base-unit parse_string fixes#114
timlnx merged 2 commits intomasterfrom
bitbyte-whatever

Conversation

@timlnx
Copy link
Copy Markdown
Owner

@timlnx timlnx commented Apr 18, 2026

Summary

  • Byte and Bit now display as B and b respectively, matching the abbreviated style of every other unit. Breaking change; noted in NEWS.rst.
  • parse_string(strict=False) now correctly handles lone BByte, lone bBit, and word forms bit/bits/byte/bytes (case-insensitive) instead of raising ValueError. Closes parse_string_unsafe() fails to parse strings with Bit or Byte unit #106.

Closes #106. In the strict=False path, add explicit checks before the
prefix-normalisation step so that lone 'B' -> Byte, lone 'b' -> Bit,
and the word forms bit/bits/byte/bytes (case-insensitive) resolve to
the correct base type instead of raising ValueError.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 18, 2026

Coverage

Test Coverage Report
FileStmtsMissCoverMissing
__init__.py6190100% 
TOTAL6190100% 

The base unit display names were the only ones that didn't use
abbreviated form. Byte('Byte'/'Bytes') -> 'B' and Bit('Bit'/'Bits')
-> 'b', consistent with KiB, MiB, kB, etc. Breaking change noted in
NEWS.rst. Five tests updated to expect the new strings.

update Byte/Bit display string examples to B/b
@timlnx timlnx force-pushed the bitbyte-whatever branch from a53f170 to 3472fb9 Compare April 18, 2026 05:29
@timlnx timlnx merged commit 83a8170 into master Apr 18, 2026
14 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.

parse_string_unsafe() fails to parse strings with Bit or Byte unit

1 participant