@@ -53,7 +53,7 @@ provides backports of these new features to older versions of Python.
5353 should broadly apply to most Python type checkers. (Some parts may still
5454 be specific to mypy.)
5555
56- `"Static Typing with Python" <https://typing.readthedocs.io /en/latest/ >`_
56+ `"Static Typing with Python" <https://typing.python.org /en/latest/ >`_
5757 Type-checker-agnostic documentation written by the community detailing
5858 type system features, useful typing related tools and typing best
5959 practices.
@@ -64,7 +64,7 @@ Specification for the Python Type System
6464========================================
6565
6666The canonical, up-to-date specification of the Python type system can be
67- found at `"Specification for the Python type system" <https://typing.readthedocs.io /en/latest/spec/index.html >`_.
67+ found at `"Specification for the Python type system" <https://typing.python.org /en/latest/spec/index.html >`_.
6868
6969.. _type-aliases :
7070
@@ -2398,6 +2398,10 @@ types.
23982398 .. versionchanged :: 3.11
23992399 Added support for generic namedtuples.
24002400
2401+ .. versionchanged :: next
2402+ Using :func: `super ` (and the ``__class__ `` :term: `closure variable `) in methods of ``NamedTuple `` subclasses
2403+ is unsupported and causes a :class: `TypeError `.
2404+
24012405 .. deprecated-removed :: 3.13 3.15
24022406 The undocumented keyword argument syntax for creating NamedTuple classes
24032407 (``NT = NamedTuple("NT", x=int) ``) is deprecated, and will be disallowed
@@ -2830,17 +2834,35 @@ with :func:`@runtime_checkable <runtime_checkable>`.
28302834 An ABC with one abstract method ``__round__ ``
28312835 that is covariant in its return type.
28322836
2833- ABCs for working with IO
2834- ------------------------
2837+ .. _typing-io :
28352838
2836- .. class :: IO
2837- TextIO
2838- BinaryIO
2839+ ABCs and Protocols for working with I/O
2840+ ---------------------------------------
28392841
2840- Generic type ``IO[AnyStr] `` and its subclasses ``TextIO(IO[str]) ``
2842+ .. class :: IO[AnyStr]
2843+ TextIO[AnyStr]
2844+ BinaryIO[AnyStr]
2845+
2846+ Generic class ``IO[AnyStr] `` and its subclasses ``TextIO(IO[str]) ``
28412847 and ``BinaryIO(IO[bytes]) ``
28422848 represent the types of I/O streams such as returned by
2843- :func: `open `.
2849+ :func: `open `. Please note that these classes are not protocols, and
2850+ their interface is fairly broad.
2851+
2852+ The protocols :class: `io.Reader ` and :class: `io.Writer ` offer a simpler
2853+ alternative for argument types, when only the ``read() `` or ``write() ``
2854+ methods are accessed, respectively::
2855+
2856+ def read_and_write(reader: Reader[str], writer: Writer[bytes]):
2857+ data = reader.read()
2858+ writer.write(data.encode())
2859+
2860+ Also consider using :class: `collections.abc.Iterable ` for iterating over
2861+ the lines of an input stream::
2862+
2863+ def read_config(stream: Iterable[str]):
2864+ for line in stream:
2865+ ...
28442866
28452867Functions and decorators
28462868------------------------
@@ -2912,7 +2934,7 @@ Functions and decorators
29122934
29132935 .. seealso ::
29142936 `Unreachable Code and Exhaustiveness Checking
2915- <https://typing.readthedocs.io /en/latest/guides/unreachable.html> `__ has more
2937+ <https://typing.python.org /en/latest/guides/unreachable.html> `__ has more
29162938 information about exhaustiveness checking with static typing.
29172939
29182940 .. versionadded :: 3.11
0 commit comments