Skip to content

Commit d56bcf9

Browse files
[3.9] bpo-41370: Add note about ForwardRefs and PEP585 generic types in docs (GH-25183) (GH-25184)
(cherry picked from commit 2b5913b) Co-authored-by: Ken Jin <[email protected]> Automerge-Triggered-By: GH:gvanrossum
1 parent c7b0fec commit d56bcf9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Doc/library/typing.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,10 +1710,15 @@ Introspection helpers
17101710
.. class:: ForwardRef
17111711

17121712
A class used for internal typing representation of string forward references.
1713-
For example, ``list["SomeClass"]`` is implicitly transformed into
1714-
``list[ForwardRef("SomeClass")]``. This class should not be instantiated by
1713+
For example, ``List["SomeClass"]`` is implicitly transformed into
1714+
``List[ForwardRef("SomeClass")]``. This class should not be instantiated by
17151715
a user, but may be used by introspection tools.
17161716

1717+
.. note::
1718+
:pep:`585` generic types such as ``list["SomeClass"]`` will not be
1719+
implicitly transformed into ``list[ForwardRef("SomeClass")]`` and thus
1720+
will not automatically resolve to ``list[SomeClass]``.
1721+
17171722
.. versionadded:: 3.7.4
17181723

17191724
Constant

0 commit comments

Comments
 (0)