Skip to content

Make link logging more consistent #10276

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

Closed
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
1 change: 1 addition & 0 deletions news/7390.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enhance the log message while downloading a pip file
7 changes: 1 addition & 6 deletions src/pip/_internal/network/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from pip._internal.cli.progress_bars import DownloadProgressProvider
from pip._internal.exceptions import NetworkConnectionError
from pip._internal.models.index import PyPI
from pip._internal.models.link import Link
from pip._internal.network.cache import is_from_cache
from pip._internal.network.session import PipSession
Expand All @@ -34,11 +33,7 @@ def _prepare_download(
) -> Iterable[bytes]:
total_length = _get_http_response_size(resp)

if link.netloc == PyPI.file_storage_domain:
url = link.show_url
else:
url = link.url_without_fragment

url = link.show_url
logged_url = redact_auth_from_url(url)

if total_length:
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 @@ -14,17 +14,17 @@

@pytest.mark.parametrize("url, headers, from_cache, expected", [
('http://example.com/foo.tgz', {}, False,
"Downloading http://example.com/foo.tgz"),
"Downloading foo.tgz"),
('http://example.com/foo.tgz', {'content-length': 2}, False,
"Downloading http://example.com/foo.tgz (2 bytes)"),
"Downloading foo.tgz (2 bytes)"),
('http://example.com/foo.tgz', {'content-length': 2}, True,
"Using cached http://example.com/foo.tgz (2 bytes)"),
"Using cached foo.tgz (2 bytes)"),
('https://files.pythonhosted.org/foo.tgz', {}, False,
"Downloading foo.tgz"),
('https://files.pythonhosted.org/foo.tgz', {'content-length': 2}, False,
"Downloading foo.tgz (2 bytes)"),
('https://files.pythonhosted.org/foo.tgz', {'content-length': 2}, True,
"Using cached foo.tgz"),
"Using cached foo.tgz (2 bytes)"),
])
def test_prepare_download__log(caplog, url, headers, from_cache, expected):
caplog.set_level(logging.INFO)
Expand Down