Skip to content

Commit 2cd15fe

Browse files
committed
Shimmy to the left
1 parent 7ee882a commit 2cd15fe

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

Doc/library/typing.rst

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,30 +1300,30 @@ These can be used as types in annotations using ``[]``, each having a unique syn
13001300
where ``T1``, ``T2``, etc. are :class:`TypeVars <TypeVar>`. This would be
13011301
invalid: only one type should be passed to Annotated.
13021302

1303-
* By default, :func:`get_type_hints` strips the metadata from annotations.
1304-
Pass ``include_extras=True`` to have the metadata preserved:
1303+
* By default, :func:`get_type_hints` strips the metadata from annotations.
1304+
Pass ``include_extras=True`` to have the metadata preserved:
13051305

1306-
.. doctest::
1307-
1308-
>>> from typing import Annotated, get_type_hints
1309-
>>> def func(x: Annotated[int, "metadata"]) -> None: pass
1310-
...
1311-
>>> get_type_hints(func)
1312-
{'x': <class 'int'>, 'return': <class 'NoneType'>}
1313-
>>> get_type_hints(func, include_extras=True)
1314-
{'x': typing.Annotated[int, 'metadata'], 'return': <class 'NoneType'>}
1315-
1316-
* At runtime, the metadata associated with an ``Annotated`` type can be
1317-
retrieved via the :attr:`!__metadata__` attribute:
1306+
.. doctest::
13181307

1319-
.. doctest::
1320-
1321-
>>> from typing import Annotated
1322-
>>> X = Annotated[int, "very", "important", "metadata"]
1323-
>>> X
1324-
typing.Annotated[int, 'very', 'important', 'metadata']
1325-
>>> X.__metadata__
1326-
('very', 'important', 'metadata')
1308+
>>> from typing import Annotated, get_type_hints
1309+
>>> def func(x: Annotated[int, "metadata"]) -> None: pass
1310+
...
1311+
>>> get_type_hints(func)
1312+
{'x': <class 'int'>, 'return': <class 'NoneType'>}
1313+
>>> get_type_hints(func, include_extras=True)
1314+
{'x': typing.Annotated[int, 'metadata'], 'return': <class 'NoneType'>}
1315+
1316+
* At runtime, the metadata associated with an ``Annotated`` type can be
1317+
retrieved via the :attr:`!__metadata__` attribute:
1318+
1319+
.. doctest::
1320+
1321+
>>> from typing import Annotated
1322+
>>> X = Annotated[int, "very", "important", "metadata"]
1323+
>>> X
1324+
typing.Annotated[int, 'very', 'important', 'metadata']
1325+
>>> X.__metadata__
1326+
('very', 'important', 'metadata')
13271327

13281328
.. seealso::
13291329

0 commit comments

Comments
 (0)