mirror of
https://github.com/python/cpython.git
synced 2025-09-29 03:35:31 +00:00
[3.9] bpo-41370: Add note about ForwardRefs and PEP585 generic types in docs (GH-25183) (GH-25184)
(cherry picked from commit 2b5913b4ee
)
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Automerge-Triggered-By: GH:gvanrossum
This commit is contained in:
parent
c7b0feca25
commit
d56bcf915b
1 changed files with 7 additions and 2 deletions
|
@ -1710,10 +1710,15 @@ Introspection helpers
|
||||||
.. class:: ForwardRef
|
.. class:: ForwardRef
|
||||||
|
|
||||||
A class used for internal typing representation of string forward references.
|
A class used for internal typing representation of string forward references.
|
||||||
For example, ``list["SomeClass"]`` is implicitly transformed into
|
For example, ``List["SomeClass"]`` is implicitly transformed into
|
||||||
``list[ForwardRef("SomeClass")]``. This class should not be instantiated by
|
``List[ForwardRef("SomeClass")]``. This class should not be instantiated by
|
||||||
a user, but may be used by introspection tools.
|
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
|
.. versionadded:: 3.7.4
|
||||||
|
|
||||||
Constant
|
Constant
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue