From 9e023e7586d0d690f8894693998555415a1ac155 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 18 Aug 2018 19:47:10 -0700 Subject: [PATCH] minor namedtuple fixes (#2227) - The extra arguments aren't keyword-only in 2.7. - Added the `defaults` argument in 3.7 (https://docs.python.org/3.7/library/collections.html#collections.namedtuple). --- stdlib/2/collections.pyi | 7 +------ stdlib/3/collections/__init__.pyi | 6 +----- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/stdlib/2/collections.pyi b/stdlib/2/collections.pyi index b8963c6f6..f61046e1c 100644 --- a/stdlib/2/collections.pyi +++ b/stdlib/2/collections.pyi @@ -1,9 +1,4 @@ -# Stubs for collections - -# Based on http://docs.python.org/2.7/library/collections.html - # These are not exported. -import typing from typing import Dict, Generic, TypeVar, Tuple, overload, Type, Optional, List, Union, Reversible # These are exported. @@ -31,7 +26,7 @@ _KT = TypeVar('_KT') _VT = TypeVar('_VT') # namedtuple is special-cased in the type checker; the initializer is ignored. -def namedtuple(typename: Union[str, unicode], field_names: Union[str, unicode, Iterable[Union[str, unicode]]], *, +def namedtuple(typename: Union[str, unicode], field_names: Union[str, unicode, Iterable[Union[str, unicode]]], verbose: bool = ..., rename: bool = ...) -> Type[tuple]: ... class deque(Sized, Iterable[_T], Reversible[_T], Generic[_T]): diff --git a/stdlib/3/collections/__init__.pyi b/stdlib/3/collections/__init__.pyi index d8fdbda97..4aa0f6a92 100644 --- a/stdlib/3/collections/__init__.pyi +++ b/stdlib/3/collections/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for collections - -# Based on http://docs.python.org/3.2/library/collections.html - # These are not exported. import sys import typing @@ -54,7 +50,7 @@ _VT = TypeVar('_VT') # namedtuple is special-cased in the type checker; the initializer is ignored. if sys.version_info >= (3, 7): def namedtuple(typename: str, field_names: Union[str, Iterable[str]], *, - rename: bool = ..., module: Optional[str] = ...) -> Type[tuple]: ... + rename: bool = ..., module: Optional[str] = ..., defaults: Optional[Iterable[Any]] = ...) -> Type[tuple]: ... elif sys.version_info >= (3, 6): def namedtuple(typename: str, field_names: Union[str, Iterable[str]], *, verbose: bool = ..., rename: bool = ..., module: Optional[str] = ...) -> Type[tuple]: ...