Repository navigation
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
for more information, see https://pre-commit.ci
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #505 +/- ##
==========================================
- Coverage 99.70% 99.29% -0.42%
==========================================
Files 12 15 +3
Lines 1024 1136 +112
==========================================
+ Hits 1021 1128 +107
- Misses 3 8 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| ) | ||
| filesize.add_argument( | ||
| "value", | ||
| nargs="?", |
There was a problem hiding this comment.
One small version-specific input edge: on Python 3.12, humanize naturalsize -1e3 is rejected as an unrecognized argument, although 1e3, -1000, and the underlying naturalsize("-1e3") all work. humanize naturalsize -- -1e3 and piping -1e3 through stdin work as well.
On Python 3.15 the direct form works, so this appears to depend on the Python version's argument parser. Would a test or a note about the -- form be useful for the older supported versions? I checked the PR's Python code with captured streams, not the installed console entry point or the full suite.
Related issue: #184
This PR adds a way to format file sizes directly from the terminal using Humanize. Previously, running
python -m humanize naturalsize 8589934592produced an error because the package had no command-line entry point. With this change, it prints8.6 GB.The CLI supports both
humanize naturalsizeandpython -m humanize naturalsize, along with binary units, GNU formatting, custom number formats, and piped input. Invalid input produces a helpful error message instead of a traceback.The implementation uses the existing naturalsize function for formatting. I also added CLI tests and updated the README and filesize documentation with examples.
I tested the changes locally on macOS. The test suite finished with 757 passed and 132 skipped. I also checked both command forms manually and confirmed the expected decimal and binary output.
The full aggregate lint check was blocked in the implementation environment by an npm certificate error while installing Prettier.