ContextVar.get() default has wrong type, it should mirror Mapping.get (#4726)

This commit is contained in:
Jason Fried
2020-10-29 13:40:55 -07:00
committed by GitHub
parent eb2fff7a92
commit f5a536b505
2 changed files with 7 additions and 2 deletions

View File

@@ -1,16 +1,20 @@
import sys
from typing import Any, Callable, ClassVar, Generic, Iterator, Mapping, TypeVar
from typing import Any, Callable, ClassVar, Generic, Iterator, Mapping, TypeVar, Union, overload
if sys.version_info >= (3, 9):
from types import GenericAlias
_T = TypeVar("_T")
_D = TypeVar("_D")
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: Union[_D, _T]) -> Union[_D, _T]: ...
def set(self, value: _T) -> Token[_T]: ...
def reset(self, token: Token[_T]) -> None: ...
if sys.version_info >= (3, 9):

View File

@@ -23,6 +23,7 @@ collections.abc.AsyncGenerator.ag_frame
collections.abc.AsyncGenerator.ag_running
contextvars.Context.__init__
contextvars.Context.get
contextvars.ContextVar.get
copy.PyStringMap
ctypes.CDLL.__init__
dataclasses.Field.__init__