Skip to content

Commit f0779d2

Browse files
committed
Rewrite some sections
Do not mention `__annotations__` dictionaries, as this is slightly outdated since 3.14. Rewrite the note about possible exceptions for clarity. Also do not mention imported type aliases, as since 3.12 aliases with the `type` statement do not suffer from this limitation anymore.
1 parent 8896a25 commit f0779d2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Doc/library/typing.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3348,7 +3348,7 @@ Introspection helpers
33483348
annotations from ``C``'s base classes with those on ``C`` directly. This
33493349
is done by traversing :attr:`C.__mro__ <type.__mro__>` and iteratively
33503350
combining
3351-
``__annotations__`` dictionaries. Annotations on classes appearing
3351+
:term:`annotations <variable annotation>` of each base class. Annotations on classes appearing
33523352
earlier in the :term:`method resolution order` always take precedence over
33533353
annotations on classes appearing later in the method resolution order.
33543354
* The function recursively replaces all occurrences of
@@ -3366,11 +3366,11 @@ Introspection helpers
33663366

33673367
.. note::
33683368

3369-
If any forward references in the annotations of *obj* are not resolvable
3370-
or are not valid Python code, this function will raise an exception
3371-
such as :exc:`NameError`. For example, this can happen with imported
3372-
:ref:`type aliases <type-aliases>` that include forward references,
3373-
or with names imported under :data:`if TYPE_CHECKING <TYPE_CHECKING>`.
3369+
If :attr:`Format.VALUE` is used and any forward references in the annotations
3370+
of *obj* are not resolvable, a :exc:`NameError` exception is raised. For example,
3371+
this can happen with names imported under :data:`if TYPE_CHECKING <TYPE_CHECKING>`.
3372+
More generally, any kind of exception can be raised if an annotation contains invalid
3373+
Python code.
33743374

33753375
.. versionchanged:: 3.9
33763376
Added ``include_extras`` parameter as part of :pep:`593`.

0 commit comments

Comments
 (0)