8000 Turn TextIOWrapper(buffer) into a protocol by srittau · Pull Request #11420 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

Turn TextIOWrapper(buffer) into a protocol #11420

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 16 commits into from
Feb 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use ReadableBuffer
  • Loading branch information
srittau committed Feb 14, 2024
commit 4c12b2db6ac271ebdf64bf07263f7bdf854c5fc2
4 changes: 2 additions & 2 deletions stdlib/io.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ class _WrappedBuffer(Protocol):
def name(self) -> Any: ...
@property
def closed(self) -> bool: ...
def read(self, size: int = ..., /) -> bytes: ...
# Optional: def read1(self, size: int, /) -> bytes: ...
def read(self, size: int = ..., /) -> ReadableBuffer: ...
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def read(self, size: int = ..., /) -> ReadableBuffer: ...
def read(self, size: int, /) -> ReadableBuffer: ...

It always calls read with an argument. Note this change makes the protocol more permissive.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to desc 8E0F ribe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a comment linking to that line in the source code?

# Optional: def read1(self, size: int, /) -> ReadableBuffer: ...
def write(self, b: bytes, /) -> object: ...
def flush(self) -> object: ...
def close(self) -> object: ...
Expand Down
0