mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-19 18:31:14 +08:00
Fix complex constructor (#8473)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user