Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Doc/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Glossary
can be retrieved by calling :func:`annotationlib.get_annotations`
on modules, classes, and functions, respectively.

Note that an *instance* of a :term:`class` cannot be annotated.

See :term:`variable annotation`, :term:`function annotation`, :pep:`484`,
:pep:`526`, and :pep:`649`, which describe this functionality.
Also see :ref:`annotations-howto`
Expand Down
5 changes: 5 additions & 0 deletions Doc/howto/annotations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,8 @@ quirks by using :func:`annotationlib.get_annotations` on Python 3.14+ or
Python, you can avoid these bugs by accessing the annotations from the
class's :attr:`~type.__dict__`
(e.g., ``cls.__dict__.get('__annotations__', None)``).

In some versions of Python, instances of classes may have an ``__annotations__``
attribute. This is not supported functionality, so the best practice is to always
interact with the ``__annotations__`` attribute of an instance's type. For example
``type(myinstance).__annotations__``.
Loading