Skip to content

fix(cli): preserve display output with --quiet - #14155

Open
ychampion wants to merge 4 commits into
pypa:mainfrom
ychampion:fix-quiet-primary-output
Open

fix(cli): preserve display output with --quiet#14155
ychampion wants to merge 4 commits into
pypa:mainfrom
ychampion:fix-quiet-primary-output

Conversation

@ychampion

@ychampion ychampion commented Jul 8, 2026

Copy link
Copy Markdown

What does this PR do?

Fixes #13018.

--quiet currently raises pip's logging threshold, which also hides primary output from display commands. This keeps primary display output visible when quiet mode suppresses INFO logs, while leaving install/download progress output quiet-suppressible.

Covered display paths include show, help, index versions, list, check, hash, cache dir/info/list, config get/list/debug, debug, and search output.

Validation:

  • uv run --with pre-commit pre-commit run black --files <touched Python files>
  • uv run --with pre-commit pre-commit run ruff-check --files <touched Python files>
  • uv run --with nox nox -s test-3.12 -- tests/functional/test_show.py tests/functional/test_help.py tests/functional/test_index.py tests/functional/test_check.py tests/functional/test_list.py tests/functional/test_hash.py tests/functional/test_cache.py tests/functional/test_configuration.py tests/functional/test_debug.py tests/unit/test_command_show.py -q
  • uv run --with nox nox -s test-3.12 -- tests/functional/test_install.py::test_install_quiet -q
  • Source-tree smoke checks for list --quiet, show --quiet, cache dir --quiet, and install --dry-run --quiet

PR Checklist:

  • I agree to follow the PSF Code of Conduct.
  • I have read and have followed the CONTRIBUTING.md file.
  • I have added a news file fragment (or this PR does not need one).
  • I have read and followed the AI_POLICY.md file, and if any AI tools were used, I have disclosed it below.

AI tools used: Codex.

Constraint: pip quiet mode uses logging thresholds that also suppress primary command output.
Rejected: Emitting display output at warning level | it would misclassify normal output and route it through stderr.
Confidence: high
Scope-risk: moderate
Directive: Keep install/download progress quiet-suppressible; opt in only primary display output.
Tested: uv run --with pre-commit pre-commit run black --files <touched python files>; uv run --with pre-commit pre-commit run ruff-check --files <touched python files>; uv run --with nox nox -s test-3.12 -- <touched command test files> -q; uv run --with nox nox -s test-3.12 -- tests/functional/test_install.py::test_install_quiet -q; source-tree quiet-mode smoke checks for list/check/hash/cache/config/debug.
Not-tested: Full pip suite across every supported Python version.
Copilot AI review requested due to automatic review settings July 8, 2026 01:17

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

The quiet fallback writes primary display output directly when logging is too quiet. It should preserve the plain text shape of command output instead of letting Rich highlight package versions or paths under forced color.

Constraint: GitHub Actions sets FORCE_COLOR, exposing Rich highlighter output in quiet-mode fallback paths.\nRejected: Loosening the list test assertion | that would hide a real output-shape regression for plain display text.\nConfidence: high\nScope-risk: narrow\nDirective: Keep direct display fallback semantically plain unless a caller explicitly passes rich renderables.\nTested: PYTHONPATH=src FORCE_COLOR=1 python3 -m pip list --quiet | python3 -c 'import sys; data=sys.stdin.buffer.read(); print(b"\\x1b[" in data); print(data[:240].decode("utf-8", "replace"))'; uv run --with pre-commit pre-commit run black --files src/pip/_internal/utils/misc.py tests/functional/test_list.py; uv run --with pre-commit pre-commit run ruff-check --files src/pip/_internal/utils/misc.py tests/functional/test_list.py; uv run --with nox nox -s test-3.12 -- tests/functional/test_list.py::test_basic_list_quiet -q; uv run --with nox nox -s test-3.12 -- tests/functional/test_list.py tests/functional/test_show.py tests/functional/test_help.py tests/functional/test_index.py tests/functional/test_check.py tests/functional/test_hash.py tests/functional/test_cache.py tests/functional/test_configuration.py tests/functional/test_debug.py tests/unit/test_command_show.py -q; uv run --with nox nox -s test-3.12 -- tests/functional/test_install.py::test_install_quiet -q\nNot-tested: Full CI matrix locally.

@sepehr-rs sepehr-rs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @ychampion, thanks for your contribution!
I'm +1 on this overall. This is something I've wanted to tackle for a long time but never got around to.
The PR looks good overall, though I've left a few comments that I think would improve it further. Let me know if you have any questions!

Comment thread src/pip/_internal/commands/show.py Outdated
Comment thread src/pip/_internal/utils/misc.py Outdated
Comment thread src/pip/_internal/utils/misc.py Outdated
Comment thread src/pip/_internal/utils/misc.py Outdated
Comment thread src/pip/_internal/utils/misc.py Outdated
Comment thread tests/functional/test_cache.py
Constraint: pip's quiet output fix should keep primary display output visible while preserving install and download quiet behavior.

Rejected: Keeping per-command show_on_quiet=True annotations | maintainer requested making visible display output the default with explicit exceptions.

Confidence: high

Scope-risk: moderate

Directive: Use show_on_quiet=False only for output that quiet mode should suppress.

Tested: uv run --with pre-commit pre-commit run black --files src/pip/_internal/utils/misc.py src/pip/_internal/utils/logging.py src/pip/_internal/commands/show.py src/pip/_internal/commands/index.py src/pip/_internal/commands/check.py src/pip/_internal/commands/configuration.py src/pip/_internal/commands/cache.py src/pip/_internal/commands/list.py src/pip/_internal/commands/search.py src/pip/_internal/commands/hash.py src/pip/_internal/commands/debug.py src/pip/_internal/commands/download.py src/pip/_internal/commands/install.py tests/functional/test_cache.py; uv run --with pre-commit pre-commit run ruff-check --files same set; uv run --with nox nox -s test-3.12 -- tests/functional/test_show.py tests/functional/test_help.py tests/functional/test_index.py tests/functional/test_check.py tests/functional/test_list.py tests/functional/test_hash.py tests/functional/test_cache.py tests/functional/test_configuration.py tests/functional/test_debug.py tests/unit/test_command_show.py -q; uv run --with nox nox -s test-3.12 -- tests/functional/test_install.py::test_install_quiet -q; source-tree quiet smoke checks for list/show/cache/dry-run install.

Not-tested: Full CI matrix locally.
@ychampion
ychampion requested a review from sepehr-rs July 8, 2026 08:54

@sepehr-rs sepehr-rs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for addressing the review comments. I've left a couple more; let me know if you need any help with them.

Comment thread src/pip/_internal/commands/search.py Outdated
Comment thread src/pip/_internal/commands/show.py Outdated
Constraint: Address pip review comments without changing quiet-output behavior.
Rejected: Keep the helper parameter | It only forwarded a constant default and made the call site harder to read.
Confidence: high
Scope-risk: narrow
Directive: Keep quiet-mode bypass explicit at display-output write_output calls.
Tested: uv run --with pre-commit pre-commit run black --files src/pip/_internal/commands/search.py src/pip/_internal/commands/show.py; uv run --with pre-commit pre-commit run ruff-check --files src/pip/_internal/commands/search.py src/pip/_internal/commands/show.py; uv run --with nox nox -s test-3.12 -- tests/functional/test_show.py tests/functional/test_help.py tests/functional/test_index.py tests/functional/test_check.py tests/functional/test_list.py tests/functional/test_hash.py tests/functional/test_cache.py tests/functional/test_configuration.py tests/functional/test_debug.py tests/unit/test_command_show.py -q; PYTHONPATH=src python3 -m pip show --quiet pip; PYTHONPATH=src python3 -m pip help --quiet; PYTHONPATH=src python3 -m pip cache dir --quiet; direct search helper smoke.
Not-tested: Full CI matrix.
@sepehr-rs

Copy link
Copy Markdown
Member

Hey @notatallshaw, would you mind taking a look at this when you have a chance? You mentioned earlier that you'd be happy to review a PR for this issue if someone submitted one. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quiet option removes useful output

3 participants