Skip to content

Use protocols for gzip and _compression #5170

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

Merged
merged 3 commits into from
Apr 8, 2021
Merged

Conversation

srittau
Copy link
Collaborator

@srittau srittau commented Apr 1, 2021

Closes: #5099

compresslevel: int = ...,
fileobj: Optional[IO[bytes]] = ...,
fileobj: Union[_ReadableFileobj, _WritableFileobj, None] = ...,
mtime: Optional[float] = ...,
) -> None: ...
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible to add more overloads to check filename/fileobj, but that could be done in a separate PR.

@github-actions

This comment has been minimized.

@srittau
Copy link
Collaborator Author

srittau commented Apr 1, 2021

It's a bit strange that the mypy_primer run after the last PR shows no diff. I'd have expected the scrapy warnings to still be present (they point to a genuine problem), same with the now obsolete # type: ignore comment in pandas.

Comment on lines 126 to +128
mode: Optional[str] = ...,
compresslevel: int = ...,
fileobj: Optional[IO[bytes]] = ...,
fileobj: Union[_ReadableFileobj, _WritableFileobj, None] = ...,
Copy link
Collaborator

@Akuli Akuli Apr 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This overload allows basically anything for mode and fileobj, including invalid combinations, such as "w" with a readable file object. Ideally there would be a way to say "use this overload only if mode is not a Literal", but I don't think there's anything like that.

@JelleZijlstra JelleZijlstra merged commit 9fbcc6c into python:master Apr 8, 2021
@srittau srittau deleted the gzip branch April 8, 2021 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use protocol for GzipFile fileobj parameter
3 participants