-
Notifications
You must be signed in to change notification settings - Fork 267
Open
Labels
topic: featureDiscussions about new features for Python's type annotationsDiscussions about new features for Python's type annotations
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?
srittau, mr-c, andreymal, m-aciek, nkonin and 3 more
Metadata
Metadata
Assignees
Labels
topic: featureDiscussions about new features for Python's type annotationsDiscussions about new features for Python's type annotations