diff -r 8c55fb5a11d8 Doc/library/typing.rst --- a/Doc/library/typing.rst Sun Aug 09 23:23:21 2015 -0400 +++ b/Doc/library/typing.rst Mon Aug 10 22:13:40 2015 -0500 @@ -352,31 +352,76 @@ .. class:: MutableSequence(Sequence[T]) + A generic version of :class:`collections.abc.MutableSequence`. + .. class:: ByteString(Sequence[int]) + An abstract base class of :class:`collections.abc.ByteString`. + + This type represents the types `bytes`, `bytearray`, and `memoryview`. + + As a shorthand for this type, `bytes` can be used to annotate arguments of + any of the types mentioned above. + .. class:: List(list, MutableSequence[T]) -.. class:: Set(set, MutableSet[T]) + Useful for annotating return types. To annotate arguments it is preferred + to use abstract collection types such as :class:`Mapping`, :class:`Sequence`, + or :class:`AbstractSet`. + + This type may be used as follows:: + + T = TypeVar('T', int, float) + + def vec2(x: T, y: T) -> List[T]: + return [x, y] + + def slice__to_4(vector: Sequence[T]) -> List[T]: + return vector[0:4] + +.. class:: AbstractSet(set, MutableSet[T]) + + An abstract base class of :class:`collections.abc.Set`. .. class:: MappingView(Sized, Iterable[T_co]) + An abstract base class of :class:`collections.abc.MappingView`. + .. class:: KeysView(MappingView[KT_co], AbstractSet[KT_co]) + An abstract base class of :class:`collections.abc.KeysView`. + .. class:: ItemsView(MappingView, Generic[KT_co, VT_co]) + An abstract base class of :class:`collections.abc.ItemsView`. + .. class:: ValuesView(MappingView[VT_co]) + An abstract base class of :class:`collections.abc.ValuesView`. + .. class:: Dict(dict, MutableMapping[KT, VT]) + Dictionary type that inherits from :class:`MutableMapping`. + + The usage of this type is as follows:: + + def get_position_in_index(word_list: Dict[str, int], word: str) -> int: + return word_list[word] + .. class:: Generator(Iterator[T_co], Generic[T_co, T_contra, V_co]) .. class:: io - Wrapper namespace for IO generic classes. + Generic base class for TextIO and BinaryIO. + + Only the types IO[str], IO[bytes], and IO[Any] and the aliases + TextIO, BinryIO, and IO respectively are valid. .. class:: re - Wrapper namespace for re type classes. + Generic base class for the Match and Pattern types. + + The types Pattern[Any] and Match[Any] are valid within the re submodule. .. function:: NamedTuple(typename, fields)