summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorJelle Zijlstra <jelle.zijlstra@gmail.com>2022-12-27 04:44:53 (GMT)
committerGitHub <noreply@github.com>2022-12-27 04:44:53 (GMT)
commit1ffc67265f1a622751069997e7ca8193f983e1e2 (patch)
tree4e680a32ecb08a23ad7eb959c749f1a7bce8f320 /Doc
parentbb159b448170b24756db9ddfde0e0a735489fce6 (diff)
downloadcpython-1ffc67265f1a622751069997e7ca8193f983e1e2.zip
cpython-1ffc67265f1a622751069997e7ca8193f983e1e2.tar.gz
cpython-1ffc67265f1a622751069997e7ca8193f983e1e2.tar.bz2
[3.10] gh-99535: Add test for inheritance of annotations and update documentation (GH-99990) (#100509)
(cherry picked from commit f5b7b19bf10724d831285fb04e00f763838bd555) Co-authored-by: MonadChains <monadchains@gmail.com>
Diffstat (limited to 'Doc')
-rw-r--r--Doc/howto/annotations.rst6
-rw-r--r--Doc/library/typing.rst4
2 files changed, 10 insertions, 0 deletions
diff --git a/Doc/howto/annotations.rst b/Doc/howto/annotations.rst
index 2bc2f2d..4720690 100644
--- a/Doc/howto/annotations.rst
+++ b/Doc/howto/annotations.rst
@@ -57,6 +57,12 @@ Accessing The Annotations Dict Of An Object In Python 3.10 And Newer
newer is to call :func:`getattr` with three arguments,
for example ``getattr(o, '__annotations__', None)``.
+ Before Python 3.10, accessing ``__annotations__`` on a class that
+ defines no annotations but that has a parent class with
+ annotations would return the parent's ``__annotations__``.
+ In Python 3.10 and newer, the child class's annotations
+ will be an empty dict instead.
+
Accessing The Annotations Dict Of An Object In Python 3.9 And Older
===================================================================
diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst
index d415f14..d327520 100644
--- a/Doc/library/typing.rst
+++ b/Doc/library/typing.rst
@@ -2233,6 +2233,10 @@ Introspection helpers
.. versionchanged:: 3.9
Added ``include_extras`` parameter as part of :pep:`593`.
+ .. versionchanged:: 3.10
+ Calling ``get_type_hints()`` on a class no longer returns the annotations
+ of its base classes.
+
.. function:: get_args(tp)
.. function:: get_origin(tp)