Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 91c4e60

Browse files
committed
Fix typos and improve markup in typing.rst.
2 parents 4b2d7f0 + 573e2cd commit 91c4e60

1 file changed

Lines changed: 18 additions & 19 deletions

File tree

Doc/library/typing.rst

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Since type information about objects kept in containers cannot be statically
6060
inferred in a generic way, abstract base classes have been extended to support
6161
subscription to denote expected types for container elements.
6262

63-
.. code-block:: python
63+
::
6464

6565
from typing import Mapping, Sequence
6666

@@ -70,7 +70,7 @@ subscription to denote expected types for container elements.
7070
Generics can be parametrized by using a new factory available in typing
7171
called :class:`TypeVar`.
7272

73-
.. code-block:: python
73+
::
7474

7575
from typing import Sequence, TypeVar
7676

@@ -85,7 +85,7 @@ User-defined generic types
8585

8686
A user-defined class can be defined as a generic class.
8787

88-
.. code-block:: python
88+
::
8989

9090
from typing import TypeVar, Generic
9191
from logging import Logger
@@ -220,9 +220,7 @@ The module defines the following classes, functions and decorators:
220220
Type variables exist primarily for the benefit of static type
221221
checkers. They serve as the parameters for generic types as well
222222
as for generic function definitions. See class Generic for more
223-
information on generic types. Generic functions work as follows:
224-
225-
.. code-block:: python
223+
information on generic types. Generic functions work as follows::
226224

227225
def repeat(x: T, n: int) -> Sequence[T]:
228226
"""Return a list containing n references to x."""
@@ -238,13 +236,13 @@ The module defines the following classes, functions and decorators:
238236
the return type is still plain :class:`str`.
239237

240238
At runtime, ``isinstance(x, T)`` will raise :exc:`TypeError`. In general,
241-
:func:`isinstance` and :func:`issublass` should not be used with types.
239+
:func:`isinstance` and :func:`issubclass` should not be used with types.
242240

243241
Type variables may be marked covariant or contravariant by passing
244242
``covariant=True`` or ``contravariant=True``. See :pep:`484` for more
245243
details. By default type variables are invariant. Alternatively,
246244
a type variable may specify an upper bound using ``bound=<type>``.
247-
This means that an actual type substituted (explicitly or implictly)
245+
This means that an actual type substituted (explicitly or implicitly)
248246
for the type variable must be a subclass of the boundary type,
249247
see :pep:`484`.
250248

@@ -278,7 +276,7 @@ The module defines the following classes, functions and decorators:
278276

279277
* You cannot subclass or instantiate a union.
280278

281-
* You cannot write ``Union[X][Y]``
279+
* You cannot write ``Union[X][Y]``.
282280

283281
* You can use ``Optional[X]`` as a shorthand for ``Union[X, None]``.
284282

@@ -331,6 +329,7 @@ The module defines the following classes, functions and decorators:
331329

332330
X = TypeVar('X')
333331
Y = TypeVar('Y')
332+
334333
def lookup_name(mapping: Mapping[X, Y], key: X, default: Y) -> Y:
335334
try:
336335
return mapping[key]
@@ -347,26 +346,26 @@ The module defines the following classes, functions and decorators:
347346

348347
.. class:: SupportsInt
349348

350-
An ABC with one abstract method `__int__`.
349+
An ABC with one abstract method ``__int__``.
351350

352351
.. class:: SupportsFloat
353352

354-
An ABC with one abstract method `__float__`.
353+
An ABC with one abstract method ``__float__``.
355354

356355
.. class:: SupportsAbs
357356

358-
An ABC with one abstract method `__abs__` that is covariant
357+
An ABC with one abstract method ``__abs__`` that is covariant
359358
in its return type.
360359

361360
.. class:: SupportsRound
362361

363-
An ABC with one abstract method `__round__`
362+
An ABC with one abstract method ``__round__``
364363
that is covariant in its return type.
365364

366365
.. class:: Reversible
367366

368-
An ABC with one abstract method `__reversed__` returning
369-
an `Iterator[T_co]`.
367+
An ABC with one abstract method ``__reversed__`` returning
368+
an ``Iterator[T_co]``.
370369

371370
.. class:: Container(Generic[T_co])
372371

@@ -503,9 +502,9 @@ The module defines the following classes, functions and decorators:
503502

504503
Return type hints for a function or method object.
505504

506-
This is often the same as obj.__annotations__, but it handles
505+
This is often the same as ``obj.__annotations__``, but it handles
507506
forward references encoded as string literals, and if necessary
508-
adds Optional[t] if a default value equal to None is set.
507+
adds ``Optional[t]`` if a default value equal to None is set.
509508

510509
.. decorator:: no_type_check(arg)
511510

@@ -519,7 +518,7 @@ The module defines the following classes, functions and decorators:
519518

520519
.. decorator:: no_type_check_decorator(decorator)
521520

522-
Decorator to give another decorator the @no_type_check effect.
521+
Decorator to give another decorator the :func:`no_type_check` effect.
523522

524523
This wraps the decorator with something that wraps the decorated
525-
function in @no_type_check.
524+
function in :func:`no_type_check`.

0 commit comments

Comments
 (0)