From 8fd28f8cf6da011e623938b5157913911dd414f7 Mon Sep 17 00:00:00 2001 From: herr kaste Date: Tue, 13 Aug 2019 11:10:27 +0200 Subject: [PATCH 1/7] Return Sets from KeysView dunder operators --- stdlib/3/typing.pyi | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index f34bf325f2bc..4565586d7b27 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -350,16 +350,16 @@ class ItemsView(MappingView, AbstractSet[Tuple[_KT_co, _VT_co]], Generic[_KT_co, def __rxor__(self, o: Iterable[_T]) -> AbstractSet[Union[Tuple[_KT_co, _VT_co], _T]]: ... class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]): - def __and__(self, o: Iterable[_T]) -> AbstractSet[Union[_KT_co, _T]]: ... - def __rand__(self, o: Iterable[_T]) -> AbstractSet[Union[_KT_co, _T]]: ... + def __and__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ... + def __rand__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ... def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[_KT_co]: ... - def __or__(self, o: Iterable[_T]) -> AbstractSet[Union[_KT_co, _T]]: ... - def __ror__(self, o: Iterable[_T]) -> AbstractSet[Union[_KT_co, _T]]: ... - def __sub__(self, o: Iterable[_T]) -> AbstractSet[Union[_KT_co, _T]]: ... - def __rsub__(self, o: Iterable[_T]) -> AbstractSet[Union[_KT_co, _T]]: ... - def __xor__(self, o: Iterable[_T]) -> AbstractSet[Union[_KT_co, _T]]: ... - def __rxor__(self, o: Iterable[_T]) -> AbstractSet[Union[_KT_co, _T]]: ... + 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[_T]) -> Set[Union[_KT_co, _T]]: ... + def __rsub__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ... + def __xor__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ... + def __rxor__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ... class ValuesView(MappingView, Iterable[_VT_co], Generic[_VT_co]): def __contains__(self, o: object) -> bool: ... From b47a81e22a3a8c09d8df5103ea5b2eaa58107467 Mon Sep 17 00:00:00 2001 From: herr kaste Date: Tue, 13 Aug 2019 11:32:48 +0200 Subject: [PATCH 2/7] Return Left for KeysView difference operators --- stdlib/3/typing.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index 4565586d7b27..f35dfd88111c 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -356,8 +356,8 @@ class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]): 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[_T]) -> Set[Union[_KT_co, _T]]: ... - def __rsub__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ... + def __sub__(self, o: Iterable[_T]) -> 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]]: ... From 39a3747b89188b1e156fefae8a74dda11fc7bce4 Mon Sep 17 00:00:00 2001 From: herr kaste Date: Tue, 13 Aug 2019 11:40:04 +0200 Subject: [PATCH 3/7] Return Sets from ItemsView dunder operators --- stdlib/3/typing.pyi | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index f35dfd88111c..de2ba0d4bcea 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -338,16 +338,16 @@ 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[_T]) -> AbstractSet[Union[Tuple[_KT_co, _VT_co], _T]]: ... - def __rand__(self, o: Iterable[_T]) -> AbstractSet[Union[Tuple[_KT_co, _VT_co], _T]]: ... + def __and__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ... + def __rand__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ... def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[Tuple[_KT_co, _VT_co]]: ... - def __or__(self, o: Iterable[_T]) -> AbstractSet[Union[Tuple[_KT_co, _VT_co], _T]]: ... - def __ror__(self, o: Iterable[_T]) -> AbstractSet[Union[Tuple[_KT_co, _VT_co], _T]]: ... - def __sub__(self, o: Iterable[_T]) -> AbstractSet[Union[Tuple[_KT_co, _VT_co], _T]]: ... - def __rsub__(self, o: Iterable[_T]) -> AbstractSet[Union[Tuple[_KT_co, _VT_co], _T]]: ... - def __xor__(self, o: Iterable[_T]) -> AbstractSet[Union[Tuple[_KT_co, _VT_co], _T]]: ... - def __rxor__(self, o: Iterable[_T]) -> AbstractSet[Union[Tuple[_KT_co, _VT_co], _T]]: ... + 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[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ... + def __rsub__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _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[_T]) -> Set[Union[_KT_co, _T]]: ... From 5f27ddacf75f477dda432a6b57d2ba0d25736675 Mon Sep 17 00:00:00 2001 From: herr kaste Date: Tue, 13 Aug 2019 11:41:35 +0200 Subject: [PATCH 4/7] Return Left for ItemsView difference operators --- stdlib/3/typing.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index de2ba0d4bcea..6e38ebdde140 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -344,8 +344,8 @@ class ItemsView(MappingView, AbstractSet[Tuple[_KT_co, _VT_co]], Generic[_KT_co, 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[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ... - def __rsub__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ... + def __sub__(self, o: Iterable[_T]) -> 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]]: ... From 73bd9c2d3c1a659b6ac29333a49e099cd0f9ea11 Mon Sep 17 00:00:00 2001 From: herr kaste Date: Tue, 13 Aug 2019 13:11:55 +0200 Subject: [PATCH 5/7] Return Left for KeysView intersection operator ... to match the behavior of `Set` and `AbstractSet` --- stdlib/3/typing.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index 6e38ebdde140..d7b7bcfcd469 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -350,8 +350,8 @@ class ItemsView(MappingView, AbstractSet[Tuple[_KT_co, _VT_co]], Generic[_KT_co, 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[_T]) -> Set[Union[_KT_co, _T]]: ... - def __rand__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ... + def __and__(self, o: Iterable[_T]) -> 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]]: ... From 3e18e9bc78592de10609b0ad9e9799eb4009b8fa Mon Sep 17 00:00:00 2001 From: herr kaste Date: Tue, 13 Aug 2019 13:13:05 +0200 Subject: [PATCH 6/7] Return Left for ItemsView intersection operators ... to match the behavior of `Set` and `AbstractSet` --- stdlib/3/typing.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index d7b7bcfcd469..e7d32b74a9e1 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -338,8 +338,8 @@ 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[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ... - def __rand__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ... + def __and__(self, o: Iterable[_T]) -> 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]]: ... From 2472f15469df4386d8f5eec6ea63d2b067eb1c1d Mon Sep 17 00:00:00 2001 From: herr kaste Date: Thu, 5 Sep 2019 11:59:51 +0200 Subject: [PATCH 7/7] Apply suggestions from code review Co-Authored-By: Sebastian Rittau --- 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 e7d32b74a9e1..c60e74555b10 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -338,25 +338,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[_T]) -> Set[Tuple[_KT_co, _VT_co]]: ... + def __and__(self, o: Iterable[object]) -> 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[_T]) -> Set[Tuple[_KT_co, _VT_co]]: ... + def __sub__(self, o: Iterable[object]) -> 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[_T]) -> Set[_KT_co]: ... + def __and__(self, o: Iterable[object]) -> 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[_T]) -> Set[_KT_co]: ... + def __sub__(self, o: Iterable[object]) -> 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]]: ...