Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix SnowballObject typing #1449

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions minio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from datetime import datetime, timedelta
from io import BytesIO
from random import random
from typing import IO, BinaryIO, Iterator, TextIO, Tuple, Union, cast
from typing import BinaryIO, Iterator, TextIO, Tuple, Union, cast
from urllib.parse import urlunsplit
from xml.etree import ElementTree as ET

Expand Down Expand Up @@ -3020,7 +3020,7 @@ def upload_snowball_objects(
info.mtime = int(
time.to_float(obj.mod_time or time.utcnow()),
)
tar.addfile(info, cast(Union[IO[bytes], None], obj.data))
tar.addfile(info, obj.data)

if not name:
length = cast(BytesIO, fileobj).tell()
Expand Down
8 changes: 5 additions & 3 deletions minio/commonconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from abc import ABCMeta
from datetime import datetime
from typing import Type, TypeVar, cast
from typing import IO, Type, TypeVar, cast
from xml.etree import ElementTree as ET

from .error import MinioException
Expand Down Expand Up @@ -533,7 +533,7 @@ def __init__(
self,
object_name: str,
filename: str | None = None,
data: bytes | None = None,
data: IO[bytes] | None = None,
length: int | None = None,
mod_time: datetime | None = None,
):
Expand All @@ -544,6 +544,8 @@ def __init__(
self._length = length
else:
raise ValueError("only one of filename or data must be provided")
if data is not None and length is None:
raise ValueError("length must be provided for data")
if mod_time is not None and not isinstance(mod_time, datetime):
raise ValueError("mod_time must be datetime type")
self._mod_time = mod_time
Expand All @@ -559,7 +561,7 @@ def filename(self) -> str | None:
return self._filename

@property
def data(self) -> bytes | None:
def data(self) -> IO[bytes] | None:
"""Get data."""
return self._data

Expand Down
Loading