Skip to content

Commit

Permalink
fix SnowballObject typing (#1449)
Browse files Browse the repository at this point in the history
Signed-off-by: Bala.FA <[email protected]>
  • Loading branch information
balamurugana authored Oct 24, 2024
1 parent 2d3982f commit 96212de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
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

0 comments on commit 96212de

Please sign in to comment.