From 78d0cc32dfb3099964ca90d1bd405cc7ebfccac2 Mon Sep 17 00:00:00 2001 From: Semyon Proshev Date: Wed, 22 Mar 2017 17:33:06 +0300 Subject: [PATCH] Add `__new__` to builtin `dict` (#1056) --- stdlib/2/__builtin__.pyi | 4 +++- stdlib/3/builtins.pyi | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index f9370cacf..e8cc5aee1 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -8,7 +8,7 @@ from typing import ( Sequence, Mapping, Tuple, List, Any, Dict, Callable, Generic, Set, AbstractSet, FrozenSet, Sized, Reversible, SupportsInt, SupportsFloat, SupportsAbs, SupportsRound, IO, BinaryIO, Union, AnyStr, MutableSequence, MutableMapping, - MutableSet, ItemsView, KeysView, ValuesView, Optional, Container, + MutableSet, ItemsView, KeysView, ValuesView, Optional, Container, Type ) from abc import abstractmethod, ABCMeta from mypy_extensions import NoReturn @@ -555,6 +555,8 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): @overload def __init__(self, iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... + def __new__(cls: Type[_T1], *args: Any, **kwargs: Any) -> _T1: ... + def has_key(self, k: _KT) -> bool: ... def clear(self) -> None: ... def copy(self) -> Dict[_KT, _VT]: ... diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index 947c5ff82..1c4d02702 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -5,7 +5,7 @@ from typing import ( Sequence, MutableSequence, Mapping, MutableMapping, Tuple, List, Any, Dict, Callable, Generic, Set, AbstractSet, FrozenSet, MutableSet, Sized, Reversible, SupportsInt, SupportsFloat, SupportsBytes, SupportsAbs, SupportsRound, IO, Union, ItemsView, KeysView, ValuesView, - ByteString, Optional, AnyStr, + ByteString, Optional, AnyStr, Type, ) from abc import abstractmethod, ABCMeta from types import TracebackType @@ -609,6 +609,9 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): def __init__(self, map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... @overload def __init__(self, iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... + + def __new__(cls: Type[_T1], *args: Any, **kwargs: Any) -> _T1: ... + def clear(self) -> None: ... def copy(self) -> Dict[_KT, _VT]: ... def popitem(self) -> Tuple[_KT, _VT]: ...