@@ -103,7 +103,7 @@ Note that ``None`` as a type hint is a special case and is replaced by
103
103
NewType
104
104
=======
105
105
106
- Use the :func: `NewType ` helper function to create distinct types::
106
+ Use the :func: `NewType ` helper to create distinct types::
107
107
108
108
from typing import NewType
109
109
@@ -132,7 +132,7 @@ accidentally creating a ``UserId`` in an invalid way::
132
132
133
133
Note that these checks are enforced only by the static type checker. At runtime,
134
134
the statement ``Derived = NewType('Derived', Base) `` will make ``Derived `` a
135
- function that immediately returns whatever parameter you pass it. That means
135
+ callable that immediately returns whatever parameter you pass it. That means
136
136
the expression ``Derived(some_value) `` does not create a new class or introduce
137
137
any overhead beyond that of a regular function call.
138
138
@@ -435,7 +435,7 @@ manner. Use :data:`Any` to indicate that a value is dynamically typed.
435
435
Nominal vs structural subtyping
436
436
===============================
437
437
438
- Initially :pep: `484 ` defined Python static type system as using
438
+ Initially :pep: `484 ` defined the Python static type system as using
439
439
*nominal subtyping *. This means that a class ``A `` is allowed where
440
440
a class ``B `` is expected if and only if ``A `` is a subclass of ``B ``.
441
441
@@ -753,7 +753,7 @@ These can be used as types in annotations using ``[]``, each having a unique syn
753
753
``no_type_check `` functionality that currently exists in the ``typing ``
754
754
module which completely disables typechecking annotations on a function
755
755
or a class, the ``Annotated `` type allows for both static typechecking
756
- of ``T `` (e.g., via mypy or Pyre, which can safely ignore ``x ``)
756
+ of ``T `` (which can safely ignore ``x ``)
757
757
together with runtime access to ``x `` within a specific application.
758
758
759
759
Ultimately, the responsibility of how to interpret the annotations (if
@@ -1064,7 +1064,7 @@ These are not used in annotations. They are building blocks for declaring types.
1064
1064
The resulting class has an extra attribute ``__annotations__ `` giving a
1065
1065
dict that maps the field names to the field types. (The field names are in
1066
1066
the ``_fields `` attribute and the default values are in the
1067
- ``_field_defaults `` attribute both of which are part of the namedtuple
1067
+ ``_field_defaults `` attribute, both of which are part of the :func: ` ~collections. namedtuple`
1068
1068
API.)
1069
1069
1070
1070
``NamedTuple `` subclasses can also have docstrings and methods::
@@ -1140,7 +1140,7 @@ These are not used in annotations. They are building blocks for declaring types.
1140
1140
Point2D = TypedDict('Point2D', x=int, y=int, label=str)
1141
1141
1142
1142
The functional syntax should also be used when any of the keys are not valid
1143
- :ref: `identifiers `, for example because they are keywords or contain hyphens.
1143
+ :ref: `identifiers < identifiers > `, for example because they are keywords or contain hyphens.
1144
1144
Example::
1145
1145
1146
1146
# raises SyntaxError
@@ -1182,7 +1182,7 @@ These are not used in annotations. They are building blocks for declaring types.
1182
1182
y: int
1183
1183
z: int
1184
1184
1185
- A ``TypedDict `` cannot inherit from a non-TypedDict class,
1185
+ A ``TypedDict `` cannot inherit from a non-\ `` TypedDict `` class,
1186
1186
notably including :class: `Generic `. For example::
1187
1187
1188
1188
class X(TypedDict):
@@ -1590,7 +1590,7 @@ Corresponding to other types in :mod:`collections.abc`
1590
1590
1591
1591
.. class :: Hashable
1592
1592
1593
- An alias to :class: `collections.abc.Hashable `
1593
+ An alias to :class: `collections.abc.Hashable `.
1594
1594
1595
1595
.. class :: Reversible(Iterable[T_co])
1596
1596
@@ -1602,7 +1602,7 @@ Corresponding to other types in :mod:`collections.abc`
1602
1602
1603
1603
.. class :: Sized
1604
1604
1605
- An alias to :class: `collections.abc.Sized `
1605
+ An alias to :class: `collections.abc.Sized `.
1606
1606
1607
1607
Asynchronous programming
1608
1608
""""""""""""""""""""""""
@@ -1807,7 +1807,7 @@ Functions and decorators
1807
1807
...
1808
1808
class Sub(Base):
1809
1809
def done(self) -> None: # Error reported by type checker
1810
- ...
1810
+ ...
1811
1811
1812
1812
@final
1813
1813
class Leaf:
@@ -1946,8 +1946,8 @@ Constant
1946
1946
1947
1947
If ``from __future__ import annotations `` is used in Python 3.7 or later,
1948
1948
annotations are not evaluated at function definition time.
1949
- Instead, they are stored as strings in ``__annotations__ ``,
1950
- This makes it unnecessary to use quotes around the annotation.
1949
+ Instead, they are stored as strings in ``__annotations__ ``.
1950
+ This makes it unnecessary to use quotes around the annotation
1951
1951
(see :pep: `563 `).
1952
1952
1953
1953
.. versionadded :: 3.5.2
0 commit comments