diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index 526cdbd88024..277451ca5cca 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -181,9 +181,9 @@ class super(object): class int: @overload - def __init__(self, x: Union[Text, bytes, SupportsInt, _SupportsIndex] = ...) -> None: ... + def __new__(cls: Type[_T], x: Union[Text, bytes, SupportsInt, _SupportsIndex] = ...) -> _T: ... @overload - def __init__(self, x: Union[Text, bytes, bytearray], base: int) -> None: ... + def __new__(cls: Type[_T], x: Union[Text, bytes, bytearray], base: int) -> _T: ... if sys.version_info >= (3, 8): def as_integer_ratio(self) -> Tuple[int, Literal[1]]: ... @property @@ -262,7 +262,7 @@ class int: def __index__(self) -> int: ... class float: - def __init__(self, x: Union[SupportsFloat, _SupportsIndex, Text, bytes, bytearray] = ...) -> None: ... + def __new__(cls: Type[_T], x: Union[SupportsFloat, _SupportsIndex, Text, bytes, bytearray] = ...) -> _T: ... def as_integer_ratio(self) -> Tuple[int, int]: ... def hex(self) -> str: ... def is_integer(self) -> bool: ... @@ -325,9 +325,9 @@ class float: class complex: @overload - def __init__(self, real: float = ..., imag: float = ...) -> None: ... + def __new__(cls: Type[_T], real: float = ..., imag: float = ...) -> _T: ... @overload - def __init__(self, real: Union[str, SupportsComplex, _SupportsIndex]) -> None: ... + def __new__(cls: Type[_T], real: Union[str, SupportsComplex, _SupportsIndex]) -> _T: ... @property def real(self) -> float: ... @property @@ -446,9 +446,9 @@ class _FormatMapMapping(Protocol): class str(Sequence[str], _str_base): if sys.version_info >= (3,): @overload - def __init__(self, o: object = ...) -> None: ... + def __new__(cls: Type[_T], o: object = ...) -> _T: ... @overload - def __init__(self, o: bytes, encoding: str = ..., errors: str = ...) -> None: ... + def __new__(cls: Type[_T], o: bytes, encoding: str = ..., errors: str = ...) -> _T: ... else: def __init__(self, o: object = ...) -> None: ... def capitalize(self) -> str: ... @@ -596,15 +596,15 @@ class str(Sequence[str], _str_base): if sys.version_info >= (3,): class bytes(ByteString): @overload - def __init__(self, ints: Iterable[int]) -> None: ... + def __new__(cls: Type[_T], ints: Iterable[int]) -> _T: ... @overload - def __init__(self, string: str, encoding: str, errors: str = ...) -> None: ... + def __new__(cls: Type[_T], string: str, encoding: str, errors: str = ...) -> _T: ... @overload - def __init__(self, length: int) -> None: ... + def __new__(cls: Type[_T], length: int) -> _T: ... @overload - def __init__(self) -> None: ... + def __new__(cls: Type[_T]) -> _T: ... @overload - def __init__(self, o: SupportsBytes) -> None: ... + def __new__(cls: Type[_T], o: SupportsBytes) -> _T: ... def capitalize(self) -> bytes: ... def center(self, __width: int, __fillchar: bytes = ...) -> bytes: ... def count(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ... diff --git a/stdlib/2and3/builtins.pyi b/stdlib/2and3/builtins.pyi index 526cdbd88024..277451ca5cca 100644 --- a/stdlib/2and3/builtins.pyi +++ b/stdlib/2and3/builtins.pyi @@ -181,9 +181,9 @@ class super(object): class int: @overload - def __init__(self, x: Union[Text, bytes, SupportsInt, _SupportsIndex] = ...) -> None: ... + def __new__(cls: Type[_T], x: Union[Text, bytes, SupportsInt, _SupportsIndex] = ...) -> _T: ... @overload - def __init__(self, x: Union[Text, bytes, bytearray], base: int) -> None: ... + def __new__(cls: Type[_T], x: Union[Text, bytes, bytearray], base: int) -> _T: ... if sys.version_info >= (3, 8): def as_integer_ratio(self) -> Tuple[int, Literal[1]]: ... @property @@ -262,7 +262,7 @@ class int: def __index__(self) -> int: ... class float: - def __init__(self, x: Union[SupportsFloat, _SupportsIndex, Text, bytes, bytearray] = ...) -> None: ... + def __new__(cls: Type[_T], x: Union[SupportsFloat, _SupportsIndex, Text, bytes, bytearray] = ...) -> _T: ... def as_integer_ratio(self) -> Tuple[int, int]: ... def hex(self) -> str: ... def is_integer(self) -> bool: ... @@ -325,9 +325,9 @@ class float: class complex: @overload - def __init__(self, real: float = ..., imag: float = ...) -> None: ... + def __new__(cls: Type[_T], real: float = ..., imag: float = ...) -> _T: ... @overload - def __init__(self, real: Union[str, SupportsComplex, _SupportsIndex]) -> None: ... + def __new__(cls: Type[_T], real: Union[str, SupportsComplex, _SupportsIndex]) -> _T: ... @property def real(self) -> float: ... @property @@ -446,9 +446,9 @@ class _FormatMapMapping(Protocol): class str(Sequence[str], _str_base): if sys.version_info >= (3,): @overload - def __init__(self, o: object = ...) -> None: ... + def __new__(cls: Type[_T], o: object = ...) -> _T: ... @overload - def __init__(self, o: bytes, encoding: str = ..., errors: str = ...) -> None: ... + def __new__(cls: Type[_T], o: bytes, encoding: str = ..., errors: str = ...) -> _T: ... else: def __init__(self, o: object = ...) -> None: ... def capitalize(self) -> str: ... @@ -596,15 +596,15 @@ class str(Sequence[str], _str_base): if sys.version_info >= (3,): class bytes(ByteString): @overload - def __init__(self, ints: Iterable[int]) -> None: ... + def __new__(cls: Type[_T], ints: Iterable[int]) -> _T: ... @overload - def __init__(self, string: str, encoding: str, errors: str = ...) -> None: ... + def __new__(cls: Type[_T], string: str, encoding: str, errors: str = ...) -> _T: ... @overload - def __init__(self, length: int) -> None: ... + def __new__(cls: Type[_T], length: int) -> _T: ... @overload - def __init__(self) -> None: ... + def __new__(cls: Type[_T]) -> _T: ... @overload - def __init__(self, o: SupportsBytes) -> None: ... + def __new__(cls: Type[_T], o: SupportsBytes) -> _T: ... def capitalize(self) -> bytes: ... def center(self, __width: int, __fillchar: bytes = ...) -> bytes: ... def count(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ... diff --git a/tests/stubtest_whitelists/py3_common.txt b/tests/stubtest_whitelists/py3_common.txt index 375f9002cf32..362b6c056b87 100644 --- a/tests/stubtest_whitelists/py3_common.txt +++ b/tests/stubtest_whitelists/py3_common.txt @@ -412,6 +412,28 @@ zipfile.ZipExtFile.read zipfile.ZipExtFile.readline zlib.compressobj +# These enums derive from (int, IntEnum) or (str, Enum). Strangely, +# at runtime, they inherit Enum.__new__, not int.__new__ or +# str.__new__ as the mro would dictate, which is why stubtest balks. +enum.IntEnum.__new__ +enum.IntFlag.__new__ +http.HTTPStatus.__new__ +inspect._ParameterKind.__new__ +pstats.SortKey.__new__ +re.RegexFlag.__new__ +signal.Handlers.__new__ +signal.Sigmasks.__new__ +signal.Signals.__new__ +socket.AddressFamily.__new__ +socket.AddressInfo.__new__ +socket.MsgFlag.__new__ +socket.SocketKind.__new__ +ssl.Options.__new__ +ssl.TLSVersion.__new__ +ssl.VerifyFlags.__new__ +ssl.VerifyMode.__new__ +tkinter.EventType.__new__ + # ========== # Whitelist entries that cannot or should not be fixed # ==========