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

@@ -7,7 +7,7 @@ from typing import (
TypeVar, Iterator, Iterable, NoReturn, overload,
Sequence, Mapping, Tuple, List, Any, Dict, Callable, Generic, Set,
AbstractSet, FrozenSet, Sized, Reversible, SupportsInt, SupportsFloat, SupportsAbs,
SupportsRound, IO, BinaryIO, Union, AnyStr, MutableSequence, MutableMapping,
SupportsComplex, SupportsRound, IO, BinaryIO, Union, AnyStr, MutableSequence, MutableMapping,
MutableSet, ItemsView, KeysView, ValuesView, Optional, Container, Type
)
from abc import abstractmethod, ABCMeta
@@ -187,6 +187,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: ...
@@ -213,6 +215,7 @@ class complex:
def __neg__(self) -> complex: ...
def __pos__(self) -> complex: ...
def __complex__(self) -> complex: ...
def __str__(self) -> str: ...
def __abs__(self) -> float: ...
def __hash__(self) -> int: ...

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: ...