mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
bpo-43987: Add "Annotations Best Practices" HOWTO doc. (#25746)
Add "Annotations Best Practices" HOWTO doc.
This commit is contained in:
parent
318ca1764c
commit
49b26fa517
7 changed files with 298 additions and 21 deletions
|
@ -807,7 +807,9 @@ Other Language Changes
|
|||
|
||||
* Class and module objects now lazy-create empty annotations dicts on demand.
|
||||
The annotations dicts are stored in the object’s ``__dict__`` for
|
||||
backwards compatibility.
|
||||
backwards compatibility. This improves the best practices for working
|
||||
with ``__annotations__``; for more information, please see
|
||||
:ref:`annotations-howto`.
|
||||
(Contributed by Larry Hastings in :issue:`43901`.)
|
||||
|
||||
New Modules
|
||||
|
@ -996,7 +998,9 @@ defined on an object. It works around the quirks of accessing the annotations
|
|||
on various types of objects, and makes very few assumptions about the object
|
||||
it examines. :func:`inspect.get_annotations` can also correctly un-stringize
|
||||
stringized annotations. :func:`inspect.get_annotations` is now considered
|
||||
best practice for accessing the annotations dict defined on any Python object.
|
||||
best practice for accessing the annotations dict defined on any Python object;
|
||||
for more information on best practices for working with annotations, please see
|
||||
:ref:`annotations-howto`.
|
||||
Relatedly, :func:`inspect.signature`,
|
||||
:func:`inspect.Signature.from_callable`, and ``inspect.Signature.from_function``
|
||||
now call :func:`inspect.get_annotations` to retrieve annotations. This means
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue