From 54e639e3abe350345faa228b049c7b058a57360f Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 9 Dec 2021 19:26:23 -0800 Subject: [PATCH 1/2] typing comment changes --- stdlib/typing.pyi | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 195645af4dbd..4247f3daf5cb 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -1,4 +1,4 @@ -import collections # Needed by aliases like DefaultDict, see mypy issue 2986 +import collections import sys from abc import ABCMeta, abstractmethod from types import BuiltinFunctionType, CodeType, FrameType, FunctionType, MethodType, ModuleType, TracebackType @@ -10,9 +10,6 @@ if sys.version_info >= (3, 7): if sys.version_info >= (3, 9): from types import GenericAlias -# Definitions of special type checking related constructs. Their definitions -# are not used, so their value does not matter. - Any = object() class TypeVar: @@ -33,6 +30,7 @@ class TypeVar: def __or__(self, other: Any) -> _SpecialForm: ... def __ror__(self, other: Any) -> _SpecialForm: ... +# Used for an undocumented mypy feature. Does not exist at runtime. _promote = object() class _SpecialForm: @@ -271,7 +269,7 @@ class Coroutine(Awaitable[_V_co], Generic[_T_co, _T_contra, _V_co]): @abstractmethod def close(self) -> None: ... -# NOTE: This type does not exist in typing.py or PEP 484. +# NOTE: This type does not exist in typing.py or PEP 484 but mypy needs it to exist. # The parameters correspond to Generator, but the 4th is the original type. class AwaitableGenerator( Awaitable[_V_co], Generator[_T_co, _T_contra, _V_co], Generic[_T_co, _T_contra, _V_co, _S], metaclass=ABCMeta @@ -682,7 +680,6 @@ def cast(typ: object, val: Any) -> Any: ... # Type constructors -# NamedTuple is special-cased in the type checker class NamedTuple(Tuple[Any, ...]): _field_types: collections.OrderedDict[str, Type[Any]] _field_defaults: dict[str, Any] @@ -740,4 +737,4 @@ if sys.version_info >= (3, 7): def __ror__(self, other: Any) -> _SpecialForm: ... if sys.version_info >= (3, 10): - def is_typeddict(tp: Any) -> bool: ... + def is_typeddict(tp: object) -> bool: ... From f1da0943d2380d3a074d963475d58df29331a4b4 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 9 Dec 2021 20:29:00 -0800 Subject: [PATCH 2/2] Update stdlib/typing.pyi --- stdlib/typing.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 4247f3daf5cb..76a818b509aa 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -1,4 +1,4 @@ -import collections +import collections # Needed by aliases like DefaultDict, see mypy issue 2986 import sys from abc import ABCMeta, abstractmethod from types import BuiltinFunctionType, CodeType, FrameType, FunctionType, MethodType, ModuleType, TracebackType