From cd12f6e255596128e4166aeb9c63f9d3a8d19c0a Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Sat, 14 May 2016 19:18:36 +0200 Subject: [PATCH] Add some missing "type" attributes (#200) --- stdlib/2.7/__builtin__.pyi | 8 ++++++++ stdlib/3/builtins.pyi | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/stdlib/2.7/__builtin__.pyi b/stdlib/2.7/__builtin__.pyi index a93555ddd..3b1335a05 100644 --- a/stdlib/2.7/__builtin__.pyi +++ b/stdlib/2.7/__builtin__.pyi @@ -40,6 +40,7 @@ class object: def __hash__(self) -> int: ... class type: + __bases__ = ... # type: Tuple[type, ...] __name__ = ... # type: str __module__ = ... # type: str __dict__ = ... # type: Dict[unicode, Any] @@ -55,6 +56,13 @@ class type: def __new__(cls, name: str, bases: Tuple[type, ...], namespace: Dict[str, Any]) -> type: ... def __call__(self, *args: Any, **kwds: Any) -> Any: ... + # Only new-style classes + __mro__ = ... # type: Tuple[type, ...] + # Note: the documentation doesnt specify what the return type is, the standard + # implementation seems to be returning a list. + def mro(self) -> List[type]: ... + def __subclasses__(self) -> List[type]: ... + class int(SupportsInt, SupportsFloat, SupportsAbs[int]): @overload def __init__(self) -> None: ... diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index f7e8562e1..02727f9b5 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -40,10 +40,12 @@ class object: def __hash__(self) -> int: ... class type: + __bases__ = ... # type: Tuple[type, ...] __name__ = ... # type: str __qualname__ = ... # type: str __module__ = ... # type: str __dict__ = ... # type: Dict[str, Any] + __mro__ = ... # type: Tuple[type, ...] @overload def __init__(self, o: object) -> None: ... @@ -54,6 +56,10 @@ class type: @overload def __new__(cls, name: str, bases: Tuple[type, ...], namespace: Dict[str, Any]) -> type: ... def __call__(self, *args: Any, **kwds: Any) -> Any: ... + def __subclasses__(self) -> List[type]: ... + # Note: the documentation doesnt specify what the return type is, the standard + # implementation seems to be returning a list. + def mro(self) -> List[type]: ... class int(SupportsInt, SupportsFloat, SupportsAbs[int]): def __init__(self, x: Union[SupportsInt, str, bytes] = None, base: int = None) -> None: ...