email: improve bytes handling (#9032)

This commit is contained in:
Jelle Zijlstra
2022-11-01 02:13:30 -07:00
committed by GitHub
parent 3e46f9a9ee
commit 7ab933f3c3
10 changed files with 26 additions and 19 deletions

View File

@@ -1,3 +1,4 @@
from collections.abc import Iterable
from email.charset import Charset
from typing import Any
@@ -6,14 +7,14 @@ __all__ = ["Header", "decode_header", "make_header"]
class Header:
def __init__(
self,
s: bytes | str | None = ...,
s: bytes | bytearray | str | None = ...,
charset: Charset | str | None = ...,
maxlinelen: int | None = ...,
header_name: str | None = ...,
continuation_ws: str = ...,
errors: str = ...,
) -> None: ...
def append(self, s: bytes | str, charset: Charset | str | None = ..., errors: str = ...) -> None: ...
def append(self, s: bytes | bytearray | str, charset: Charset | str | None = ..., errors: str = ...) -> None: ...
def encode(self, splitchars: str = ..., maxlinelen: int | None = ..., linesep: str = ...) -> str: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, __other: object) -> bool: ...
@@ -23,7 +24,7 @@ class Header:
# contains at least one encoded part.
def decode_header(header: Header | str) -> list[tuple[Any, Any | None]]: ...
def make_header(
decoded_seq: list[tuple[bytes, str | None]],
decoded_seq: Iterable[tuple[bytes | bytearray | str, str | None]],
maxlinelen: int | None = ...,
header_name: str | None = ...,
continuation_ws: str = ...,