This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
and loaders (in the :mod:`importlib.abc` module). You can create your own
ABCs with the :mod:`abc` module.
annotation
A metadata value associated with a global variable, a class attribute or a
function or method parameter or return value, that stores a
:term:`type hint`.
Annotations are stored in the :attr:`__annotations__` special attribute
of a module (when annotating a global variable), class (when annotating
one of its attributes) or function or method (when annotating a parameter or a
return value) and can be accessed using :func:`typing.get_type_hints`.
See :pep:`484` and :pep:`526` which describe this functionality.
argument
A value passed to a :term:`function` (or :term:`method`) when calling the
function. There are two kinds of argument:
Expand Down
Expand Up
@@ -175,6 +187,15 @@ Glossary
normally contain method definitions which operate on instances of the
class.
class variable
A variable defined in a class and intended to be modified only at
class level (i.e., not in an instance of the class).
Class variables can be specified as such through
:term:`type hints <type hint>`.
See :pep:`526` which describes class variable annotations.
coercion
The implicit conversion of an instance of one type to another during an
operation which involves two arguments of the same type. For example,
Expand Down
Expand Up
@@ -367,16 +388,19 @@ Glossary
and the :ref:`function` section.
function annotation
An arbitrary metadata value associated with a function parameter or return
value. Its syntax is explained in section :ref:`function`. Annotations
may be accessed via the :attr:`__annotations__` special attribute of a
function object.
An :term:`annotation` of a function, or a method.
For example, this function has its parameters annotated as taking
:class:`int` arguments and its return value annotated as being an
:class:`int` as well::
def sum_two_numbers(a: int, b: int) -> int:
return a + b
See also the :term:`variable annotation` glossary entry.
Its syntax is explained in section :ref:`function`.
Annotations are meant to provide a standard way for programmers to
document types of functions they design. See :pep:`484`, which
describes this functionality.
See also the :term:`variable annotation` glossary entry, and :pep:`484`,
which describes this functionality.
__future__
A pseudo-module which programmers can use to enable new language features
Expand Down
Expand Up
@@ -1009,6 +1033,18 @@ Glossary
:attr:`~instance.__class__` attribute or can be retrieved with
``type(obj)``.
type hint
A specification about the expected type for a global variable, class
variable, function or method parameter or return value.
While type hints are optional and are not enforced by Python when used,
they are useful for static type analysis tools, and aid IDEs on code
completion and refactoring.
Type hints are stored in :term:`annotations <annotation>`.
See also :pep:`483` which describe this functionality.
universal newlines
A manner of interpreting text streams in which all of the following are
recognized as ending a line: the Unix end-of-line convention ``'\n'``,
Expand All
@@ -1017,17 +1053,21 @@ Glossary
:func:`bytes.splitlines` for an additional use.
variable annotation
A type metadata value associated with a module global variable or
a class attribute. Its syntax is explained in section :ref:`annassign`.
Annotations are stored in the :attr:`__annotations__` special
attribute of a class or module object and can be accessed using
:func:`typing.get_type_hints`.
An :term:`annotation` of a global variable, or a class attribute.
For example, this variable is annotated as taking :class:`int` values::
count: int = 0
When annotating variables, assignment is optional::
class C:
field: int
See also the :term:`function annotation` glossary entry.
Its syntax is explained in section :ref:`annassign`.
Annotations are meant to provide a standard way for programmers to
document types of functions they design. See :pep:`484` and :pep:`526`
which describe this functionality.
See also the :term:`function annotation` glossary entry, and :pep:`484`
and :pep:`526` which describe this functionality.
virtual environment
A cooperatively isolated runtime environment that allows Python users
Expand Down
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[3.7] bpo-32769: Write annotation entry for glossary (GH-6657) #6821
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
Uh oh!
There was an error while loading. Please reload this page.
[3.7] bpo-32769: Write annotation entry for glossary (GH-6657) #6821
Filter by extension
Viewed files
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing