Add __complex__ to complex (#2004)

* Add __complex__ to complex

complex SupportsComplex!

* Allow constructing complex from SupportsComplex
This commit is contained in:
Alan Du
2018-04-03 10:14:52 -04:00
committed by Jelle Zijlstra
parent 8e3182dafa
commit bd26c7bf84
2 changed files with 9 additions and 3 deletions

View File

@@ -4,8 +4,8 @@ from typing import (
TypeVar, Iterator, Iterable, overload, Container,
Sequence, MutableSequence, Mapping, MutableMapping, NoReturn, 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, Type,
SupportsComplex, SupportsBytes, SupportsAbs, SupportsRound, IO, Union, ItemsView, KeysView,
ValuesView, ByteString, Optional, AnyStr, Type,
)
from abc import abstractmethod, ABCMeta
from types import TracebackType, CodeType
@@ -204,6 +204,8 @@ class complex:
def __init__(self, re: float = ..., im: float = ...) -> None: ...
@overload
def __init__(self, s: str) -> None: ...
@overload
def __init__(self, s: SupportsComplex) -> None: ...
@property
def real(self) -> float: ...
@@ -229,6 +231,7 @@ class complex:
def __pos__(self) -> complex: ...
def __str__(self) -> str: ...
def __complex__(self) -> complex: ...
def __abs__(self) -> float: ...
def __hash__(self) -> int: ...
def __bool__(self) -> bool: ...