From 873a24ba9a907a09b4a07498e4bc2773cc8b9ad6 Mon Sep 17 00:00:00 2001 From: Alexander 'z33ky' Hirsch <1zeeky@gmail.com> Date: Thu, 15 Dec 2016 20:21:17 +0100 Subject: [PATCH 1/3] Add special methods for object --- stdlib/2/__builtin__.pyi | 3 +++ stdlib/3/builtins.pyi | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index b6de92b57b8d..0428449ea6ab 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -39,6 +39,9 @@ class object: def __repr__(self) -> str: ... def __hash__(self) -> int: ... + def __getattribute__(self, name: str) -> Any: ... + def __delattr__(self, name: str) -> None: ... + class type: __bases__ = ... # type: Tuple[type, ...] __name__ = ... # type: str diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index 3847506a826a..5bdb6dceb109 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -41,6 +41,10 @@ class object: def __str__(self) -> str: ... def __repr__(self) -> str: ... def __hash__(self) -> int: ... + def __format__(self, format_spec: str) -> str: ... + + def __getattribute__(self, name: str) -> Any: ... + def __delattr__(self, name: str) -> None: ... class type: __bases__ = ... # type: Tuple[type, ...] @@ -638,7 +642,6 @@ class enumerate(Iterator[Tuple[int, _T]], Generic[_T]): def __init__(self, iterable: Iterable[_T], start: int = 0) -> None: ... def __iter__(self) -> Iterator[Tuple[int, _T]]: ... def __next__(self) -> Tuple[int, _T]: ... - # TODO __getattribute__ class range(Sequence[int]): @overload From e12b4186832489479ce977c1ca4b037bd47eb36c Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 3 Jan 2017 16:38:15 -0800 Subject: [PATCH 2/3] Add __format__ to 2/__builtin__.pyi too --- stdlib/2/__builtin__.pyi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index 0428449ea6ab..9e7191ae92bb 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -38,7 +38,7 @@ class object: def __str__(self) -> str: ... def __repr__(self) -> str: ... def __hash__(self) -> int: ... - + def __format__(self, format_spec: str) -> str: ... def __getattribute__(self, name: str) -> Any: ... def __delattr__(self, name: str) -> None: ... @@ -164,7 +164,6 @@ class float(SupportsFloat, SupportsInt, SupportsAbs[float]): def __float__(self) -> float: ... def __abs__(self) -> float: ... def __hash__(self) -> int: ... - def __format__(self, format_spec: AnyStr) -> str: ... class complex(SupportsAbs[float]): @overload From 3b340c6ff7dde317113c396f488d56cc511746b5 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 3 Jan 2017 16:39:01 -0800 Subject: [PATCH 3/3] Remove redundant __format__ from float. --- stdlib/3/builtins.pyi | 2 -- 1 file changed, 2 deletions(-) diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index 5bdb6dceb109..6fce14d94597 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -42,7 +42,6 @@ class object: def __repr__(self) -> str: ... def __hash__(self) -> int: ... def __format__(self, format_spec: str) -> str: ... - def __getattribute__(self, name: str) -> Any: ... def __delattr__(self, name: str) -> None: ... @@ -154,7 +153,6 @@ class float(SupportsFloat, SupportsInt, SupportsAbs[float]): def __float__(self) -> float: ... def __abs__(self) -> float: ... def __hash__(self) -> int: ... - def __format__(self, format_spec: str) -> str: ... class complex(SupportsAbs[float]): @overload