From 156b3bec923721f5c3361d007649b15dd56bd5fd Mon Sep 17 00:00:00 2001 From: Guo Ci Date: Wed, 3 Dec 2025 17:20:08 -0500 Subject: [PATCH 1/2] [stdlib] Update `fromhex` method `bytes` and `bytesarray` docs: https://docs.python.org/dev/library/stdtypes.html#bytes.fromhex https://docs.python.org/dev/library/stdtypes.html#bytearray.fromhex --- stdlib/builtins.pyi | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 38be452e8d49..4fc6428453c7 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -731,8 +731,12 @@ class bytes(Sequence[int]): def translate(self, table: ReadableBuffer | None, /, delete: ReadableBuffer = b"") -> bytes: ... def upper(self) -> bytes: ... def zfill(self, width: SupportsIndex, /) -> bytes: ... - @classmethod - def fromhex(cls, string: str, /) -> Self: ... + if sys.version_info >= (3, 14): + @classmethod + def fromhex(cls, string: str | ReadableBuffer, /) -> Self: ... + else: + @classmethod + def fromhex(cls, string: str, /) -> Self: ... @staticmethod def maketrans(frm: ReadableBuffer, to: ReadableBuffer, /) -> bytes: ... def __len__(self) -> int: ... @@ -836,8 +840,12 @@ class bytearray(MutableSequence[int]): def translate(self, table: ReadableBuffer | None, /, delete: bytes = b"") -> bytearray: ... def upper(self) -> bytearray: ... def zfill(self, width: SupportsIndex, /) -> bytearray: ... - @classmethod - def fromhex(cls, string: str, /) -> Self: ... + if sys.version_info >= (3, 14): + @classmethod + def fromhex(cls, string: str | ReadableBuffer, /) -> Self: ... + else: + @classmethod + def fromhex(cls, string: str, /) -> Self: ... @staticmethod def maketrans(frm: ReadableBuffer, to: ReadableBuffer, /) -> bytes: ... def __len__(self) -> int: ... From c66d58b1caa577d7423c9aada24d7050d38be3d1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 3 Dec 2025 22:22:59 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/builtins.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 4fc6428453c7..ed2217e79446 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -737,6 +737,7 @@ class bytes(Sequence[int]): else: @classmethod def fromhex(cls, string: str, /) -> Self: ... + @staticmethod def maketrans(frm: ReadableBuffer, to: ReadableBuffer, /) -> bytes: ... def __len__(self) -> int: ... @@ -846,6 +847,7 @@ class bytearray(MutableSequence[int]): else: @classmethod def fromhex(cls, string: str, /) -> Self: ... + @staticmethod def maketrans(frm: ReadableBuffer, to: ReadableBuffer, /) -> bytes: ... def __len__(self) -> int: ...