From f21b53e2ae259a5ee0167972f92ce31f943885f9 Mon Sep 17 00:00:00 2001 From: Elazar Gershuni Date: Tue, 13 Sep 2016 19:57:37 +0300 Subject: [PATCH 1/8] update nameduple() to function signature + module --- stdlib/3/collections/__init__.pyi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stdlib/3/collections/__init__.pyi b/stdlib/3/collections/__init__.pyi index 0dc340e2c069..ec808eed488b 100644 --- a/stdlib/3/collections/__init__.pyi +++ b/stdlib/3/collections/__init__.pyi @@ -25,7 +25,9 @@ _VT = TypeVar('_VT') # namedtuple is special-cased in the type checker; the initializer is ignored. -namedtuple = object() +def namedtuple(typename: str, field_names: Union[str, Iterable[Any]], *, + verbose: bool = ..., rename: bool = ..., module: str = None) -> Type[tuple]: ... + class UserDict(MutableMapping): ... class UserList(MutableSequence): ... From e55bc2c3ca00993a090e7288738998294ccc7ac3 Mon Sep 17 00:00:00 2001 From: Elazar Gershuni Date: Tue, 13 Sep 2016 20:04:14 +0300 Subject: [PATCH 2/8] update NamedTuple() to function signature + module --- stdlib/3/typing.pyi | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index d5389962aa13..5c538e1c144d 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -16,7 +16,6 @@ Callable = object() Type = object() builtinclass = object() _promote = object() -NamedTuple = object() no_type_check = object() NewType = object() @@ -418,3 +417,11 @@ class Pattern(Generic[AnyStr]): # Functions def get_type_hints(obj: Callable) -> dict[str, Any]: ... + + +# Type constructors + +# The special-cased in the type checker; the initializer is ignored. +def NamedTuple(typename: str, fields: Iterable[Tuple[str, Any]], *, + verbose: bool = ..., rename: bool = ..., module: str = None) -> Type[tuple]: ... + From 4a10dbcbba7d837afdf4bc2f45c1f15581bb0154 Mon Sep 17 00:00:00 2001 From: Elazar Date: Tue, 13 Sep 2016 20:18:51 +0300 Subject: [PATCH 3/8] Oops --- stdlib/3/typing.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index 5c538e1c144d..5c7a5f4e9c36 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -421,7 +421,7 @@ def get_type_hints(obj: Callable) -> dict[str, Any]: ... # Type constructors -# The special-cased in the type checker; the initializer is ignored. +# NamedTuple is special-cased in the type checker; the initializer is ignored. def NamedTuple(typename: str, fields: Iterable[Tuple[str, Any]], *, verbose: bool = ..., rename: bool = ..., module: str = None) -> Type[tuple]: ... From 7db7dccd1f6be6d08540f0985bc1b7fa72689bcc Mon Sep 17 00:00:00 2001 From: Elazar Date: Tue, 13 Sep 2016 20:23:03 +0300 Subject: [PATCH 4/8] import Any, Type --- stdlib/3/collections/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3/collections/__init__.pyi b/stdlib/3/collections/__init__.pyi index ec808eed488b..706e444e2727 100644 --- a/stdlib/3/collections/__init__.pyi +++ b/stdlib/3/collections/__init__.pyi @@ -7,7 +7,7 @@ # These are not exported. from typing import ( TypeVar, Iterable, Generic, Iterator, Dict, overload, - Mapping, List, Tuple, Callable, Sized, + Mapping, List, Tuple, Callable, Sized, Any, Type, Optional, Union ) # These are exported. From 0162ef2fd448afdc8c4a1c5e4801e6464b931de9 Mon Sep 17 00:00:00 2001 From: Elazar Gershuni Date: Tue, 13 Sep 2016 20:41:56 +0300 Subject: [PATCH 5/8] remove blank lines --- stdlib/3/collections/__init__.pyi | 1 - stdlib/3/typing.pyi | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/stdlib/3/collections/__init__.pyi b/stdlib/3/collections/__init__.pyi index ec808eed488b..9a31eeac9e5f 100644 --- a/stdlib/3/collections/__init__.pyi +++ b/stdlib/3/collections/__init__.pyi @@ -28,7 +28,6 @@ _VT = TypeVar('_VT') def namedtuple(typename: str, field_names: Union[str, Iterable[Any]], *, verbose: bool = ..., rename: bool = ..., module: str = None) -> Type[tuple]: ... - class UserDict(MutableMapping): ... class UserList(MutableSequence): ... class UserString(Sequence): ... diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index 5c538e1c144d..61056b891141 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -418,10 +418,9 @@ class Pattern(Generic[AnyStr]): def get_type_hints(obj: Callable) -> dict[str, Any]: ... - # Type constructors -# The special-cased in the type checker; the initializer is ignored. +# Namedtuple is special-cased in the type checker; the initializer is ignored. def NamedTuple(typename: str, fields: Iterable[Tuple[str, Any]], *, verbose: bool = ..., rename: bool = ..., module: str = None) -> Type[tuple]: ... From 089f1388fa3198131a78bee0256b9ba36bfb8ac5 Mon Sep 17 00:00:00 2001 From: Elazar Gershuni Date: Tue, 13 Sep 2016 20:45:22 +0300 Subject: [PATCH 6/8] namedtuple() in 2.7 --- stdlib/2.7/collections.pyi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stdlib/2.7/collections.pyi b/stdlib/2.7/collections.pyi index 9d4624301dcc..4d004fda7427 100644 --- a/stdlib/2.7/collections.pyi +++ b/stdlib/2.7/collections.pyi @@ -7,7 +7,7 @@ # NOTE: These are incomplete! from typing import ( - Any, Dict, Generic, TypeVar, Iterable, Tuple, Callable, Mapping, overload, Iterator, + Any, Dict, Generic, TypeVar, Iterable, Tuple, Callable, Mapping, overload, Iterator, Type, Sized, Optional, List, Set, Sequence, Union, Reversible, MutableMapping, MutableSequence ) import typing @@ -17,7 +17,8 @@ _KT = TypeVar('_KT') _VT = TypeVar('_VT') # namedtuple is special-cased in the type checker; the initializer is ignored. -namedtuple = ... # type: Any +def namedtuple(typename: str, field_names: Union[str, Iterable[Any]], *, + verbose: bool = ..., rename: bool = ...) -> Type[tuple]: ... class deque(Sized, Iterable[_T], Reversible[_T], Generic[_T]): def __init__(self, iterable: Iterable[_T] = ..., From 0000ed146134fbe92e3c71d820ca4605f90f4917 Mon Sep 17 00:00:00 2001 From: Elazar Date: Wed, 14 Sep 2016 00:00:01 +0300 Subject: [PATCH 7/8] killed --- stdlib/3/typing.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index 1210f38ec204..baa3a8e97b40 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -423,4 +423,3 @@ def get_type_hints(obj: Callable) -> dict[str, Any]: ... # NamedTuple is special-cased in the type checker; the initializer is ignored. def NamedTuple(typename: str, fields: Iterable[Tuple[str, Any]], *, verbose: bool = ..., rename: bool = ..., module: str = None) -> Type[tuple]: ... - From 7ad6105dc3e55babfd4447edd6ddcbecbd14f383 Mon Sep 17 00:00:00 2001 From: Elazar Gershuni Date: Wed, 14 Sep 2016 00:04:23 +0300 Subject: [PATCH 8/8] add NamedTuple sig to 2.7/typing.pyi --- stdlib/2.7/typing.pyi | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/stdlib/2.7/typing.pyi b/stdlib/2.7/typing.pyi index e8aa48a6f1ef..47ec651e89aa 100644 --- a/stdlib/2.7/typing.pyi +++ b/stdlib/2.7/typing.pyi @@ -15,7 +15,6 @@ Callable = object() Type = object() builtinclass = object() _promote = object() -NamedTuple = object() NewType = object() # Type aliases @@ -348,3 +347,9 @@ class Pattern(Generic[AnyStr]): # Functions def get_type_hints(obj: Callable) -> dict[str, Any]: ... + +# Type constructors + +# NamedTuple is special-cased in the type checker; the initializer is ignored. +def NamedTuple(typename: str, fields: Iterable[Tuple[str, Any]], *, + verbose: bool = ..., rename: bool = ...) -> Type[tuple]: ...