diff options
Diffstat (limited to 'Doc/library/typing.rst')
-rw-r--r-- | Doc/library/typing.rst | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 898a0f0..447b548 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -10,8 +10,8 @@ -------------- -This module supports type hints as specified by :pep:`484`. The most -fundamental support consists of the type :data:`Any`, :data:`Union`, +This module supports type hints as specified by :pep:`484` and :pep:`526`. +The most fundamental support consists of the type :data:`Any`, :data:`Union`, :data:`Tuple`, :data:`Callable`, :class:`TypeVar`, and :class:`Generic`. For full specification please see :pep:`484`. For a simplified introduction to type hints see :pep:`483`. @@ -507,7 +507,13 @@ The module defines the following classes, functions and decorators: An alias to :class:`collections.abc.Sized` -.. class:: AbstractSet(Sized, Iterable[T_co], Container[T_co]) +.. class:: Collection(Sized, Iterable[T_co], Container[T_co]) + + A generic version of :class:`collections.abc.Collection` + + .. versionadded:: 3.6 + +.. class:: AbstractSet(Sized, Collection[T_co]) A generic version of :class:`collections.abc.Set`. @@ -515,7 +521,7 @@ The module defines the following classes, functions and decorators: A generic version of :class:`collections.abc.MutableSet`. -.. class:: Mapping(Sized, Iterable[KT], Container[KT], Generic[VT_co]) +.. class:: Mapping(Sized, Collection[KT], Generic[VT_co]) A generic version of :class:`collections.abc.Mapping`. @@ -523,7 +529,7 @@ The module defines the following classes, functions and decorators: A generic version of :class:`collections.abc.MutableMapping`. -.. class:: Sequence(Sized, Iterable[T_co], Container[T_co]) +.. class:: Sequence(Reversible[T_co], Collection[T_co]) A generic version of :class:`collections.abc.Sequence`. @@ -590,6 +596,12 @@ The module defines the following classes, functions and decorators: A generic version of :class:`collections.abc.AsyncIterator`. +.. class:: ContextManager(Generic[T_co]) + + A generic version of :class:`contextlib.AbstractContextManager`. + + .. versionadded:: 3.6 + .. class:: Dict(dict, MutableMapping[KT, VT]) A generic version of :class:`dict`. @@ -702,7 +714,7 @@ The module defines the following classes, functions and decorators: .. function:: get_type_hints(obj) - Return type hints for a function or method object. + Return type hints for a class, module, function or method object. This is often the same as ``obj.__annotations__``, but it handles forward references encoded as string literals, and if necessary @@ -845,8 +857,8 @@ The module defines the following classes, functions and decorators: and should not be set on instances of that class. Usage:: class Starship: - stats = {} # type: ClassVar[Dict[str, int]] # class variable - damage = 10 # type: int # instance variable + stats: ClassVar[Dict[str, int]] = {} # class variable + damage: int = 10 # instance variable :data:`ClassVar` accepts only types and cannot be further subscribed. |