Skip to content

Improve presentation of non-verbose downloads with non-PyPI indexes #13494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
7 changes: 3 additions & 4 deletions src/pip/_internal/network/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from pip._internal.cli.progress_bars import BarType, get_download_progress_renderer
from pip._internal.exceptions import IncompleteDownloadError, NetworkConnectionError
from pip._internal.models.index import PyPI
from pip._internal.models.link import Link
from pip._internal.network.cache import SafeFileCache, is_from_cache
from pip._internal.network.session import CacheControlAdapter, PipSession
Expand Down Expand Up @@ -51,10 +50,10 @@ def _log_download(
total_length: int | None,
range_start: int | None = 0,
) -> Iterable[bytes]:
if link.netloc == PyPI.file_storage_domain:
url = link.show_url
else:
if logger.getEffectiveLevel() > logging.INFO:
url = link.url_without_fragment
else:
url = link.show_url

logged_url = redact_auth_from_url(url)

Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_network_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@
{},
False,
None,
"Downloading http://example.com/foo.tgz",
"Downloading foo.tgz",
),
(
"http://example.com/foo.tgz",
{"content-length": "2"},
False,
None,
"Downloading http://example.com/foo.tgz (2 bytes)",
"Downloading foo.tgz (2 bytes)",
),
(
"http://example.com/foo.tgz",
{"content-length": "2"},
True,
None,
"Using cached http://example.com/foo.tgz (2 bytes)",
"Using cached foo.tgz (2 bytes)",
),
(
"https://files.pythonhosted.org/foo.tgz",
Expand Down Expand Up @@ -72,7 +72,7 @@
{"content-length": "200"},
False,
100,
"Resuming download http://example.com/foo.tgz (100 bytes/200 bytes)",
"Resuming download foo.tgz (100 bytes/200 bytes)",
),
],
)
Expand Down
Loading