mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-21 03:11:16 +08:00
Make typing.IO inherit Iterator, not Iterable (#502)
In Python, it's possible to use the `next` builtin method on file objects produced by `open`. This change modifies `typing.IO` so this usage will successfully typecheck.
This commit is contained in:
committed by
Guido van Rossum
parent
5e5b3726f2
commit
97bc450acd
@@ -208,7 +208,7 @@ Text = unicode
|
||||
|
||||
TYPE_CHECKING = True
|
||||
|
||||
class IO(Iterable[AnyStr], Generic[AnyStr]):
|
||||
class IO(Iterator[AnyStr], Generic[AnyStr]):
|
||||
# TODO detach
|
||||
# TODO use abstract properties
|
||||
@property
|
||||
@@ -250,6 +250,8 @@ class IO(Iterable[AnyStr], Generic[AnyStr]):
|
||||
@abstractmethod
|
||||
def writelines(self, lines: Iterable[AnyStr]) -> None: ...
|
||||
|
||||
@abstractmethod
|
||||
def next(self) -> AnyStr: ...
|
||||
@abstractmethod
|
||||
def __iter__(self) -> Iterator[AnyStr]: ...
|
||||
@abstractmethod
|
||||
|
||||
Reference in New Issue
Block a user