Skip to content

Commit

Permalink
fix: support urllib3<2.0 versions
Browse files Browse the repository at this point in the history
  • Loading branch information
arithmetic1728 committed Sep 28, 2023
1 parent f33bb9d commit a3e7c66
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion google/auth/transport/urllib3.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,18 @@
"urllib3 package to use the urllib3 transport."
) from caught_exc

from packaging import version

from google.auth import environment_vars
from google.auth import exceptions
from google.auth import transport
from google.oauth2 import service_account

if version.parse(urllib3.__version__) >= version.parse("2.0.0"): # pragma: NO COVER
RequestMethods = urllib3._request_methods.RequestMethods
else: # pragma: NO COVER
RequestMethods = urllib3.request.RequestMethods

_LOGGER = logging.getLogger(__name__)


Expand Down Expand Up @@ -179,7 +186,7 @@ def _make_mutual_tls_http(cert, key):
return http


class AuthorizedHttp(urllib3._request_methods.RequestMethods): # type: ignore
class AuthorizedHttp(RequestMethods): # type: ignore
"""A urllib3 HTTP class with credentials.
This class is used to perform requests to API endpoints that require
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
# rsa==4.5 is the last version to support 2.7
# https://github.com/sybrenstuvel/python-rsa/issues/152#issuecomment-643470233
"rsa>=3.1.4,<5",
"urllib3>=2.0.5",
)

extras = {
Expand Down
1 change: 1 addition & 0 deletions testing/constraints-3.10.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
urllib3<2.0.0
1 change: 1 addition & 0 deletions testing/constraints-3.11.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
urllib3>2.0.0

0 comments on commit a3e7c66

Please sign in to comment.