Fix mypy errors from minio 7.2.20 type stubs.
Code Quality Pipeline / code-quality (pull_request) Successful in 36s
PR Title Check / check-title (pull_request) Failing after 6s
Test Python Package / test (pull_request) Successful in 43s

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:
Brian Bjarke Jensen
2026-06-28 23:32:31 +02:00
co-authored by Cursor
parent e3cab5e0b6
commit 0f31170209
3 changed files with 22 additions and 19 deletions
@@ -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(