From 8c5661992d96f010e91ca775e6343c2e7d898c04 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sat, 29 Oct 2022 14:45:58 +0300 Subject: [PATCH 1/6] binhex: improve bytes handling --- stdlib/binhex.pyi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stdlib/binhex.pyi b/stdlib/binhex.pyi index 639d30d1d0de..a1f7cb9d5c9e 100644 --- a/stdlib/binhex.pyi +++ b/stdlib/binhex.pyi @@ -1,5 +1,6 @@ from typing import IO, Any from typing_extensions import Literal, TypeAlias +from _typeshed import ReadableBuffer __all__ = ["binhex", "hexbin", "Error"] @@ -27,9 +28,9 @@ class openrsrc: class BinHex: def __init__(self, name_finfo_dlen_rlen: _FileInfoTuple, ofp: _FileHandleUnion) -> None: ... - def write(self, data: bytes) -> None: ... + def write(self, data: ReadableBuffer) -> None: ... def close_data(self) -> None: ... - def write_rsrc(self, data: bytes) -> None: ... + def write_rsrc(self, data: ReadableBuffer) -> None: ... def close(self) -> None: ... def binhex(inp: str, out: str) -> None: ... From 8c1a06c8ffaf03794a2b92a761811829abdc8566 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 29 Oct 2022 11:48:27 +0000 Subject: [PATCH 2/6] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/binhex.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/binhex.pyi b/stdlib/binhex.pyi index a1f7cb9d5c9e..1010bbc45998 100644 --- a/stdlib/binhex.pyi +++ b/stdlib/binhex.pyi @@ -1,6 +1,6 @@ +from _typeshed import ReadableBuffer from typing import IO, Any from typing_extensions import Literal, TypeAlias -from _typeshed import ReadableBuffer __all__ = ["binhex", "hexbin", "Error"] From c5b7a172cf360ba94f53c52c0f00f900b24f0130 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sat, 29 Oct 2022 21:54:50 +0300 Subject: [PATCH 3/6] Address review --- stdlib/_typeshed/__init__.pyi | 1 + stdlib/binhex.pyi | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index b0ee1f4ad48a..c065e35924d7 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -234,6 +234,7 @@ else: WriteableBuffer: TypeAlias = bytearray | memoryview | array.array[Any] | mmap.mmap | ctypes._CData # stable # Same as _WriteableBuffer, but also includes read-only buffer types (like bytes). ReadableBuffer: TypeAlias = ReadOnlyBuffer | WriteableBuffer # stable +_BufferWithLen: TypeAlias = ReadableBuffer # not stable ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, TracebackType] OptExcInfo: TypeAlias = Union[ExcInfo, tuple[None, None, None]] diff --git a/stdlib/binhex.pyi b/stdlib/binhex.pyi index a1f7cb9d5c9e..4a8c8f81d726 100644 --- a/stdlib/binhex.pyi +++ b/stdlib/binhex.pyi @@ -28,9 +28,9 @@ class openrsrc: class BinHex: def __init__(self, name_finfo_dlen_rlen: _FileInfoTuple, ofp: _FileHandleUnion) -> None: ... - def write(self, data: ReadableBuffer) -> None: ... + def write(self, data: _BufferWithLen) -> None: ... def close_data(self) -> None: ... - def write_rsrc(self, data: ReadableBuffer) -> None: ... + def write_rsrc(self, data: _BufferWithLen) -> None: ... def close(self) -> None: ... def binhex(inp: str, out: str) -> None: ... From 9da2284d23d52ab1633cb8fa976418064ea2913f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 29 Oct 2022 18:57:55 +0000 Subject: [PATCH 4/6] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/binhex.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stdlib/binhex.pyi b/stdlib/binhex.pyi index 7556bcb46961..a03ad036dcfe 100644 --- a/stdlib/binhex.pyi +++ b/stdlib/binhex.pyi @@ -1,4 +1,3 @@ -from _typeshed import ReadableBuffer from typing import IO, Any from typing_extensions import Literal, TypeAlias From 20eb466dfde1de1bc581c1be9fbecd1720a50287 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Sat, 29 Oct 2022 22:13:28 +0300 Subject: [PATCH 5/6] Update binhex.pyi --- stdlib/binhex.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/binhex.pyi b/stdlib/binhex.pyi index a03ad036dcfe..e0993c840ce7 100644 --- a/stdlib/binhex.pyi +++ b/stdlib/binhex.pyi @@ -1,3 +1,4 @@ +from _typeshed import _BufferWithLen from typing import IO, Any from typing_extensions import Literal, TypeAlias From 67b4990237a65f1aa2de25f7c398781c6ff8d75c Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Sat, 29 Oct 2022 22:27:36 +0300 Subject: [PATCH 6/6] Update __init__.pyi --- stdlib/_typeshed/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index c065e35924d7..849078e9462e 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -234,7 +234,7 @@ else: WriteableBuffer: TypeAlias = bytearray | memoryview | array.array[Any] | mmap.mmap | ctypes._CData # stable # Same as _WriteableBuffer, but also includes read-only buffer types (like bytes). ReadableBuffer: TypeAlias = ReadOnlyBuffer | WriteableBuffer # stable -_BufferWithLen: TypeAlias = ReadableBuffer # not stable +_BufferWithLen: TypeAlias = ReadableBuffer # not stable # noqa: Y047 ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, TracebackType] OptExcInfo: TypeAlias = Union[ExcInfo, tuple[None, None, None]]