Skip to content

Commit 96212de

Browse files
authored
fix SnowballObject typing (#1449)
Signed-off-by: Bala.FA <[email protected]>
1 parent 2d3982f commit 96212de

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

minio/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from datetime import datetime, timedelta
3535
from io import BytesIO
3636
from random import random
37-
from typing import IO, BinaryIO, Iterator, TextIO, Tuple, Union, cast
37+
from typing import BinaryIO, Iterator, TextIO, Tuple, Union, cast
3838
from urllib.parse import urlunsplit
3939
from xml.etree import ElementTree as ET
4040

@@ -3020,7 +3020,7 @@ def upload_snowball_objects(
30203020
info.mtime = int(
30213021
time.to_float(obj.mod_time or time.utcnow()),
30223022
)
3023-
tar.addfile(info, cast(Union[IO[bytes], None], obj.data))
3023+
tar.addfile(info, obj.data)
30243024

30253025
if not name:
30263026
length = cast(BytesIO, fileobj).tell()

minio/commonconfig.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
from abc import ABCMeta
2323
from datetime import datetime
24-
from typing import Type, TypeVar, cast
24+
from typing import IO, Type, TypeVar, cast
2525
from xml.etree import ElementTree as ET
2626

2727
from .error import MinioException
@@ -533,7 +533,7 @@ def __init__(
533533
self,
534534
object_name: str,
535535
filename: str | None = None,
536-
data: bytes | None = None,
536+
data: IO[bytes] | None = None,
537537
length: int | None = None,
538538
mod_time: datetime | None = None,
539539
):
@@ -544,6 +544,8 @@ def __init__(
544544
self._length = length
545545
else:
546546
raise ValueError("only one of filename or data must be provided")
547+
if data is not None and length is None:
548+
raise ValueError("length must be provided for data")
547549
if mod_time is not None and not isinstance(mod_time, datetime):
548550
raise ValueError("mod_time must be datetime type")
549551
self._mod_time = mod_time
@@ -559,7 +561,7 @@ def filename(self) -> str | None:
559561
return self._filename
560562

561563
@property
562-
def data(self) -> bytes | None:
564+
def data(self) -> IO[bytes] | None:
563565
"""Get data."""
564566
return self._data
565567

0 commit comments

Comments
 (0)