Skip to content

Commit

Permalink
Fix type annotations in remove_objects and upload_snowball_objects
Browse files Browse the repository at this point in the history
The delete_object_list argument was annotated as
"Iterator[DeleteObject]". This means that mypy would complain if
client code passes a list of DeleteObject-s to remove_objects.

But in practice passing in a list works: the delete_objects function
later converts the list to an iterator using "itertools.chain".

I changed the type annotation to "Iterable[DeleteObject]". This way,
mypy is happy if we pass an iterator, and when we pass a list.

(And same thing in upload_snowball_objects)
  • Loading branch information
cuu508 committed Jan 4, 2024
1 parent 830a114 commit 36e8631
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions minio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import itertools
import os
import tarfile
from collections.abc import Iterable
from datetime import datetime, timedelta
from io import BytesIO
from random import random
Expand Down Expand Up @@ -2139,7 +2140,7 @@ def _delete_objects(
def remove_objects(
self,
bucket_name: str,
delete_object_list: Iterator[DeleteObject],
delete_object_list: Iterable[DeleteObject],
bypass_governance_mode: bool = False,
) -> Iterator[DeleteError]:
"""
Expand Down Expand Up @@ -2946,7 +2947,7 @@ def set_object_retention(
def upload_snowball_objects(
self,
bucket_name: str,
object_list: Iterator[SnowballObject],
object_list: Iterable[SnowballObject],
metadata: DictType | None = None,
sse: Sse | None = None,
tags: Tags | None = None,
Expand Down

0 comments on commit 36e8631

Please sign in to comment.