Skip to content

Commit

Permalink
Replace BinaryIO with IO[bytes]
Browse files Browse the repository at this point in the history
  • Loading branch information
q0w committed Nov 14, 2021
1 parent decc34c commit a0477b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
10 changes: 5 additions & 5 deletions aiodocker/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import json
import warnings
from typing import (
IO,
Any,
AsyncIterator,
BinaryIO,
Dict,
List,
Mapping,
Expand Down Expand Up @@ -230,7 +230,7 @@ async def delete(
)

@staticmethod
async def _stream(fileobj: BinaryIO) -> AsyncIterator[bytes]:
async def _stream(fileobj: IO[bytes]) -> AsyncIterator[bytes]:
chunk = fileobj.read(io.DEFAULT_BUFFER_SIZE)
while chunk:
yield chunk
Expand All @@ -241,7 +241,7 @@ async def build(
self,
*,
remote: str = None,
fileobj: BinaryIO = None,
fileobj: IO[bytes] = None,
path_dockerfile: str = None,
tag: str = None,
quiet: bool = False,
Expand All @@ -261,7 +261,7 @@ def build(
self,
*,
remote: str = None,
fileobj: BinaryIO = None,
fileobj: IO[bytes] = None,
path_dockerfile: str = None,
tag: str = None,
quiet: bool = False,
Expand All @@ -280,7 +280,7 @@ def build( # noqa: F811
self,
*,
remote: str = None,
fileobj: BinaryIO = None,
fileobj: IO[bytes] = None,
path_dockerfile: str = None,
tag: str = None,
quiet: bool = False,
Expand Down
16 changes: 3 additions & 13 deletions aiodocker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,7 @@
import tarfile
import tempfile
from io import BytesIO
from typing import (
IO,
Any,
BinaryIO,
Iterable,
Mapping,
MutableMapping,
Optional,
Tuple,
Union,
)
from typing import IO, Any, Iterable, Mapping, MutableMapping, Optional, Tuple, Union


async def parse_result(response, response_type=None, *, encoding="utf-8"):
Expand Down Expand Up @@ -227,12 +217,12 @@ def clean_filters(filters: Mapping = None) -> str:
return json.dumps(filters)


def mktar_from_dockerfile(fileobject: BinaryIO) -> IO:
def mktar_from_dockerfile(fileobject: Union[BytesIO, IO[bytes]]) -> IO[bytes]:
"""
Create a zipped tar archive from a Dockerfile
**Remember to close the file object**
Args:
fileobj: a Dockerfile
fileobject: a Dockerfile
Returns:
a NamedTemporaryFile() object
"""
Expand Down

0 comments on commit a0477b8

Please sign in to comment.