From a0b2583bb1b797e4d9420373efdf13d81a545324 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 25 Sep 2023 14:47:02 +0100 Subject: [PATCH] Add `OrderedDict.__(r)or__` (#10770) --- stdlib/collections/__init__.pyi | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 3b8d92f78..1d560117a 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -373,6 +373,15 @@ class OrderedDict(dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]): @overload def setdefault(self, key: _KT, default: _VT) -> _VT: ... def __eq__(self, __value: object) -> bool: ... + if sys.version_info >= (3, 9): + @overload + def __or__(self, __value: dict[_KT, _VT]) -> Self: ... + @overload + def __or__(self, __value: dict[_T1, _T2]) -> OrderedDict[_KT | _T1, _VT | _T2]: ... + @overload + def __ror__(self, __value: dict[_KT, _VT]) -> Self: ... + @overload + def __ror__(self, __value: dict[_T1, _T2]) -> OrderedDict[_KT | _T1, _VT | _T2]: ... # type: ignore[misc] class defaultdict(dict[_KT, _VT], Generic[_KT, _VT]): default_factory: Callable[[], _VT] | None