Skip to content

[CLI] Auto right-align numeric columns in human table output#4288

Merged
Wauplin merged 4 commits into
mainfrom
cli-auto-right-align-numeric-columns
May 28, 2026
Merged

[CLI] Auto right-align numeric columns in human table output#4288
Wauplin merged 4 commits into
mainfrom
cli-auto-right-align-numeric-columns

Conversation

@Wauplin

@Wauplin Wauplin commented May 28, 2026

Copy link
Copy Markdown
Collaborator

I feel it's cleaner to right-align numbers by default.

This PR automatically right-aligns all numeric-only columns (all values are int, float, or None) in human table output. Explicit alignments passed to out.table() still take precedence.

Removed now-redundant explicit alignments from papers.py, discussions.py, extensions.py, datasets.py, and partially from buckets.py (total_files is auto-inferred, size kept explicit since it can be a formatted string).

before

✗ hf models ls     
ID                   CREATED_AT DOWNLOADS LIBRARY_NAME          LIKES PIPELINE_TAG       PRIVATE TAGS                  TRENDING_SCORE
-------------------- ---------- --------- --------------------- ----- ------------------ ------- --------------------- --------------
openbmb/MiniCPM5-1B  2026-05-21 15629     transformers          457   text-generation            transformers, safe... 405           
bytedance-researc... 2026-05-15 2506      Lance                 947   any-to-any                 Lance, safetensors... 395           
meituan-longcat/L... 2026-05-21 0         diffusers             355                              diffusers, onnx, s... 345           
HauhauCS/Qwen3.6-... 2026-04-17 1956558                         971   image-text-to-text         gguf, uncensored, ... 244           

after

✗ hf models ls 
ID                   CREATED_AT DOWNLOADS LIBRARY_NAME          LIKES PIPELINE_TAG       PRIVATE TAGS                  TRENDING_SCORE
-------------------- ---------- --------- --------------------- ----- ------------------ ------- --------------------- --------------
openbmb/MiniCPM5-1B  2026-05-21     15629 transformers            457 text-generation            transformers, safe...            405
bytedance-researc... 2026-05-15      2506 Lance                   947 any-to-any                 Lance, safetensors...            395
meituan-longcat/L... 2026-05-21         0 diffusers               355                            diffusers, onnx, s...            345

🤖 Generated with Claude Code


Note

Low Risk
Presentation-only change to CLI table formatting; explicit alignments still win, with a special case for formatted size strings in bucket listings.

Overview
Human-mode CLI tables now auto right-align columns whose non-None cells are all numeric (int/float, excluding bool), via new _infer_alignments in _output.py. Explicit alignments passed to out.table() still override inference.

Several commands drop redundant manual alignment (papers, discussions, extensions, datasets leaderboard, etc.). buckets list keeps size: right only when values may be human-readable strings; total_files is inferred. Tests in test_cli_output.py expect the updated column spacing.

Reviewed by Cursor Bugbot for commit 38e8a8e. Bugbot is set up for automated code reviews on this repo. Configure here.

Numeric-only columns (int/float/None values) are now right-aligned by
default, removing the need for explicit alignments in most CLI commands.
Explicit alignments still take precedence for string columns like
formatted sizes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c13f77f. Configure here.

Comment thread src/huggingface_hub/cli/_output.py Outdated
`bool` is a subclass of `int` in Python, so boolean columns (rendered
as checkmarks) were incorrectly right-aligned.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bot-ci-comment

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Wauplin Wauplin requested a review from hanouticelina May 28, 2026 10:52

@hanouticelina hanouticelina left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree it looks better! 👍 thank you

test_cli_output.py::test_table_adaptive_shrinks_widest_column needs to be adapted otherwise good to merge!

@Wauplin

Wauplin commented May 28, 2026

Copy link
Copy Markdown
Collaborator Author

(failing CI unrelated)

@Wauplin Wauplin merged commit 5e8e940 into main May 28, 2026
22 of 26 checks passed
@Wauplin Wauplin deleted the cli-auto-right-align-numeric-columns branch May 28, 2026 13:06
@huggingface-hub-bot

Copy link
Copy Markdown
Contributor

This PR has been shipped as part of the v1.17.0 release.

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.

2 participants