mirror of
https://github.com/python/cpython.git
synced 2025-08-20 00:32:12 +00:00
[3.14] gh-119180: More documentation for PEP 649/749 (GH-133552) (#133902)
gh-119180: More documentation for PEP 649/749 (GH-133552)
The SC asked that the Appendix in PEP-749 be added to the docs.
(cherry picked from commit 3396df56d0)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This commit is contained in:
parent
507715d5f7
commit
a3475e68bb
3 changed files with 141 additions and 8 deletions
|
|
@ -1885,7 +1885,7 @@ expressions. The presence of annotations does not change the runtime semantics o
|
|||
the code, except if some mechanism is used that introspects and uses the annotations
|
||||
(such as :mod:`dataclasses` or :func:`functools.singledispatch`).
|
||||
|
||||
By default, annotations are lazily evaluated in a :ref:`annotation scope <annotation-scopes>`.
|
||||
By default, annotations are lazily evaluated in an :ref:`annotation scope <annotation-scopes>`.
|
||||
This means that they are not evaluated when the code containing the annotation is evaluated.
|
||||
Instead, the interpreter saves information that can be used to evaluate the annotation later
|
||||
if requested. The :mod:`annotationlib` module provides tools for evaluating annotations.
|
||||
|
|
@ -1898,6 +1898,12 @@ all annotations are instead stored as strings::
|
|||
>>> f.__annotations__
|
||||
{'param': 'annotation'}
|
||||
|
||||
This future statement will be deprecated and removed in a future version of Python,
|
||||
but not before Python 3.13 reaches its end of life (see :pep:`749`).
|
||||
When it is used, introspection tools like
|
||||
:func:`annotationlib.get_annotations` and :func:`typing.get_type_hints` are
|
||||
less likely to be able to resolve annotations at runtime.
|
||||
|
||||
|
||||
.. rubric:: Footnotes
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue