summaryrefslogtreecommitdiffstats
path: root/Misc
diff options
context:
space:
mode:
authorlarryhastings <larry@hastings.org>2021-04-30 04:16:28 (GMT)
committerGitHub <noreply@github.com>2021-04-30 04:16:28 (GMT)
commit74613a46fc79cacc88d3eae4105b12691cd4ba20 (patch)
treee4bb45c84127a124ac969aa06e0946798a7e5bba /Misc
parenta62e424de0c394cda178a8d934d06f0559b5e28d (diff)
downloadcpython-74613a46fc79cacc88d3eae4105b12691cd4ba20.zip
cpython-74613a46fc79cacc88d3eae4105b12691cd4ba20.tar.gz
cpython-74613a46fc79cacc88d3eae4105b12691cd4ba20.tar.bz2
bpo-43817: Add inspect.get_annotations(). (#25522)
Add inspect.get_annotations, which safely computes the annotations defined on an object. It works around the quirks of accessing the annotations from various types of objects, and makes very few assumptions about the object passed in. inspect.get_annotations can also correctly un-stringize stringized annotations. inspect.signature, inspect.from_callable, and inspect.from_function now call inspect.get_annotations to retrieve annotations. This means inspect.signature and inspect.from_callable can now un-stringize stringized annotations, too.
Diffstat (limited to 'Misc')
-rw-r--r--Misc/NEWS.d/next/Library/2021-04-22-04-12-13.bpo-43817.FQ-XlH.rst11
1 files changed, 11 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Library/2021-04-22-04-12-13.bpo-43817.FQ-XlH.rst b/Misc/NEWS.d/next/Library/2021-04-22-04-12-13.bpo-43817.FQ-XlH.rst
new file mode 100644
index 0000000..36a6018
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2021-04-22-04-12-13.bpo-43817.FQ-XlH.rst
@@ -0,0 +1,11 @@
+Add :func:`inspect.get_annotations`, which safely computes the annotations
+defined on an object. It works around the quirks of accessing the
+annotations from various types of objects, and makes very few assumptions
+about the object passed in. :func:`inspect.get_annotations` can also
+correctly un-stringize stringized annotations.
+
+:func:`inspect.signature`, :func:`inspect.from_callable`, and
+:func:`inspect.from_function` now call :func:`inspect.get_annotations`
+to retrieve annotations. This means :func:`inspect.signature`
+and :func:`inspect.from_callable` can now un-stringize stringized
+annotations, too.