Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
  • Loading branch information
JelleZijlstra and AA-Turner authored Jul 27, 2024
1 parent b4f6385 commit 6ebdce9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Doc/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Glossary
on modules, classes, and functions, respectively.

See :term:`variable annotation`, :term:`function annotation`, :pep:`484`,
:pep:`526` and :pep:`649`, which describe this functionality.
:pep:`526`, and :pep:`649`, which describe this functionality.
Also see :ref:`annotations-howto`
for best practices on working with annotations.

Expand Down
13 changes: 8 additions & 5 deletions Doc/library/annotationlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,11 @@ on modules, classes, and functions.
reference is being evaluated. *owner* is the object that owns the annotation from
which the forward reference derives, usually a function, class, or module.

Once a :class:`~ForwardRef` instance has been evaluated, it caches the evaluated
value, and future calls to :meth:`evaluate` will return the cached value, regardless
of the parameters passed in.
.. important::

Once a :class:`~ForwardRef` instance has been evaluated, it caches the evaluated
value, and future calls to :meth:`evaluate` will return the cached value, regardless
of the parameters passed in.

.. versionadded:: 3.14

Expand All @@ -146,7 +148,7 @@ on modules, classes, and functions.

This is usually equivalent to accessing the :attr:`~object.__annotate__` attribute of *obj*,
but direct access to the attribute may return the wrong object in certain situations involving
metaclasses. It is recommended to use this function instead of accessing the attribute directly.
metaclasses. This function should be used instead of accessing the attribute directly.

.. versionadded:: 3.14

Expand All @@ -158,7 +160,8 @@ on modules, classes, and functions.
:attr:`~object.__annotate__` and :attr:`~object.__annotations__` attributes.
Passing in an object of any other type raises :exc:`TypeError`.

The *format* parameter controls the format in which annotations are returned.
The *format* parameter controls the format in which annotations are returned,
and must be a member of the :class:`Format` enum or its integer equivalent.

Returns a dict. :func:`!get_annotations` returns a new dict every time
it's called; calling it twice on the same object will return two
Expand Down
22 changes: 12 additions & 10 deletions Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3325,16 +3325,18 @@ Introspection helpers
* Supports the :attr:`~annotationlib.Format.FORWARDREF` and
:attr:`~annotationlib.Format.SOURCE` formats.

*forward_ref* must be an instance of :class:`~annotationlib.ForwardRef`. *owner*, if given,
should be the object that holds the annotations that the forward reference
derived from, such as a module, class object, or function. It is used to
infer the namespaces to use for looking up names. *globals* and *locals*
can also be explicitly given to provide the global and local namespaces.
*type_params* is a tuple of :ref:`type parameters <type-params>` that are in scope when
evaluating the forward reference. This parameter must be provided (though
it may be an empty tuple) if *owner* is not given and the forward reference
does not already have an owner set. *format* specifies the format of the
annotation and is a member of the :class:`annotationlib.Format` enum.
*forward_ref* must be an instance of :class:`~annotationlib.ForwardRef`.
*owner*, if given, should be the object that holds the annotations that
the forward reference derived from, such as a module, class object, or function.
It is used to infer the namespaces to use for looking up names.
*globals* and *locals* can also be explicitly given to provide
the global and local namespaces.
*type_params* is a tuple of :ref:`type parameters <type-params>` that
are in scope when evaluating the forward reference.
This parameter must be provided (though it may be an empty tuple) if *owner*
is not given and the forward reference does not already have an owner set.
*format* specifies the format of the annotation and is a member of
the :class:`annotationlib.Format` enum.

.. versionadded:: 3.14

Expand Down

0 comments on commit 6ebdce9

Please sign in to comment.