diff --git a/stdlib/@tests/stubtest_allowlists/common.txt b/stdlib/@tests/stubtest_allowlists/common.txt index b9cb4f3f13f6..ba5482626c9b 100644 --- a/stdlib/@tests/stubtest_allowlists/common.txt +++ b/stdlib/@tests/stubtest_allowlists/common.txt @@ -51,7 +51,6 @@ _collections_abc.Mapping.__reversed__ # set to None at runtime for a better err # Adding these reflected dunders to `typing.AbstractSet` causes a large number of false-positives. See #7414. _collections_abc.Set.__rand__ _collections_abc.Set.__ror__ -_collections_abc.Set.__rsub__ _collections_abc.Set.__rxor__ # Undocumented implementation details of a deprecated class diff --git a/stdlib/@tests/stubtest_allowlists/py39.txt b/stdlib/@tests/stubtest_allowlists/py39.txt index f706ee5c19ee..4ce820179d44 100644 --- a/stdlib/@tests/stubtest_allowlists/py39.txt +++ b/stdlib/@tests/stubtest_allowlists/py39.txt @@ -140,7 +140,6 @@ collections.Mapping.__reversed__ # Set to None at runtime for a better error me # Adding these reflected dunders to `typing.AbstractSet` causes a large number of false-positives. See #7414. collections.Set.__rand__ collections.Set.__ror__ -collections.Set.__rsub__ collections.Set.__rxor__ ssl.RAND_egd # Depends on the existence and flags of SSL diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index f2ce8a60ccbf..be2ac4b57b3d 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1261,13 +1261,14 @@ class set(MutableSet[_T]): def __len__(self) -> int: ... def __contains__(self, o: object, /) -> bool: ... def __iter__(self) -> Iterator[_T]: ... - def __and__(self, value: AbstractSet[object], /) -> set[_T]: ... - def __iand__(self, value: AbstractSet[object], /) -> Self: ... - def __or__(self, value: AbstractSet[_S], /) -> set[_T | _S]: ... + def __and__(self, value: AbstractSet[object], /) -> set[_T]: ... # type: ignore[override,misc] + def __iand__(self, value: AbstractSet[object], /) -> Self: ... # type: ignore[override,misc] + def __or__(self, value: AbstractSet[_S], /) -> set[_T | _S]: ... # type: ignore[override,misc] def __ior__(self, value: AbstractSet[_T], /) -> Self: ... # type: ignore[override,misc] - def __sub__(self, value: AbstractSet[_T | None], /) -> set[_T]: ... - def __isub__(self, value: AbstractSet[object], /) -> Self: ... - def __xor__(self, value: AbstractSet[_S], /) -> set[_T | _S]: ... + def __sub__(self, value: AbstractSet[_T | None], /) -> set[_T]: ... # type: ignore[override,misc] + def __isub__(self, value: AbstractSet[object], /) -> Self: ... # type: ignore[override,misc] + def __rsub__(self, value: AbstractSet[_S], /) -> set[_S]: ... # type: ignore[override,misc] + def __xor__(self, value: AbstractSet[_S], /) -> set[_T | _S]: ... # type: ignore[override,misc] def __ixor__(self, value: AbstractSet[_T], /) -> Self: ... # type: ignore[override,misc] def __le__(self, value: AbstractSet[object], /) -> bool: ... def __lt__(self, value: AbstractSet[object], /) -> bool: ... @@ -1294,10 +1295,10 @@ class frozenset(AbstractSet[_T_co]): def __len__(self) -> int: ... def __contains__(self, o: object, /) -> bool: ... def __iter__(self) -> Iterator[_T_co]: ... - def __and__(self, value: AbstractSet[_T_co], /) -> frozenset[_T_co]: ... - def __or__(self, value: AbstractSet[_S], /) -> frozenset[_T_co | _S]: ... - def __sub__(self, value: AbstractSet[_T_co], /) -> frozenset[_T_co]: ... - def __xor__(self, value: AbstractSet[_S], /) -> frozenset[_T_co | _S]: ... + def __and__(self, value: AbstractSet[_T_co], /) -> frozenset[_T_co]: ... # type: ignore[override,misc] + def __or__(self, value: AbstractSet[_S], /) -> frozenset[_T_co | _S]: ... # type: ignore[override,misc] + def __sub__(self, value: AbstractSet[_T_co], /) -> frozenset[_T_co]: ... # type: ignore[override,misc] + def __xor__(self, value: AbstractSet[_S], /) -> frozenset[_T_co | _S]: ... # type: ignore[override,misc] def __le__(self, value: AbstractSet[object], /) -> bool: ... def __lt__(self, value: AbstractSet[object], /) -> bool: ... def __ge__(self, value: AbstractSet[object], /) -> bool: ... diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index 5efe69a97377..ceae9d70902c 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -147,13 +147,13 @@ if sys.version_info >= (3, 14): def __len__(self) -> int: ... def __contains__(self, o: object, /) -> bool: ... def __iter__(self) -> Iterator[_T]: ... - def __and__(self, value: AbstractSet[object], /) -> set[_T]: ... - def __iand__(self, value: AbstractSet[object], /) -> Self: ... - def __or__(self, value: AbstractSet[_S], /) -> set[_T | _S]: ... + def __and__(self, value: AbstractSet[object], /) -> set[_T]: ... # type: ignore[override,misc] + def __iand__(self, value: AbstractSet[object], /) -> Self: ... # type: ignore[override,misc] + def __or__(self, value: AbstractSet[_S], /) -> set[_T | _S]: ... # type: ignore[override,misc] def __ior__(self, value: AbstractSet[_T], /) -> Self: ... # type: ignore[override,misc] - def __sub__(self, value: AbstractSet[_T | None], /) -> set[_T]: ... - def __isub__(self, value: AbstractSet[object], /) -> Self: ... - def __xor__(self, value: AbstractSet[_S], /) -> set[_T | _S]: ... + def __sub__(self, value: AbstractSet[_T | None], /) -> set[_T]: ... # type: ignore[override,misc] + def __isub__(self, value: AbstractSet[object], /) -> Self: ... # type: ignore[override,misc] + def __xor__(self, value: AbstractSet[_S], /) -> set[_T | _S]: ... # type: ignore[override,misc] def __ixor__(self, value: AbstractSet[_T], /) -> Self: ... # type: ignore[override,misc] def __le__(self, value: AbstractSet[object], /) -> bool: ... def __lt__(self, value: AbstractSet[object], /) -> bool: ... @@ -162,7 +162,7 @@ if sys.version_info >= (3, 14): def __eq__(self, value: object, /) -> bool: ... def __rand__(self, value: AbstractSet[object], /) -> set[_T]: ... def __ror__(self, value: AbstractSet[_S], /) -> set[_T | _S]: ... # type: ignore[misc] - def __rsub__(self, value: AbstractSet[_T], /) -> set[_T]: ... + def __rsub__(self, value: AbstractSet[_T], /) -> set[_T]: ... # type: ignore[override,misc] def __rxor__(self, value: AbstractSet[_S], /) -> set[_T | _S]: ... # type: ignore[misc] def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 15a5864613d1..d6d3188f64ea 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -704,10 +704,11 @@ class AbstractSet(Collection[_T_co]): def __lt__(self, other: AbstractSet[Any]) -> bool: ... def __gt__(self, other: AbstractSet[Any]) -> bool: ... def __ge__(self, other: AbstractSet[Any]) -> bool: ... - def __and__(self, other: AbstractSet[Any]) -> AbstractSet[_T_co]: ... - def __or__(self, other: AbstractSet[_T]) -> AbstractSet[_T_co | _T]: ... - def __sub__(self, other: AbstractSet[Any]) -> AbstractSet[_T_co]: ... - def __xor__(self, other: AbstractSet[_T]) -> AbstractSet[_T_co | _T]: ... + def __and__(self, other: Iterable[Any]) -> AbstractSet[_T_co]: ... + def __or__(self, other: Iterable[_T]) -> AbstractSet[_T_co | _T]: ... + def __sub__(self, other: Iterable[Any]) -> AbstractSet[_T_co]: ... + def __rsub__(self, other: Iterable[_T]) -> AbstractSet[_T]: ... + def __xor__(self, other: Iterable[_T]) -> AbstractSet[_T_co | _T]: ... def __eq__(self, other: object) -> bool: ... def isdisjoint(self, other: Iterable[Any]) -> bool: ... @@ -720,10 +721,10 @@ class MutableSet(AbstractSet[_T]): def clear(self) -> None: ... def pop(self) -> _T: ... def remove(self, value: _T) -> None: ... - def __ior__(self, it: AbstractSet[_T]) -> typing_extensions.Self: ... # type: ignore[override,misc] - def __iand__(self, it: AbstractSet[Any]) -> typing_extensions.Self: ... - def __ixor__(self, it: AbstractSet[_T]) -> typing_extensions.Self: ... # type: ignore[override,misc] - def __isub__(self, it: AbstractSet[Any]) -> typing_extensions.Self: ... + def __ior__(self, it: Iterable[_T]) -> typing_extensions.Self: ... # type: ignore[override,misc] + def __iand__(self, it: Iterable[Any]) -> typing_extensions.Self: ... + def __ixor__(self, it: Iterable[_T]) -> typing_extensions.Self: ... # type: ignore[override,misc] + def __isub__(self, it: Iterable[Any]) -> typing_extensions.Self: ... class MappingView(Sized): __slots__ = ("_mapping",) diff --git a/stubs/boltons/boltons/setutils.pyi b/stubs/boltons/boltons/setutils.pyi index d86104518841..77263f4c4084 100644 --- a/stubs/boltons/boltons/setutils.pyi +++ b/stubs/boltons/boltons/setutils.pyi @@ -40,7 +40,7 @@ class IndexedSet(MutableSet[Any]): # __sub__ = difference # __xor__ = symmetric_difference __rxor__ = symmetric_difference - def __rsub__(self, other: _RSub[_T_co]) -> _RSub[_T_co]: ... + def __rsub__(self, other: _RSub[_T_co]) -> _RSub[_T_co]: ... # type: ignore[override] def update(self, *others: Iterable[Any]) -> None: ... def intersection_update(self, *others: Iterable[Any]) -> None: ... def difference_update(self, *others: Container[Any]) -> None: ...