diff --git a/docs/source/runtime_troubles.rst b/docs/source/runtime_troubles.rst index 0847a5796512..909215a774a9 100644 --- a/docs/source/runtime_troubles.rst +++ b/docs/source/runtime_troubles.rst @@ -277,10 +277,18 @@ sections, these can be dealt with by using :ref:`typing.TYPE_CHECKING .. code-block:: python + from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: from _typeshed import SupportsRichComparison + def f(x: SupportsRichComparison) -> None + +The ``from __future__ import annotations`` is required to avoid +a ``NameError`` when using the imported symbol. +For more information and caveats, see the section on +:ref:`future annotations `. + .. _generic-builtins: Using generic builtins