From 4c8182b2e389eff6c6e5f059b7dd8ea05748d194 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Mon, 12 Sep 2022 00:25:16 +0300 Subject: [PATCH] Use `@abstractmethod` for abstract properties in `typing` Source: https://github.com/python/cpython/blame/53a54b781d1f05f2d0b40ce88b3da92d5d23e9d2/Lib/typing.py#L3167-L3297 --- stdlib/typing.pyi | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 81ba341044d5..e3c82c6b8bcc 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -637,14 +637,16 @@ TYPE_CHECKING: bool # 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 + @abstractmethod def mode(self) -> str: ... @property + @abstractmethod def name(self) -> str: ... @abstractmethod def close(self) -> None: ... @property + @abstractmethod def closed(self) -> bool: ... @abstractmethod def fileno(self) -> int: ... @@ -690,16 +692,20 @@ class BinaryIO(IO[bytes]): def __enter__(self) -> BinaryIO: ... class TextIO(IO[str]): - # TODO use abstractproperty @property + @abstractmethod def buffer(self) -> BinaryIO: ... @property + @abstractmethod def encoding(self) -> str: ... @property + @abstractmethod def errors(self) -> str | None: ... @property + @abstractmethod def line_buffering(self) -> int: ... # int on PyPy, bool on CPython @property + @abstractmethod def newlines(self) -> Any: ... # None, str or tuple @abstractmethod def __enter__(self) -> TextIO: ...