Skip to content

Commit 646f9f3

Browse files
committed
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.
1 parent c32e1e2 commit 646f9f3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

stdlib/3/typing.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,25 +335,25 @@ class MappingView:
335335
def __len__(self) -> int: ...
336336

337337
class ItemsView(MappingView, AbstractSet[Tuple[_KT_co, _VT_co]], Generic[_KT_co, _VT_co]):
338-
def __and__(self, o: Iterable[object]) -> Set[Tuple[_KT_co, _VT_co]]: ...
338+
def __and__(self, o: Iterable[Any]) -> Set[Tuple[_KT_co, _VT_co]]: ...
339339
def __rand__(self, o: Iterable[_T]) -> Set[_T]: ...
340340
def __contains__(self, o: object) -> bool: ...
341341
def __iter__(self) -> Iterator[Tuple[_KT_co, _VT_co]]: ...
342342
def __or__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ...
343343
def __ror__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ...
344-
def __sub__(self, o: Iterable[object]) -> Set[Tuple[_KT_co, _VT_co]]: ...
344+
def __sub__(self, o: Iterable[Any]) -> Set[Tuple[_KT_co, _VT_co]]: ...
345345
def __rsub__(self, o: Iterable[_T]) -> Set[_T]: ...
346346
def __xor__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ...
347347
def __rxor__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ...
348348

349349
class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]):
350-
def __and__(self, o: Iterable[object]) -> Set[_KT_co]: ...
350+
def __and__(self, o: Iterable[Any]) -> Set[_KT_co]: ...
351351
def __rand__(self, o: Iterable[_T]) -> Set[_T]: ...
352352
def __contains__(self, o: object) -> bool: ...
353353
def __iter__(self) -> Iterator[_KT_co]: ...
354354
def __or__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ...
355355
def __ror__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ...
356-
def __sub__(self, o: Iterable[object]) -> Set[_KT_co]: ...
356+
def __sub__(self, o: Iterable[Any]) -> Set[_KT_co]: ...
357357
def __rsub__(self, o: Iterable[_T]) -> Set[_T]: ...
358358
def __xor__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ...
359359
def __rxor__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ...

0 commit comments

Comments
 (0)