Merge ~cjwatson/launchpad:avoid-private-urllib-request-functions into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 201819ab7eb4e8e565771b8a4be4b11c31ef7a03
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:avoid-private-urllib-request-functions
Merge into: launchpad:master
Diff against target: 26 lines (+2/-5)
1 file modified
lib/lp/oci/model/ociregistryclient.py (+2/-5)
Reviewer Review Type Date Requested Status
Guruprasad Approve
Review via email: mp+420297@code.launchpad.net

Commit message

Avoid importing private urllib.request names

Description of the change

`urllib.request` defines an `__all__` list that doesn't include `parse_http_list` or `parse_keqv_list`, so we get import pedant warnings once we start importing these directly from `urllib.request` rather than via `six`. Use the equivalent (and slightly simpler to use) `requests.utils.parse_dict_header` instead.

To post a comment you must log in.
Revision history for this message
Guruprasad (lgp171188) wrote :

LGTM 👍

Revision history for this message
Guruprasad (lgp171188) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lib/lp/oci/model/ociregistryclient.py b/lib/lp/oci/model/ociregistryclient.py
index 30a99ad..e04a17a 100644
--- a/lib/lp/oci/model/ociregistryclient.py
+++ b/lib/lp/oci/model/ociregistryclient.py
@@ -23,11 +23,8 @@ from requests.exceptions import (
23 ConnectionError,23 ConnectionError,
24 HTTPError,24 HTTPError,
25 )25 )
26from requests.utils import parse_dict_header
26from six.moves.urllib.parse import urlparse27from six.moves.urllib.parse import urlparse
27from six.moves.urllib.request import (
28 parse_http_list,
29 parse_keqv_list,
30 )
31from tenacity import (28from tenacity import (
32 before_log,29 before_log,
33 retry,30 retry,
@@ -707,7 +704,7 @@ class BearerTokenRegistryClient(RegistryHTTPClient):
707 parameters of the token GET request."""704 parameters of the token GET request."""
708 instructions = request.headers['Www-Authenticate']705 instructions = request.headers['Www-Authenticate']
709 token_type, values = instructions.split(' ', 1)706 token_type, values = instructions.split(' ', 1)
710 dict_values = parse_keqv_list(parse_http_list(values))707 dict_values = parse_dict_header(values)
711 return token_type, dict_values708 return token_type, dict_values
712709
713 def authenticate(self, last_failed_request):710 def authenticate(self, last_failed_request):

Subscribers

People subscribed via source and target branches

to status/vote changes: