From df6f701ba4af1a09db7862ece7164d578df0087f Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Thu, 6 Jan 2022 22:43:04 +0000 Subject: [PATCH] builtins: Fix from_bytes() and fromhex() return type (#6842) --- stdlib/builtins.pyi | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index d4b986127..454479b06 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -206,8 +206,12 @@ class int: def to_bytes(self, length: SupportsIndex, byteorder: Literal["little", "big"], *, signed: bool = ...) -> bytes: ... @classmethod def from_bytes( - cls, bytes: Iterable[SupportsIndex] | SupportsBytes, byteorder: Literal["little", "big"], *, signed: bool = ... - ) -> int: ... # TODO buffer object argument + cls: Type[Self], + bytes: Iterable[SupportsIndex] | SupportsBytes, # TODO buffer object argument + byteorder: Literal["little", "big"], + *, + signed: bool = ..., + ) -> Self: ... def __add__(self, __x: int) -> int: ... def __sub__(self, __x: int) -> int: ... def __mul__(self, __x: int) -> int: ... @@ -273,7 +277,7 @@ class float: def hex(self) -> str: ... def is_integer(self) -> bool: ... @classmethod - def fromhex(cls, __s: str) -> float: ... + def fromhex(cls: Type[Self], __s: str) -> Self: ... @property def real(self) -> float: ... @property @@ -518,7 +522,7 @@ class bytes(ByteString): def upper(self) -> bytes: ... def zfill(self, __width: SupportsIndex) -> bytes: ... @classmethod - def fromhex(cls: Type[_T], __s: str) -> _T: ... + def fromhex(cls: Type[Self], __s: str) -> Self: ... @staticmethod def maketrans(__frm: bytes, __to: bytes) -> bytes: ... def __len__(self) -> int: ... @@ -622,7 +626,7 @@ class bytearray(MutableSequence[int], ByteString): def upper(self) -> bytearray: ... def zfill(self, __width: SupportsIndex) -> bytearray: ... @classmethod - def fromhex(cls, __string: str) -> bytearray: ... + def fromhex(cls: Type[Self], __string: str) -> Self: ... @staticmethod def maketrans(__frm: bytes, __to: bytes) -> bytes: ... def __len__(self) -> int: ...