From 543f825585772533216487b46628ac079a7ba745 Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" <1330696+mr-c@users.noreply.github.com> Date: Thu, 15 Oct 2026 11:50:29 +0200 Subject: [PATCH] docs: link to collections.abc.* instead of the Typing aliases Save your readers a click --- docs/source/kinds_of_types.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/kinds_of_types.rst b/docs/source/kinds_of_types.rst index b736078a796cf..8ea9e539558e7 100644 --- a/docs/source/kinds_of_types.rst +++ b/docs/source/kinds_of_types.rst @@ -688,7 +688,7 @@ Generators ********** A basic generator that only yields values can be succinctly annotated as having a return -type of either :py:class:`Iterator[YieldType] ` or :py:class:`Iterable[YieldType] `. For example: +type of either :py:class:`Iterator[YieldType] ` or :py:class:`Iterable[YieldType] `. For example: .. code-block:: python @@ -699,8 +699,8 @@ type of either :py:class:`Iterator[YieldType] ` or :py:class:`I A good rule of thumb is to annotate functions with the most specific return type possible. However, you should also take care to avoid leaking implementation details into a function's public API. In keeping with these two principles, prefer -:py:class:`Iterator[YieldType] ` over -:py:class:`Iterable[YieldType] ` as the return-type annotation for a +:py:class:`Iterator[YieldType] ` over +:py:class:`Iterable[YieldType] ` as the return-type annotation for a generator function, as it lets mypy know that users are able to call :py:func:`next` on the object returned by the function. Nonetheless, bear in mind that ``Iterable`` may sometimes be the better option, if you consider it an implementation detail that @@ -708,7 +708,7 @@ sometimes be the better option, if you consider it an implementation detail that If you want your generator to accept values via the :py:meth:`~generator.send` method or return a value, on the other hand, you should use the -:py:class:`Generator[YieldType, SendType, ReturnType] ` generic type instead of +:py:class:`Generator[YieldType, SendType, ReturnType] ` generic type instead of either ``Iterator`` or ``Iterable``. For example: .. code-block:: python