summaryrefslogtreecommitdiffstats
path: root/Doc/library/inspect.rst
diff options
context:
space:
mode:
authorlarryhastings <larry@hastings.org>2021-05-02 04:19:24 (GMT)
committerGitHub <noreply@github.com>2021-05-02 04:19:24 (GMT)
commit49b26fa517165f991c35a4afcbef1fcb26836bec (patch)
tree1dd85a398089b1f909365d3bf9c38339f4c93db8 /Doc/library/inspect.rst
parent318ca1764ca02692e19e5ea05078281b93c8106a (diff)
downloadcpython-49b26fa517165f991c35a4afcbef1fcb26836bec.zip
cpython-49b26fa517165f991c35a4afcbef1fcb26836bec.tar.gz
cpython-49b26fa517165f991c35a4afcbef1fcb26836bec.tar.bz2
bpo-43987: Add "Annotations Best Practices" HOWTO doc. (#25746)
Add "Annotations Best Practices" HOWTO doc.
Diffstat (limited to 'Doc/library/inspect.rst')
-rw-r--r--Doc/library/inspect.rst7
1 files changed, 7 insertions, 0 deletions
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
index 56c2f767..b9e8be1 100644
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -1149,6 +1149,9 @@ Classes and functions
with the result of calling :func:`eval()` on those values:
* If eval_str is true, :func:`eval()` is called on values of type ``str``.
+ (Note that ``get_annotations`` doesn't catch exceptions; if :func:`eval()`
+ raises an exception, it will unwind the stack past the ``get_annotations``
+ call.)
* If eval_str is false (the default), values of type ``str`` are unchanged.
``globals`` and ``locals`` are passed in to :func:`eval()`; see the documentation
@@ -1164,6 +1167,10 @@ Classes and functions
although if ``obj`` is a wrapped function (using
``functools.update_wrapper()``) it is first unwrapped.
+ Calling ``get_annotations`` is best practice for accessing the
+ annotations dict of any object. See :ref:`annotations-howto` for
+ more information on annotations best practices.
+
.. versionadded:: 3.10