Skip to content

Commit

Permalink
Make urllib3 v1 compatible
Browse files Browse the repository at this point in the history
Signed-off-by: Bala.FA <[email protected]>
  • Loading branch information
balamurugana committed Dec 29, 2023
1 parent cdf8553 commit 427d782
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 7 deletions.
7 changes: 6 additions & 1 deletion minio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@
import urllib3
from urllib3 import Retry
from urllib3._collections import HTTPHeaderDict
from urllib3.response import BaseHTTPResponse

try:
from urllib3.response import BaseHTTPResponse # type: ignore[attr-defined]
except ImportError:
from urllib3.response import HTTPResponse as BaseHTTPResponse

from urllib3.util import Timeout

from . import __title__, __version__, time
Expand Down
10 changes: 9 additions & 1 deletion minio/credentials/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@

import certifi
from urllib3.poolmanager import PoolManager
from urllib3.response import BaseHTTPResponse

try:
from urllib3.response import BaseHTTPResponse # type: ignore[attr-defined]
except ImportError:
from urllib3.response import HTTPResponse as BaseHTTPResponse

from urllib3.util import Retry, parse_url

from minio.helpers import sha256_hash
Expand Down Expand Up @@ -459,6 +464,9 @@ def retrieve(self) -> Credentials:
raise ValueError(f"no IAM roles attached to EC2 service {url}")
url += "/" + role_names[0].strip("\r")

if not url:
raise ValueError("url is empty; this should not happen")

self._credentials = self.fetch(url)
return self._credentials

Expand Down
6 changes: 5 additions & 1 deletion minio/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
from Crypto.Cipher import AES, ChaCha20_Poly1305
from Crypto.Cipher._mode_gcm import GcmMode
from Crypto.Cipher.ChaCha20_Poly1305 import ChaCha20Poly1305Cipher
from urllib3.response import BaseHTTPResponse

try:
from urllib3.response import BaseHTTPResponse # type: ignore[attr-defined]
except ImportError:
from urllib3.response import HTTPResponse as BaseHTTPResponse

#
# Encrypted Message Format:
Expand Down
6 changes: 5 additions & 1 deletion minio/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@
from xml.etree import ElementTree as ET

from urllib3._collections import HTTPHeaderDict
from urllib3.response import BaseHTTPResponse

try:
from urllib3.response import BaseHTTPResponse # type: ignore[attr-defined]
except ImportError:
from urllib3.response import HTTPResponse as BaseHTTPResponse

from .credentials import Credentials
from .helpers import check_bucket_name
Expand Down
5 changes: 4 additions & 1 deletion minio/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
from typing import Type, TypeVar
from xml.etree import ElementTree as ET

from urllib3.response import BaseHTTPResponse
try:
from urllib3.response import BaseHTTPResponse # type: ignore[attr-defined]
except ImportError:
from urllib3.response import HTTPResponse as BaseHTTPResponse

from .xml import findtext

Expand Down
7 changes: 6 additions & 1 deletion minio/minioadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
from urllib3 import Retry
from urllib3._collections import HTTPHeaderDict
from urllib3.poolmanager import PoolManager
from urllib3.response import BaseHTTPResponse

try:
from urllib3.response import BaseHTTPResponse # type: ignore[attr-defined]
except ImportError:
from urllib3.response import HTTPResponse as BaseHTTPResponse

from urllib3.util import Timeout

from . import time
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
long_description_content_type="text/markdown",
package_dir={"minio": "minio"},
packages=["minio", "minio.credentials"],
install_requires=["certifi", "urllib3>=2.0", "argon2-cffi",
install_requires=["certifi", "urllib3", "argon2-cffi",
"pycryptodome", "typing-extensions"],
tests_require=[],
license="Apache-2.0",
Expand Down

0 comments on commit 427d782

Please sign in to comment.