Improve __(r)or__ signatures for TypedDict classes (#10565)

This commit is contained in:
Alex Waygood
2023-08-12 18:27:35 +01:00
committed by GitHub
parent 7836c47286
commit df08fcec5f
8 changed files with 29 additions and 44 deletions

View File

@@ -233,8 +233,16 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
def values(self) -> dict_values[str, object]: ...
def __delitem__(self, k: Never) -> None: ...
if sys.version_info >= (3, 9):
@overload
def __or__(self, __value: Self) -> Self: ...
def __ior__(self, __value: Self) -> Self: ...
@overload
def __or__(self, __value: dict[str, Any]) -> dict[str, object]: ...
@overload
def __ror__(self, __value: Self) -> Self: ...
@overload
def __ror__(self, __value: dict[str, Any]) -> dict[str, object]: ...
# supposedly incompatible definitions of `__ior__` and `__or__`:
def __ior__(self, __value: Self) -> Self: ... # type: ignore[misc]
# TypedDict is a (non-subscriptable) special form.
TypedDict: object