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