From e629cf503948ddf8e553016d51bc7a661589f6aa Mon Sep 17 00:00:00 2001 From: Stephen Morton Date: Mon, 21 Oct 2024 23:28:44 -0700 Subject: [PATCH] contextvars.Context doesn't inherit from Mapping --- stdlib/contextvars.pyi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/stdlib/contextvars.pyi b/stdlib/contextvars.pyi index dd5ea0acbe2c..62ff9fb184b9 100644 --- a/stdlib/contextvars.pyi +++ b/stdlib/contextvars.pyi @@ -1,5 +1,5 @@ import sys -from collections.abc import Callable, Iterator, Mapping +from collections.abc import Callable, ItemsView, Iterator, KeysView, ValuesView from typing import Any, ClassVar, Generic, TypeVar, final, overload from typing_extensions import ParamSpec @@ -47,7 +47,7 @@ def copy_context() -> Context: ... # It doesn't make sense to make this generic, because for most Contexts each ContextVar will have # a different value. @final -class Context(Mapping[ContextVar[Any], Any]): +class Context: def __init__(self) -> None: ... @overload def get(self, key: ContextVar[_T], default: None = None, /) -> _T | None: ... @@ -61,3 +61,7 @@ class Context(Mapping[ContextVar[Any], Any]): def __iter__(self) -> Iterator[ContextVar[Any]]: ... def __len__(self) -> int: ... def __eq__(self, value: object, /) -> bool: ... + def items(self) -> ItemsView[ContextVar[Any], Any]: ... + def keys(self) -> KeysView[ContextVar[Any]]: ... + def values(self) -> ValuesView[Any]: ... + def __contains__(self, key: object, /) -> bool: ...