[Python-checkins] bpo-41370: Add note about ForwardRefs and PEP585 generic types in docs (#25183)

gvanrossum webhook-mailer at python.org
Sun Apr 4 11:14:56 EDT 2021


https://github.com/python/cpython/commit/2b5913b4ee5852a28ca1509478f5582beb3aff7b
commit: 2b5913b4ee5852a28ca1509478f5582beb3aff7b
branch: master
author: Ken Jin <28750310+Fidget-Spinner at users.noreply.github.com>
committer: gvanrossum <gvanrossum at gmail.com>
date: 2021-04-04T08:14:44-07:00
summary:

bpo-41370: Add note about ForwardRefs and PEP585 generic types in docs (#25183)

files:
M Doc/library/typing.rst

diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst
index 9696fd4ef99e6..f6d1ccb1c5b3d 100644
--- a/Doc/library/typing.rst
+++ b/Doc/library/typing.rst
@@ -1948,10 +1948,15 @@ Introspection helpers
 .. class:: ForwardRef
 
    A class used for internal typing representation of string forward references.
-   For example, ``list["SomeClass"]`` is implicitly transformed into
-   ``list[ForwardRef("SomeClass")]``.  This class should not be instantiated by
+   For example, ``List["SomeClass"]`` is implicitly transformed into
+   ``List[ForwardRef("SomeClass")]``.  This class should not be instantiated by
    a user, but may be used by introspection tools.
 
+   .. note::
+      :pep:`585` generic types such as ``list["SomeClass"]`` will not be
+      implicitly transformed into ``list[ForwardRef("SomeClass")]`` and thus
+      will not automatically resolve to ``list[SomeClass]``.
+
    .. versionadded:: 3.7.4
 
 Constant



More information about the Python-checkins mailing list