@@ -40,12 +40,13 @@ Glossary
40
40
ABCs with the :mod: `abc ` module.
41
41
42
42
annotation
43
- A type metadata value associated with a global variable, a class
44
- attribute, or function parameter/return value.
43
+ A metadata value associated with a global variable, a class variable or a
44
+ function or method parameter or return value, that stores a
45
+ :term: `type hint `.
45
46
46
47
Annotations are stored in the :attr: `__annotations__ ` special attribute
47
48
of a module (when annotating a global variable), class (when annotating
48
- one of its attributes ) or function (when annotating its parameters or
49
+ a class variable ) or function or method (when annotating a parameter or a
49
50
return value) and can be accessed using :func: `typing.get_type_hints `.
50
51
51
52
See :pep: `484 ` and :pep: `526 ` which describe this functionality.
@@ -378,7 +379,7 @@ Glossary
378
379
and the :ref: `function ` section.
379
380
380
381
function annotation
381
- An :term: `annotation ` of a function or method.
382
+ An :term: `annotation ` of a function, or a method.
382
383
383
384
For example, this function has its parameters annotated as taking
384
385
:class: `int ` arguments and its return value annotated as being an
@@ -1023,6 +1024,18 @@ Glossary
1023
1024
:attr: `~instance.__class__ ` attribute or can be retrieved with
1024
1025
``type(obj) ``.
1025
1026
1027
+ type hint
1028
+ An specification about the expected type for a global variable, class
1029
+ variable, function or method parameter or return value.
1030
+
1031
+ While type hints are optional and are not enforced by Python when used,
1032
+ they are very useful for static type analysis tools, and aid IDEs on code
1033
+ completion and refactoring.
1034
+
1035
+ Type hints are stored in :term: `annotations <annotation> `.
1036
+
1037
+ See also :pep: `483 ` which describe this functionality.
1038
+
1026
1039
universal newlines
1027
1040
A manner of interpreting text streams in which all of the following are
1028
1041
recognized as ending a line: the Unix end-of-line convention ``'\n' ``,
@@ -1031,7 +1044,7 @@ Glossary
1031
1044
:func: `bytes.splitlines ` for an additional use.
1032
1045
1033
1046
variable annotation
1034
- An :term: `annotation ` of a global variable, or class variable.
1047
+ An :term: `annotation ` of a global variable, or a class variable.
1035
1048
1036
1049
For example, this variable is annotated as taking :class: `int ` values::
1037
1050
@@ -1044,7 +1057,7 @@ Glossary
1044
1057
1045
1058
Its syntax is explained in section :ref: `annassign `.
1046
1059
1047
- See also the :term: `function annotation ` glossary entry, see :pep: `484 `
1060
+ See also the :term: `function annotation ` glossary entry, and :pep: `484 `
1048
1061
and :pep: `526 ` which describe this functionality.
1049
1062
1050
1063
virtual environment
0 commit comments