mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 20:24:30 +08:00
Add types and functions in types.py that are new in 3.7 (#3066)
* Add types and functions in types.py that are new in 3.7 * Update `resolve_bases` to accept any iterable of objects, and the same for `new_class` if the version is at least 3.7 * Add comparison overrides implemented by MethodWrapperType * Fix mypy error due to over-constrained `__eq__`
This commit is contained in:
committed by
Jelle Zijlstra
parent
1763f51c0d
commit
58221cf20e
@@ -6,7 +6,7 @@
|
||||
import sys
|
||||
from typing import (
|
||||
Any, Awaitable, Callable, Dict, Generic, Iterator, Mapping, Optional, Tuple, TypeVar,
|
||||
Union, overload, Type
|
||||
Union, overload, Type, Iterable
|
||||
)
|
||||
|
||||
# ModuleType is exported from this module, but for circular import
|
||||
@@ -156,6 +156,38 @@ class BuiltinFunctionType:
|
||||
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||
BuiltinMethodType = BuiltinFunctionType
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
class WrapperDescriptorType:
|
||||
__name__: str
|
||||
__qualname__: str
|
||||
__objclass__: type
|
||||
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||
def __get__(self, obj: Any, type: type = ...) -> Any: ...
|
||||
|
||||
class MethodWrapperType:
|
||||
__self__: object
|
||||
__name__: str
|
||||
__qualname__: str
|
||||
__objclass__: type
|
||||
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||
def __eq__(self, other: Any) -> bool: ...
|
||||
def __ne__(self, other: Any) -> bool: ...
|
||||
|
||||
class MethodDescriptorType:
|
||||
__name__: str
|
||||
__qualname__: str
|
||||
__objclass__: type
|
||||
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||
def __get__(self, obj: Any, type: type = ...) -> Any: ...
|
||||
|
||||
class ClassMethodDescriptorType:
|
||||
__name__: str
|
||||
__qualname__: str
|
||||
__objclass__: type
|
||||
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||
def __get__(self, obj: Any, type: type = ...) -> Any: ...
|
||||
|
||||
|
||||
class TracebackType:
|
||||
if sys.version_info >= (3, 7):
|
||||
def __init__(self, tb_next: Optional[TracebackType], tb_frame: FrameType, tb_lasti: int, tb_lineno: int) -> None: ...
|
||||
@@ -199,7 +231,11 @@ class MemberDescriptorType:
|
||||
def __set__(self, obj: Any) -> None: ...
|
||||
def __delete__(self, obj: Any) -> None: ...
|
||||
|
||||
def new_class(name: str, bases: Tuple[type, ...] = ..., kwds: Dict[str, Any] = ..., exec_body: Callable[[Dict[str, Any]], None] = ...) -> type: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def new_class(name: str, bases: Iterable[object] = ..., kwds: Dict[str, Any] = ..., exec_body: Callable[[Dict[str, Any]], None] = ...) -> type: ...
|
||||
def resolve_bases(bases: Iterable[object]) -> Tuple[Any, ...]: ...
|
||||
else:
|
||||
def new_class(name: str, bases: Tuple[type, ...] = ..., kwds: Dict[str, Any] = ..., exec_body: Callable[[Dict[str, Any]], None] = ...) -> type: ...
|
||||
def prepare_class(name: str, bases: Tuple[type, ...] = ..., kwds: Dict[str, Any] = ...) -> Tuple[type, Dict[str, Any], Dict[str, Any]]: ...
|
||||
|
||||
# Actually a different type, but `property` is special and we want that too.
|
||||
|
||||
Reference in New Issue
Block a user