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
1diff --git a/lib/lp/oci/model/ociregistryclient.py b/lib/lp/oci/model/ociregistryclient.py
2index 30a99ad..e04a17a 100644
3--- a/lib/lp/oci/model/ociregistryclient.py
4+++ b/lib/lp/oci/model/ociregistryclient.py
5@@ -23,11 +23,8 @@ from requests.exceptions import (
6 ConnectionError,
7 HTTPError,
8 )
9+from requests.utils import parse_dict_header
10 from six.moves.urllib.parse import urlparse
11-from six.moves.urllib.request import (
12- parse_http_list,
13- parse_keqv_list,
14- )
15 from tenacity import (
16 before_log,
17 retry,
18@@ -707,7 +704,7 @@ class BearerTokenRegistryClient(RegistryHTTPClient):
19 parameters of the token GET request."""
20 instructions = request.headers['Www-Authenticate']
21 token_type, values = instructions.split(' ', 1)
22- dict_values = parse_keqv_list(parse_http_list(values))
23+ dict_values = parse_dict_header(values)
24 return token_type, dict_values
25
26 def authenticate(self, last_failed_request):

Subscribers

People subscribed via source and target branches

to status/vote changes: