Skip to content

Use IO instead of BytesIO/TextIO #1495

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions minio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from datetime import datetime, timedelta
from io import BytesIO
from random import random
from typing import Any, BinaryIO, Iterator, TextIO, Tuple, Union, cast
from typing import IO, Any, Iterator, Tuple, Union, cast
from urllib.parse import urlunsplit
from xml.etree import ElementTree as ET

Expand Down Expand Up @@ -128,7 +128,7 @@ class Minio:
_region_map: dict[str, str]
_base_url: BaseURL
_user_agent: str
_trace_stream: TextIO | None
_trace_stream: IO[str] | None
_provider: Provider | None
_http: urllib3.PoolManager

Expand Down Expand Up @@ -525,7 +525,7 @@ def set_app_info(self, app_name: str, app_version: str):
raise ValueError("Application name/version cannot be empty.")
self._user_agent = f"{_DEFAULT_USER_AGENT} {app_name}/{app_version}"

def trace_on(self, stream: TextIO):
def trace_on(self, stream: IO[str]):
"""
Enable http trace.

Expand Down Expand Up @@ -1826,7 +1826,7 @@ def put_object(
self,
bucket_name: str,
object_name: str,
data: BinaryIO,
data: IO[bytes],
length: int,
content_type: str = "application/octet-stream",
metadata: DictType | None = None,
Expand Down Expand Up @@ -3129,7 +3129,7 @@ def upload_snowball_objects(
return self.put_object(
bucket_name,
object_name,
cast(BinaryIO, fileobj),
cast("IO[bytes]", fileobj),
length,
metadata=cast(Union[DictType, None], metadata),
sse=sse,
Expand Down
4 changes: 2 additions & 2 deletions minio/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from datetime import datetime
from queue import Queue
from threading import BoundedSemaphore, Thread
from typing import BinaryIO, Dict, List, Mapping, Tuple, Union
from typing import IO, Dict, List, Mapping, Tuple, Union

from typing_extensions import Protocol
from urllib3._collections import HTTPHeaderDict
Expand Down Expand Up @@ -191,7 +191,7 @@ def update(self, length: int):


def read_part_data(
stream: BinaryIO,
stream: IO[bytes],
size: int,
part_data: bytes = b"",
progress: ProgressType | None = None,
Expand Down