Fix mypy errors from minio 7.2.20 type stubs.
Guard bucket_name before Minio API calls, update S3Error test mocks for the new constructor signature, and add types-redis to the pre-commit mypy hook. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
co-authored by
Cursor
parent
e3cab5e0b6
commit
0f31170209
@@ -131,7 +131,7 @@ class MinioAdapter(
|
||||
if not isinstance(content_type, str) or len(content_type) == 0:
|
||||
raise ValueError("content_type must be a non-empty string")
|
||||
# Check connection
|
||||
if self._client is None or not self.is_connected:
|
||||
if self._client is None or self._bucket_name is None or not self.is_connected:
|
||||
raise ConnectionError("Not connected to Minio")
|
||||
# Prepare buffer for reading
|
||||
num_bytes = data.getbuffer().nbytes
|
||||
@@ -156,7 +156,7 @@ class MinioAdapter(
|
||||
if not isinstance(object_name, str) or len(object_name) == 0:
|
||||
raise ValueError("object_name must be a non-empty string")
|
||||
# Check connection
|
||||
if self._client is None or not self.is_connected:
|
||||
if self._client is None or self._bucket_name is None or not self.is_connected:
|
||||
raise ConnectionError("Not connected to Minio")
|
||||
# Get data from bucket
|
||||
# N.B. bucket name is set when connecting
|
||||
@@ -191,7 +191,7 @@ class MinioAdapter(
|
||||
if not isinstance(object_name, str) or len(object_name) == 0:
|
||||
raise ValueError("object_name must be a non-empty string")
|
||||
# Check connection
|
||||
if self._client is None or not self.is_connected:
|
||||
if self._client is None or self._bucket_name is None or not self.is_connected:
|
||||
raise ConnectionError("Not connected to Minio")
|
||||
# Delete object from bucket
|
||||
# N.B. bucket name is set when connecting
|
||||
@@ -210,7 +210,7 @@ class MinioAdapter(
|
||||
raise ValueError("prefix must be a string")
|
||||
# Check connection
|
||||
# N.B. bucket name is set when connecting
|
||||
if self._client is None or not self.is_connected:
|
||||
if self._client is None or self._bucket_name is None or not self.is_connected:
|
||||
raise ConnectionError("Not connected to Minio")
|
||||
# List objects in bucket
|
||||
objects = self._client.list_objects(
|
||||
|
||||
Reference in New Issue
Block a user