-
Notifications
You must be signed in to change notification settings - Fork 103
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
Replace BinaryIO with IO[bytes] #644
Conversation
From my understanding, python/typing#829 recommends using protocols for function arguments. |
aiodocker/utils.py
Outdated
@@ -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]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what to use here as Tarfile.gettarinfo
expects fileobj as BytesIO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let's keep BytesIO
if there is no choice.
I can recommend making a PR for typeshed; they accept corrections easily and quickly if a patch is correct.
aiodocker/utils.py
Outdated
@@ -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]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let's keep BytesIO
if there is no choice.
I can recommend making a PR for typeshed; they accept corrections easily and quickly if a patch is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to revisit the test suite (#849), so I'm going to merge this first and do follow-ups.
What do these changes do?
Replace
BinaryIO
withIO[bytes]
So
mktar_from_dockerfile
should takefileobj
asUnion[BytesIO, IO[bytes]]
(IO[bytes]
forelse
case) and returnIO[bytes]
because there is not any case with returningIO[str]
. Alsodocker.images.build
should also takefileobj
asIO[bytes]
There is also a discussion about
typing.IO
: python/typing#829, so protocols are useless due to the amount of use.Are there changes in behavior for the user?
Related issue number
Checklist
CONTRIBUTORS.txt
changes
folder<issue_id>.<type>
for example (588.bug)issue_id
change it to the pr id after creating the pr.feature
: Signifying a new feature..bugfix
: Signifying a bug fix..doc
: Signifying a documentation improvement..removal
: Signifying a deprecation or removal of public API..misc
: A ticket has been closed, but it is not of interest to users.