From fb5783e2fc89aca27a9d34e6b971a82481df9c7d Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Tue, 15 Oct 2019 22:14:05 +0200 Subject: [PATCH 1/2] Add PEP 593 (Annotated etc.) typing_extensions stubs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code has been added to typing_extensions in https://github.com/python/typing/pull/632 and https://github.com/python/typing/pull/639/. I really didn't know how to type Annotated and _AnnotatedAlias here – feel free to correct this. --- third_party/2and3/typing_extensions.pyi | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/third_party/2and3/typing_extensions.pyi b/third_party/2and3/typing_extensions.pyi index ef36d125cf7e..f3e669407d4d 100644 --- a/third_party/2and3/typing_extensions.pyi +++ b/third_party/2and3/typing_extensions.pyi @@ -12,7 +12,7 @@ from typing import overload as overload from typing import Text as Text from typing import Type as Type from typing import TYPE_CHECKING as TYPE_CHECKING -from typing import TypeVar, Any, Mapping, ItemsView, KeysView, ValuesView, Dict, Type +from typing import TypeVar, Any, Mapping, ItemsView, KeysView, Optional, ValuesView, Dict, Type _T = TypeVar('_T') _F = TypeVar('_F', bound=Callable[..., Any]) @@ -59,3 +59,11 @@ if sys.version_info >= (3, 5): if sys.version_info >= (3, 6): from typing import AsyncGenerator as AsyncGenerator + +def get_type_hints( + obj: Callable[..., Any], globalns: Optional[Dict[str, Any]] = ..., localns: Optional[Dict[str, Any]] = ..., + include_extras: bool = ... +) -> Dict[str, Any]: ... + +Annotated: _SpecialForm = ... +_AnnotatedAlias: Any = ... From b1e0dcf0457e81c57ea14341c3c38869a0469c3a Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Wed, 16 Oct 2019 17:05:32 +0200 Subject: [PATCH 2/2] Mention that _AnnotatedAlias is undocumented --- third_party/2and3/typing_extensions.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/2and3/typing_extensions.pyi b/third_party/2and3/typing_extensions.pyi index f3e669407d4d..edf40d67569f 100644 --- a/third_party/2and3/typing_extensions.pyi +++ b/third_party/2and3/typing_extensions.pyi @@ -66,4 +66,4 @@ def get_type_hints( ) -> Dict[str, Any]: ... Annotated: _SpecialForm = ... -_AnnotatedAlias: Any = ... +_AnnotatedAlias: Any = ... # undocumented