mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
contextvars: widen return value of ContextVar.get(default) (#9953)
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user