mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 13:04:46 +08:00
PEP 604: Add ror operator and modify isinstance and subclass (#5509)
Add operators or and ror for types.Union and ror to the type class. Also, add modified isinstance and issubclass signatures to support old-style and new-style unions inside.
This commit is contained in:
@@ -156,6 +156,7 @@ class type(object):
|
||||
def __prepare__(metacls, __name: str, __bases: Tuple[type, ...], **kwds: Any) -> Mapping[str, Any]: ...
|
||||
if sys.version_info >= (3, 10):
|
||||
def __or__(self, t: Any) -> types.Union: ...
|
||||
def __ror__(self, t: Any) -> types.Union: ...
|
||||
|
||||
class super(object):
|
||||
@overload
|
||||
@@ -1032,8 +1033,19 @@ def iter(__iterable: Iterable[_T]) -> Iterator[_T]: ...
|
||||
def iter(__function: Callable[[], Optional[_T]], __sentinel: None) -> Iterator[_T]: ...
|
||||
@overload
|
||||
def iter(__function: Callable[[], _T], __sentinel: Any) -> Iterator[_T]: ...
|
||||
def isinstance(__obj: object, __class_or_tuple: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ...
|
||||
def issubclass(__cls: type, __class_or_tuple: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ...
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
def isinstance(
|
||||
__obj: object, __class_or_tuple: Union[type, types.Union, Tuple[Union[type, types.Union, Tuple[Any, ...]], ...]]
|
||||
) -> bool: ...
|
||||
def issubclass(
|
||||
__cls: type, __class_or_tuple: Union[type, types.Union, Tuple[Union[type, types.Union, Tuple[Any, ...]], ...]]
|
||||
) -> bool: ...
|
||||
|
||||
else:
|
||||
def isinstance(__obj: object, __class_or_tuple: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ...
|
||||
def issubclass(__cls: type, __class_or_tuple: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ...
|
||||
|
||||
def len(__obj: Sized) -> int: ...
|
||||
def license() -> None: ...
|
||||
def locals() -> Dict[str, Any]: ...
|
||||
|
||||
@@ -352,3 +352,5 @@ if sys.version_info >= (3, 10):
|
||||
NotImplementedType = _NotImplementedType # noqa F811 from builtins
|
||||
class Union:
|
||||
__args__: Tuple[Any, ...]
|
||||
def __or__(self, obj: Any) -> Union: ...
|
||||
def __ror__(self, obj: Any) -> Union: ...
|
||||
|
||||
Reference in New Issue
Block a user