python / python/typeshed

Introduce a protocol for `ZipFile.__init__`'s `file` parameter

Open
#10,880 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: io
Dominant language
Python
Stars
5.1k
Forks
2.1k
Avg merge
1d 19h
Merged PRs (30d)
82

Description

See https://github.com/python/typeshed/pull/10706#discussion_r1334909767
The file parameter in ZipFile.__init__ is typed as StrPath | IO[bytes]. IO[bytes] is incorrect here, but the correct protocol might be a bit complex and not something I feel like launching myself into right now. So I'm opening this issue so we don't forget.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked typeshed pull request discussion and the stub entry for ZipFile.init; determine the protocol required for its file parameter and why IO[bytes] is incorrect. Done means replacing that annotation with the appropriate protocol while preserving support for StrPath and file-like inputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.