contextvars: widen return value of ContextVar.get(default) (#9953)

This commit is contained in:
Jean Hominal
2023-03-27 18:00:54 +02:00
committed by GitHub
parent b9fedd20ce
commit 0c0a58f36d

View File

@@ -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):