-
-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix sorting of proxy_map in PDMPyPIClient
Sort proxy_map after constructing URLPatterns. URLPattern has logic to make more specific patterns sort first. Current code instead sorts URLs as strings, which orders them lexicographically. This means that URLs from `no_proxy` usually sort *after* URLs from `all_proxy` and so `no_proxy` settings have no effect. Fixes #3254
- Loading branch information
Showing
3 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix using `no_proxy` when `all_proxy` is set. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from pdm.project.core import Project | ||
|
||
|
||
def test_session_sources_all_proxy(project: Project, mocker, monkeypatch): | ||
monkeypatch.setenv("all_proxy", "http://localhost:8888") | ||
mock_get_transport = mocker.patch("pdm.models.session._get_transport") | ||
|
||
assert project.environment.session is not None | ||
transport_args = mock_get_transport.call_args | ||
assert transport_args is not None | ||
assert transport_args.kwargs["proxy"].url == "http://localhost:8888" | ||
|
||
monkeypatch.setenv("no_proxy", "pypi.org") | ||
mock_get_transport.reset_mock() | ||
del project.environment.session | ||
assert project.environment.session is not None | ||
transport_args = mock_get_transport.call_args | ||
assert transport_args is not None | ||
assert transport_args.kwargs["proxy"] is None |