mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 12:14:27 +08:00
Update int.from_bytes to allow more than sequences (#3571)
`int.from_bytes` supports both iterables of ints and objects that define __bytes__'. As an example `int.from_bytes(iter([1, 0]), 'little'))` returns 1.
This commit is contained in:
@@ -157,7 +157,7 @@ class int:
|
||||
if sys.version_info >= (3,):
|
||||
def to_bytes(self, length: int, byteorder: str, *, signed: bool = ...) -> bytes: ...
|
||||
@classmethod
|
||||
def from_bytes(cls, bytes: Sequence[int], byteorder: str, *,
|
||||
def from_bytes(cls, bytes: Union[Iterable[int], SupportsBytes], byteorder: str, *,
|
||||
signed: bool = ...) -> int: ... # TODO buffer object argument
|
||||
|
||||
def __add__(self, x: int) -> int: ...
|
||||
|
||||
@@ -157,7 +157,7 @@ class int:
|
||||
if sys.version_info >= (3,):
|
||||
def to_bytes(self, length: int, byteorder: str, *, signed: bool = ...) -> bytes: ...
|
||||
@classmethod
|
||||
def from_bytes(cls, bytes: Sequence[int], byteorder: str, *,
|
||||
def from_bytes(cls, bytes: Union[Iterable[int], SupportsBytes], byteorder: str, *,
|
||||
signed: bool = ...) -> int: ... # TODO buffer object argument
|
||||
|
||||
def __add__(self, x: int) -> int: ...
|
||||
|
||||
Reference in New Issue
Block a user