From dbcb38a60546af07d10e45b94f769e569e3fd714 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 16 Jan 2022 14:45:11 +0000 Subject: [PATCH] Add more missing methods to `os._Environ` (#6926) --- stdlib/os/__init__.pyi | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 090928f67..3341c50f6 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -46,6 +46,8 @@ if sys.version_info >= (3, 9): path = _path _T = TypeVar("_T") +_T1 = TypeVar("_T1") +_T2 = TypeVar("_T2") _AnyStr_co = TypeVar("_AnyStr_co", str, bytes, covariant=True) # ----- os variables ----- @@ -246,9 +248,12 @@ class _Environ(MutableMapping[AnyStr, AnyStr], Generic[AnyStr]): def __iter__(self) -> Iterator[AnyStr]: ... def __len__(self) -> int: ... if sys.version_info >= (3, 9): + def __or__(self, value: Mapping[_T1, _T2]) -> dict[AnyStr | _T1, AnyStr | _T2]: ... + def __ror__(self, value: Mapping[_T1, _T2]) -> dict[AnyStr | _T1, AnyStr | _T2]: ... # We use @overload instead of a Union for reasons similar to those given for # overloading MutableMapping.update in stdlib/typing.pyi - @overload + # The type: ignore is needed due to incompatible __or__/__ior__ signatures + @overload # type: ignore[misc] def __ior__(self: Self, value: Mapping[AnyStr, AnyStr]) -> Self: ... @overload def __ior__(self: Self, value: Iterable[tuple[AnyStr, AnyStr]]) -> Self: ...