diff --git a/src/pip/_internal/network/download.py b/src/pip/_internal/network/download.py index 9881cc285fa..d607554cd5f 100644 --- a/src/pip/_internal/network/download.py +++ b/src/pip/_internal/network/download.py @@ -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 @@ -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) diff --git a/tests/unit/test_network_download.py b/tests/unit/test_network_download.py index 7fb6b7fe64b..0f08d8010c3 100644 --- a/tests/unit/test_network_download.py +++ b/tests/unit/test_network_download.py @@ -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", @@ -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)", ), ], )