10000 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
Show file tree
Hide file tree
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
Make FileIO compatible
  • Loading branch information
srittau committed Feb 14, 2024
commit ad8461f2b51f95efe5a3a2c125d707bb89a18e6c
5 changes: 4 additions & 1 deletion stdlib/io.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ class BufferedIOBase(IOBase):

class FileIO(RawIOBase, BinaryIO): # type: ignore[misc] # incompatible definitions of writelines in the base classes
mode: str
name: FileDescriptorOrPath
# The type of "name" equals the argument passed in to the constructor,
# but that can make FileIO incompatible with other I/O types that assume
# "name" is a str. In the future, making FileIO generic might help.
name: Any
def __init__(
self, file: FileDescriptorOrPath, mode: str = ..., closefd: bool = ..., opener: _Opener | None = ...
) -> None: ...
Expand Down
4 changes: 3 additions & 1 deletion test_cases/stdlib/check_io.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from gzip import GzipFile
from io import TextIOWrapper
from io import FileIO, TextIOWrapper

TextIOWrapper(FileIO(""))
TextIOWrapper(FileIO(13))
TextIOWrapper(GzipFile(""))
0