|
1 | 1 | import sys
|
| 2 | +from _typeshed import ReadableBuffer |
| 3 | +from typing_extensions import TypeAlias |
2 | 4 |
|
3 |
| -def a2b_uu(__data: str | bytes) -> bytes: ... |
| 5 | +# Many functions in binascii accept buffer objects |
| 6 | +# or ASCII-only strings. |
| 7 | +_AsciiBuffer: TypeAlias = str | ReadableBuffer |
| 8 | + |
| 9 | +def a2b_uu(__data: _AsciiBuffer) -> bytes: ... |
4 | 10 |
|
5 | 11 | if sys.version_info >= (3, 7):
|
6 |
| - def b2a_uu(__data: bytes, *, backtick: bool = ...) -> bytes: ... |
| 12 | + def b2a_uu(__data: ReadableBuffer, *, backtick: bool = ...) -> bytes: ... |
7 | 13 |
|
8 | 14 | else:
|
9 |
| - def b2a_uu(__data: bytes) -> bytes: ... |
| 15 | + def b2a_uu(__data: ReadableBuffer) -> bytes: ... |
10 | 16 |
|
11 |
| -def a2b_base64(__data: str | bytes) -> bytes: ... |
12 |
| -def b2a_base64(__data: bytes, *, newline: bool = ...) -> bytes: ... |
13 |
| -def a2b_qp(data: str | bytes, header: bool = ...) -> bytes: ... |
14 |
| -def b2a_qp(data: bytes, quotetabs: bool = ..., istext: bool = ..., header: bool = ...) -> bytes: ... |
| 17 | +def a2b_base64(__data: _AsciiBuffer) -> bytes: ... |
| 18 | +def b2a_base64(__data: ReadableBuffer, *, newline: bool = ...) -> bytes: ... |
| 19 | +def a2b_qp(data: _AsciiBuffer, header: bool = ...) -> bytes: ... |
| 20 | +def b2a_qp(data: ReadableBuffer, quotetabs: bool = ..., istext: bool = ..., header: bool = ...) -> bytes: ... |
15 | 21 |
|
16 | 22 | if sys.version_info < (3, 11):
|
17 |
| - def a2b_hqx(__data: str | bytes) -> bytes: ... |
18 |
| - def rledecode_hqx(__data: bytes) -> bytes: ... |
19 |
| - def rlecode_hqx(__data: bytes) -> bytes: ... |
20 |
| - def b2a_hqx(__data: bytes) -> bytes: ... |
| 23 | + def a2b_hqx(__data: _AsciiBuffer) -> bytes: ... |
| 24 | + def rledecode_hqx(__data: ReadableBuffer) -> bytes: ... |
| 25 | + def rlecode_hqx(__data: ReadableBuffer) -> bytes: ... |
| 26 | + def b2a_hqx(__data: ReadableBuffer) -> bytes: ... |
21 | 27 |
|
22 |
| -def crc_hqx(__data: bytes, __crc: int) -> int: ... |
23 |
| -def crc32(__data: bytes, __crc: int = ...) -> int: ... |
24 |
| -def b2a_hex(__data: bytes) -> bytes: ... |
| 28 | +def crc_hqx(__data: ReadableBuffer, __crc: int) -> int: ... |
| 29 | +def crc32(__data: ReadableBuffer, __crc: int = ...) -> int: ... |
25 | 30 |
|
26 | 31 | if sys.version_info >= (3, 8):
|
27 |
| - def hexlify(data: bytes, sep: str | bytes = ..., bytes_per_sep: int = ...) -> bytes: ... |
| 32 | + # sep must be str or bytes, not bytearray or any other buffer |
| 33 | + def b2a_hex(data: ReadableBuffer, sep: str | bytes = ..., bytes_per_sep: int = ...) -> bytes: ... |
| 34 | + def hexlify(data: ReadableBuffer, sep: str | bytes = ..., bytes_per_sep: int = ...) -> bytes: ... |
28 | 35 |
|
29 | 36 | else:
|
30 |
| - def hexlify(__data: bytes) -> bytes: ... |
| 37 | + def b2a_hex(__data: ReadableBuffer) -> bytes: ... |
| 38 | + def hexlify(__data: ReadableBuffer) -> bytes: ... |
31 | 39 |
|
32 |
| -def a2b_hex(__hexstr: str | bytes) -> bytes: ... |
33 |
| -def unhexlify(__hexstr: str | bytes) -> bytes: ... |
| 40 | +def a2b_hex(__hexstr: _AsciiBuffer) -> bytes: ... |
| 41 | +def unhexlify(__hexstr: _AsciiBuffer) -> bytes: ... |
34 | 42 |
|
35 | 43 | class Error(ValueError): ...
|
36 | 44 | class Incomplete(Exception): ...
|
0 commit comments