diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 1a88e708a..23958919d 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -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