Improve the accuracy of (default)dict.__(r)or__ (#10679)

This commit is contained in:
Alex Waygood
2023-09-08 11:22:17 +01:00
committed by GitHub
parent aa39b996e9
commit 6eec191739
4 changed files with 143 additions and 8 deletions

View File

@@ -1120,13 +1120,13 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
if sys.version_info >= (3, 9):
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
@overload
def __or__(self, __value: Mapping[_KT, _VT]) -> dict[_KT, _VT]: ...
def __or__(self, __value: dict[_KT, _VT]) -> dict[_KT, _VT]: ...
@overload
def __or__(self, __value: Mapping[_T1, _T2]) -> dict[_KT | _T1, _VT | _T2]: ...
def __or__(self, __value: dict[_T1, _T2]) -> dict[_KT | _T1, _VT | _T2]: ...
@overload
def __ror__(self, __value: Mapping[_KT, _VT]) -> dict[_KT, _VT]: ...
def __ror__(self, __value: dict[_KT, _VT]) -> dict[_KT, _VT]: ...
@overload
def __ror__(self, __value: Mapping[_T1, _T2]) -> dict[_KT | _T1, _VT | _T2]: ...
def __ror__(self, __value: dict[_T1, _T2]) -> dict[_KT | _T1, _VT | _T2]: ...
# dict.__ior__ should be kept roughly in line with MutableMapping.update()
@overload # type: ignore[misc]
def __ior__(self, __value: SupportsKeysAndGetItem[_KT, _VT]) -> Self: ...