From 646f9f3cc0a31a6ba523057d4daf451744cc6867 Mon Sep 17 00:00:00 2001 From: "Michael J. Sullivan" Date: Tue, 1 Oct 2019 17:11:33 -0700 Subject: [PATCH] Use Any instead of object in the view types for __and__ and __sub__ This was discussed in #3181 and the correct explanation was given that object ought to be preferred here. In practice this caused an obscure issue with mypy when using this operations on the results of six.viewkeys(), since it decided that it wanted a mapping *from* object as a result of inference contexts. Grumble. --- stdlib/3/typing.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index 4aa4988bd25f..fb279c01f46b 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -335,25 +335,25 @@ class MappingView: def __len__(self) -> int: ... class ItemsView(MappingView, AbstractSet[Tuple[_KT_co, _VT_co]], Generic[_KT_co, _VT_co]): - def __and__(self, o: Iterable[object]) -> Set[Tuple[_KT_co, _VT_co]]: ... + def __and__(self, o: Iterable[Any]) -> Set[Tuple[_KT_co, _VT_co]]: ... def __rand__(self, o: Iterable[_T]) -> Set[_T]: ... def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[Tuple[_KT_co, _VT_co]]: ... def __or__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ... def __ror__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ... - def __sub__(self, o: Iterable[object]) -> Set[Tuple[_KT_co, _VT_co]]: ... + def __sub__(self, o: Iterable[Any]) -> Set[Tuple[_KT_co, _VT_co]]: ... def __rsub__(self, o: Iterable[_T]) -> Set[_T]: ... def __xor__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ... def __rxor__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ... class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]): - def __and__(self, o: Iterable[object]) -> Set[_KT_co]: ... + def __and__(self, o: Iterable[Any]) -> Set[_KT_co]: ... def __rand__(self, o: Iterable[_T]) -> Set[_T]: ... def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[_KT_co]: ... def __or__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ... def __ror__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ... - def __sub__(self, o: Iterable[object]) -> Set[_KT_co]: ... + def __sub__(self, o: Iterable[Any]) -> Set[_KT_co]: ... def __rsub__(self, o: Iterable[_T]) -> Set[_T]: ... def __xor__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ... def __rxor__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ...