Skip to content
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

ZipFile.open() return type #13051

Open
AT0myks opened this issue Nov 20, 2024 · 1 comment
Open

ZipFile.open() return type #13051

AT0myks opened this issue Nov 20, 2024 · 1 comment
Labels
topic: io I/O related issues

Comments

@AT0myks
Copy link

AT0myks commented Nov 20, 2024

ZipFile.open() returns an instance of ZipExtFile if mode='r' and an instance of _ZipWriteFile if mode='w', but in typeshed its return type is IO[bytes].

def open(
self, name: str | ZipInfo, mode: _ReadWriteMode = "r", pwd: bytes | None = None, *, force_zip64: bool = False
) -> IO[bytes]: ...

Is this on purpose? Would it be possible instead to have an overload for each case?

@AlexWaygood AlexWaygood added the topic: io I/O related issues label Nov 20, 2024
@srittau
Copy link
Collaborator

srittau commented Nov 20, 2024

Generally nowadays IO return types are a bit frowned upon in typeshed (at least by me). I'm actually on a snail-like long-term mission to eliminate IO in typeshed where possible. So any improvements here are very welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: io I/O related issues
Projects
None yet
Development

No branches or pull requests

3 participants