Add typing.Reader and typing.Writer
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 302
- Avg merge
- 23h
- Merged PRs (30d)
- 8
Description
I recently stumbled at a TODO in typeshed that proposes to split IO[AnyStr] into smaller pieces. I think it is a good idea and propose to add two protocols:
class Reader(Protocol[AnyStr]):
def read(self, n: int = ...) -> AnyStr: ...
def readlines(self) -> List[AnyStr]: ...
def close(self) -> None: ...
class Writer(Protocol[AnyStr]):
def write(self, s: AnyStr) -> int: ...
def writelines(self, lines: List[AnyStr]) -> None: ...
def close(self) -> None: ...
Then IO[AnyStr] can subclass both, plus add some less often used methods (also IO should stay nominal). What do you think?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the referenced TODO in typeshed and review the existing definition of typing.IO. Compare the proposed Reader and Writer protocols with IO's less frequently used methods and the requirement that IO remain nominal; done means reaching agreement on the protocol design and documenting or implementing the accepted change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100