Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/huggingface_hub/cli/_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import click

from huggingface_hub.errors import ConfirmationError
from huggingface_hub.utils import ANSI, StatusLine, disable_progress_bars, is_agent, tabulate
from huggingface_hub.utils import ANSI, StatusLine, disable_progress_bars, enable_progress_bars, is_agent, tabulate


class OutputFormat(str, Enum):
Expand Down Expand Up @@ -67,6 +67,8 @@ def set_mode(self, mode: OutputFormat = OutputFormat.auto) -> None:
self.mode = mode
if mode != OutputFormat.human:
disable_progress_bars()
else:
enable_progress_bars()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Human mode warns when bars disabled

Low Severity

set_mode now calls enable_progress_bars for every human-mode resolution, including Output construction and auto detection. That helper emits a UserWarning when HF_HUB_DISABLE_PROGRESS_BARS is set, so a normal hf command writes a warning to stderr even though bars were already intentionally disabled.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d9e7583. Configure here.


def set_no_truncate(self, no_truncate: bool) -> None:
"""Toggle off cell truncation for human table output."""
Expand Down
14 changes: 14 additions & 0 deletions tests/test_cli_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ def test_auto_resets_after_explicit():
assert o.mode == HUMAN


def test_explicit_human_reenables_progress_bars():
# Global progress-bar state: restore it on teardown so other tests are unaffected.
from huggingface_hub.utils import are_progress_bars_disabled, enable_progress_bars

o = Output()
o.set_mode(AGENT)
assert are_progress_bars_disabled()
try:
o.set_mode(HUMAN)
assert not are_progress_bars_disabled()
finally:
enable_progress_bars()


# =============================================================================
# out.result()
# =============================================================================
Expand Down