Skip to content

Commit 07c464a

Browse files
fix: support urllib3<2.0 versions (#1390)
* fix: support urllib3<2.0 versions * update
1 parent f33bb9d commit 07c464a

File tree

5 files changed

+10
-2
lines changed

5 files changed

+10
-2
lines changed

google/auth/transport/urllib3.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,18 @@
4040
"urllib3 package to use the urllib3 transport."
4141
) from caught_exc
4242

43+
from packaging import version # type: ignore
44+
4345
from google.auth import environment_vars
4446
from google.auth import exceptions
4547
from google.auth import transport
4648
from google.oauth2 import service_account
4749

50+
if version.parse(urllib3.__version__) >= version.parse("2.0.0"): # pragma: NO COVER
51+
RequestMethods = urllib3._request_methods.RequestMethods # type: ignore
52+
else: # pragma: NO COVER
53+
RequestMethods = urllib3.request.RequestMethods # type: ignore
54+
4855
_LOGGER = logging.getLogger(__name__)
4956

5057

@@ -179,7 +186,7 @@ def _make_mutual_tls_http(cert, key):
179186
return http
180187

181188

182-
class AuthorizedHttp(urllib3._request_methods.RequestMethods): # type: ignore
189+
class AuthorizedHttp(RequestMethods): # type: ignore
183190
"""A urllib3 HTTP class with credentials.
184191
185192
This class is used to perform requests to API endpoints that require

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
# rsa==4.5 is the last version to support 2.7
2626
# https://github.com/sybrenstuvel/python-rsa/issues/152#issuecomment-643470233
2727
"rsa>=3.1.4,<5",
28-
"urllib3>=2.0.5",
2928
)
3029

3130
extras = {

system_tests/secrets.tar.enc

0 Bytes
Binary file not shown.

testing/constraints-3.10.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
urllib3<2.0.0

testing/constraints-3.11.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
urllib3>2.0.0

0 commit comments

Comments
 (0)