mirror of https://github.com/python/cpython
bpo-35566: Add links to annotation glossary term (GH-11291)
This commit is contained in:
parent
d378b1f8ed
commit
b7105c9c96
|
@ -51,9 +51,9 @@ Module-level decorators, classes, and functions
|
||||||
|
|
||||||
The :func:`dataclass` decorator examines the class to find
|
The :func:`dataclass` decorator examines the class to find
|
||||||
``field``\s. A ``field`` is defined as class variable that has a
|
``field``\s. A ``field`` is defined as class variable that has a
|
||||||
type annotation. With two exceptions described below, nothing in
|
:term:`type annotation <variable annotation>`. With two
|
||||||
:func:`dataclass` examines the type specified in the variable
|
exceptions described below, nothing in :func:`dataclass`
|
||||||
annotation.
|
examines the type specified in the variable annotation.
|
||||||
|
|
||||||
The order of the fields in all of the generated methods is the
|
The order of the fields in all of the generated methods is the
|
||||||
order in which they appear in the class definition.
|
order in which they appear in the class definition.
|
||||||
|
|
|
@ -571,8 +571,8 @@ used keyword arguments.
|
||||||
single: ->; function annotations
|
single: ->; function annotations
|
||||||
single: : (colon); function annotations
|
single: : (colon); function annotations
|
||||||
|
|
||||||
Parameters may have annotations of the form "``: expression``" following the
|
Parameters may have an :term:`annotation <function annotation>` of the form "``: expression``"
|
||||||
parameter name. Any parameter may have an annotation even those of the form
|
following the parameter name. Any parameter may have an annotation, even those of the form
|
||||||
``*identifier`` or ``**identifier``. Functions may have "return" annotation of
|
``*identifier`` or ``**identifier``. Functions may have "return" annotation of
|
||||||
the form "``-> expression``" after the parameter list. These annotations can be
|
the form "``-> expression``" after the parameter list. These annotations can be
|
||||||
any valid Python expression. The presence of annotations does not change the
|
any valid Python expression. The presence of annotations does not change the
|
||||||
|
|
|
@ -325,8 +325,8 @@ Annotated assignment statements
|
||||||
single: statement; assignment, annotated
|
single: statement; assignment, annotated
|
||||||
single: : (colon); annotated variable
|
single: : (colon); annotated variable
|
||||||
|
|
||||||
Annotation assignment is the combination, in a single statement,
|
:term:`Annotation <variable annotation>` assignment is the combination, in a single
|
||||||
of a variable or attribute annotation and an optional assignment statement:
|
statement, of a variable or attribute annotation and an optional assignment statement:
|
||||||
|
|
||||||
.. productionlist::
|
.. productionlist::
|
||||||
annotated_assignment_stmt: `augtarget` ":" `expression` ["=" `expression`]
|
annotated_assignment_stmt: `augtarget` ":" `expression` ["=" `expression`]
|
||||||
|
|
|
@ -682,10 +682,10 @@ Function Annotations
|
||||||
information about the types used by user-defined functions (see :pep:`3107` and
|
information about the types used by user-defined functions (see :pep:`3107` and
|
||||||
:pep:`484` for more information).
|
:pep:`484` for more information).
|
||||||
|
|
||||||
Annotations are stored in the :attr:`__annotations__` attribute of the function
|
:term:`Annotations <function annotation>` are stored in the :attr:`__annotations__`
|
||||||
as a dictionary and have no effect on any other part of the function. Parameter
|
attribute of the function as a dictionary and have no effect on any other part of the
|
||||||
annotations are defined by a colon after the parameter name, followed by an
|
function. Parameter annotations are defined by a colon after the parameter name, followed
|
||||||
expression evaluating to the value of the annotation. Return annotations are
|
by an expression evaluating to the value of the annotation. Return annotations are
|
||||||
defined by a literal ``->``, followed by an expression, between the parameter
|
defined by a literal ``->``, followed by an expression, between the parameter
|
||||||
list and the colon denoting the end of the :keyword:`def` statement. The
|
list and the colon denoting the end of the :keyword:`def` statement. The
|
||||||
following example has a positional argument, a keyword argument, and the return
|
following example has a positional argument, a keyword argument, and the return
|
||||||
|
|
Loading…
Reference in New Issue