Fix complex constructor (#8473)

This commit is contained in:
Scott Lerman
2022-08-02 17:41:18 -04:00
committed by GitHub
parent fc0a5a26b5
commit 93ebd58055

View File

@@ -364,10 +364,24 @@ class float:
def __bool__(self) -> bool: ...
class complex:
@overload
def __new__(cls: type[Self], real: float = ..., imag: float = ...) -> Self: ...
@overload
def __new__(cls: type[Self], real: str | SupportsComplex | SupportsIndex | complex) -> Self: ...
if sys.version_info >= (3, 8):
# Python doesn't currently accept SupportsComplex for the second argument
@overload
def __new__(
cls: type[Self],
real: complex | SupportsComplex | SupportsFloat | SupportsIndex = ...,
imag: complex | SupportsFloat | SupportsIndex = ...,
) -> Self: ...
@overload
def __new__(cls: type[Self], real: str | SupportsComplex | SupportsFloat | SupportsIndex | complex) -> Self: ...
else:
@overload
def __new__(
cls: type[Self], real: complex | SupportsComplex | SupportsFloat = ..., imag: complex | SupportsFloat = ...
) -> Self: ...
@overload
def __new__(cls: type[Self], real: str | SupportsComplex | SupportsFloat | complex) -> Self: ...
@property
def real(self) -> float: ...
@property