Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-132426: Add get_annotate_from_class_namespace replacing get_annotate_function #132490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 4, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
reword docs, thanks Adam
  • Loading branch information
JelleZijlstra committed Apr 17, 2025
commit e9fd0ebaaeed6721e65536b08b2b70a6f28f805e
9 changes: 6 additions & 3 deletions 9 Doc/library/annotationlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,9 @@ Functions

Retrieve the :term:`annotate function` from a class namespace dictionary *namespace*.
Return :const:`!None` if the namespace does not contain an annotate function.
This is useful in :ref:`metaclasses <metaclasses>` to retrieve the annotate function;
see :ref:`below <annotationlib-metaclass>` for an example.
This is primarily useful before the class has been fully created (e.g., in a metaclass);
after the class exists, the annotate function can be retrieved with ``cls.__annotate__``.
See :ref:`below <annotationlib-metaclass>` for an example using this function in a metaclass.

.. versionadded:: 3.14

Expand Down Expand Up @@ -429,7 +430,9 @@ that calls the original annotate function, makes any necessary adjustments, and
returns the result.

Below is an example of a metaclass that filters out all :class:`typing.ClassVar`
annotations from the class and puts them in a separate attribute::
annotations from the class and puts them in a separate attribute:

.. code-block:: python

import annotationlib
import typing
Expand Down
2 changes: 1 addition & 1 deletion 2 Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ Special attributes
:attr:`__annotations__ attributes <object.__annotations__>`.

For best practices on working with :attr:`~object.__annotations__`,
please see :mod:`annotationlib`. It is recommended to use
please see :mod:`annotationlib`. Where possible, use
:func:`annotationlib.get_annotations` instead of accessing this
attribute directly.

Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.