From 0c0a58f36d4e9f55a50cd14e48eca720fa679202 Mon Sep 17 00:00:00 2001 From: Jean Hominal Date: Mon, 27 Mar 2023 18:00:54 +0200 Subject: [PATCH] contextvars: widen return value of ContextVar.get(default) (#9953) --- stubs/contextvars/contextvars.pyi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stubs/contextvars/contextvars.pyi b/stubs/contextvars/contextvars.pyi index 044d8a43c..8ce52bdfe 100644 --- a/stubs/contextvars/contextvars.pyi +++ b/stubs/contextvars/contextvars.pyi @@ -7,6 +7,7 @@ if sys.version_info >= (3, 9): from types import GenericAlias _T = TypeVar("_T") +_D = TypeVar("_D") _P = ParamSpec("_P") @final @@ -17,7 +18,10 @@ class ContextVar(Generic[_T]): def __init__(self, name: str, *, default: _T) -> None: ... @property def name(self) -> str: ... - def get(self, default: _T = ...) -> _T: ... + @overload + def get(self) -> _T: ... + @overload + def get(self, default: _D | _T) -> _D | _T: ... def set(self, value: _T) -> Token[_T]: ... def reset(self, token: Token[_T]) -> None: ... if sys.version_info >= (3, 9):