From 928f0063184014fccb28f998d6834f8c1d2af705 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 17 Oct 2022 11:44:40 +0100 Subject: [PATCH] `typing.pyi`: Improve comments for `IO`/`TextIO` (#8913) #8726 proposed to make these properties abstract, but it would have broken half the typed-Python ecosystem, and we've since decided that it's not worth taking action on this (https://github.com/python/typeshed/issues/2146#event-7450564547). This PR rephrases the comments to make clear that there isn't really anything actionable that can be done here. --- stdlib/typing.pyi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 954f47d14..53bfccd74 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -638,7 +638,9 @@ 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 + # At runtime these are all abstract properties, + # but making them abstract in the stub is hugely disruptive, for not much gain. + # See #8726 @property def mode(self) -> str: ... @property @@ -691,7 +693,7 @@ class BinaryIO(IO[bytes]): def __enter__(self) -> BinaryIO: ... class TextIO(IO[str]): - # TODO use abstractproperty + # See comment regarding the @properties in the `IO` class @property def buffer(self) -> BinaryIO: ... @property