Use positional-only arguments for IO (#6851)

This commit is contained in:
Sebastian Rittau
2022-01-08 19:49:29 +01:00
committed by GitHub
parent 267bb2485a
commit f4ce1ebaf8
4 changed files with 25 additions and 10 deletions

View File

@@ -499,6 +499,9 @@ Text = str
TYPE_CHECKING = True
# In stubs, the arguments of the IO class are marked as positional-only.
# This differs from runtime, but better reflects the fact that in reality
# classes deriving from IO use different names for the arguments.
class IO(Iterator[AnyStr], Generic[AnyStr]):
# TODO use abstract properties
@property
@@ -516,27 +519,27 @@ class IO(Iterator[AnyStr], Generic[AnyStr]):
@abstractmethod
def isatty(self) -> bool: ...
@abstractmethod
def read(self, n: int = ...) -> AnyStr: ...
def read(self, __n: int = ...) -> AnyStr: ...
@abstractmethod
def readable(self) -> bool: ...
@abstractmethod
def readline(self, limit: int = ...) -> AnyStr: ...
def readline(self, __limit: int = ...) -> AnyStr: ...
@abstractmethod
def readlines(self, hint: int = ...) -> list[AnyStr]: ...
def readlines(self, __hint: int = ...) -> list[AnyStr]: ...
@abstractmethod
def seek(self, offset: int, whence: int = ...) -> int: ...
def seek(self, __offset: int, __whence: int = ...) -> int: ...
@abstractmethod
def seekable(self) -> bool: ...
@abstractmethod
def tell(self) -> int: ...
@abstractmethod
def truncate(self, size: int | None = ...) -> int: ...
def truncate(self, __size: int | None = ...) -> int: ...
@abstractmethod
def writable(self) -> bool: ...
@abstractmethod
def write(self, s: AnyStr) -> int: ...
def write(self, __s: AnyStr) -> int: ...
@abstractmethod
def writelines(self, lines: Iterable[AnyStr]) -> None: ...
def writelines(self, __lines: Iterable[AnyStr]) -> None: ...
@abstractmethod
def __next__(self) -> AnyStr: ...
@abstractmethod
@@ -545,7 +548,7 @@ class IO(Iterator[AnyStr], Generic[AnyStr]):
def __enter__(self) -> IO[AnyStr]: ...
@abstractmethod
def __exit__(
self, t: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
self, __t: Type[BaseException] | None, __value: BaseException | None, __traceback: TracebackType | None
) -> bool | None: ...
class BinaryIO(IO[bytes]):