Add all the email __all__s (#7304)

This commit is contained in:
Alex Waygood
2022-02-20 01:53:29 +00:00
committed by GitHub
parent e9db3bd50a
commit b74acc7546
21 changed files with 68 additions and 1 deletions

View File

@@ -1,3 +1,5 @@
__all__ = ["body_decode", "body_encode", "decode", "decodestring", "header_encode", "header_length"]
def header_length(bytearray: str | bytes) -> int: ...
def header_encode(header_bytes: str | bytes, charset: str = ...) -> str: ...
def body_encode(s: bytes, maxlinelen: int = ..., eol: str = ...) -> str: ...

View File

@@ -1,5 +1,7 @@
from typing import Iterator
__all__ = ["Charset", "add_alias", "add_charset", "add_codec"]
QP: int # undocumented
BASE64: int # undocumented
SHORTEST: int # undocumented

View File

@@ -1,5 +1,7 @@
from email.message import Message
__all__ = ["encode_7or8bit", "encode_base64", "encode_noop", "encode_quopri"]
def encode_base64(msg: Message) -> None: ...
def encode_quopri(msg: Message) -> None: ...
def encode_7or8bit(msg: Message) -> None: ...

View File

@@ -2,6 +2,8 @@ from email.message import Message
from email.policy import Policy
from typing import Callable, Generic, TypeVar, overload
__all__ = ["FeedParser", "BytesFeedParser"]
_M = TypeVar("_M", bound=Message)
class FeedParser(Generic[_M]):

View File

@@ -2,6 +2,8 @@ from _typeshed import SupportsWrite
from email.message import Message
from email.policy import Policy
__all__ = ["Generator", "DecodedGenerator", "BytesGenerator"]
class Generator:
def clone(self, fp: SupportsWrite[str]) -> Generator: ...
def write(self, s: str) -> None: ...

View File

@@ -1,5 +1,7 @@
from email.charset import Charset
__all__ = ["Header", "decode_header", "make_header"]
class Header:
def __init__(
self,

View File

@@ -1,5 +1,8 @@
from email.message import Message
from typing import Iterator
__all__ = ["body_line_iterator", "typed_subpart_iterator", "walk"]
def body_line_iterator(msg: Message, decode: bool = ...) -> Iterator[str]: ...
def typed_subpart_iterator(msg: Message, maintype: str = ..., subtype: str | None = ...) -> Iterator[str]: ...
def walk(self: Message) -> Iterator[Message]: ...

View File

@@ -6,6 +6,8 @@ from email.policy import Policy
# using a type alias ("_HeaderType = Any") breaks mypy, who knows why
from typing import Any, Any as _HeaderType, Generator, Iterator, Optional, Sequence, TypeVar, Union
__all__ = ["Message", "EmailMessage"]
_T = TypeVar("_T")
_PayloadType = Union[list[Message], str, bytes]

View File

@@ -2,6 +2,8 @@ from email.mime.nonmultipart import MIMENonMultipart
from email.policy import Policy
from typing import Callable, Optional, Union
__all__ = ["MIMEApplication"]
_ParamsType = Union[str, None, tuple[str, Optional[str], str]]
class MIMEApplication(MIMENonMultipart):

View File

@@ -2,6 +2,8 @@ from email.mime.nonmultipart import MIMENonMultipart
from email.policy import Policy
from typing import Callable, Optional, Union
__all__ = ["MIMEAudio"]
_ParamsType = Union[str, None, tuple[str, Optional[str], str]]
class MIMEAudio(MIMENonMultipart):

View File

@@ -2,6 +2,8 @@ import email.message
from email.policy import Policy
from typing import Optional, Union
__all__ = ["MIMEBase"]
_ParamsType = Union[str, None, tuple[str, Optional[str], str]]
class MIMEBase(email.message.Message):

View File

@@ -2,6 +2,8 @@ from email.mime.nonmultipart import MIMENonMultipart
from email.policy import Policy
from typing import Callable, Optional, Union
__all__ = ["MIMEImage"]
_ParamsType = Union[str, None, tuple[str, Optional[str], str]]
class MIMEImage(MIMENonMultipart):

View File

@@ -2,5 +2,7 @@ from email.message import Message
from email.mime.nonmultipart import MIMENonMultipart
from email.policy import Policy
__all__ = ["MIMEMessage"]
class MIMEMessage(MIMENonMultipart):
def __init__(self, _msg: Message, _subtype: str = ..., *, policy: Policy | None = ...) -> None: ...

View File

@@ -3,6 +3,8 @@ from email.mime.base import MIMEBase
from email.policy import Policy
from typing import Optional, Sequence, Union
__all__ = ["MIMEMultipart"]
_ParamsType = Union[str, None, tuple[str, Optional[str], str]]
class MIMEMultipart(MIMEBase):

View File

@@ -1,3 +1,5 @@
from email.mime.base import MIMEBase
__all__ = ["MIMENonMultipart"]
class MIMENonMultipart(MIMEBase): ...

View File

@@ -1,5 +1,7 @@
from email.mime.nonmultipart import MIMENonMultipart
from email.policy import Policy
__all__ = ["MIMEText"]
class MIMEText(MIMENonMultipart):
def __init__(self, _text: str, _subtype: str = ..., _charset: str | None = ..., *, policy: Policy | None = ...) -> None: ...

View File

@@ -3,6 +3,8 @@ from email.message import Message
from email.policy import Policy
from typing import BinaryIO, Callable, TextIO, TypeVar
__all__ = ["Parser", "HeaderParser", "BytesParser", "BytesHeaderParser", "FeedParser", "BytesFeedParser"]
_M = TypeVar("_M", bound=Message)
FeedParser = email.feedparser.FeedParser[_M]

View File

@@ -5,6 +5,8 @@ from email.header import Header
from email.message import Message
from typing import Any, Callable
__all__ = ["Compat32", "compat32", "Policy", "EmailPolicy", "default", "strict", "SMTP", "HTTP"]
class Policy(metaclass=ABCMeta):
max_line_length: int | None
linesep: str

View File

@@ -1,3 +1,16 @@
__all__ = [
"body_decode",
"body_encode",
"body_length",
"decode",
"decodestring",
"header_decode",
"header_encode",
"header_length",
"quote",
"unquote",
]
def header_check(octet: int) -> bool: ...
def body_check(octet: int) -> bool: ...
def header_length(bytearray: bytes) -> int: ...

View File

@@ -3,6 +3,24 @@ import sys
from email.charset import Charset
from typing import Optional, Union, overload
__all__ = [
"collapse_rfc2231_value",
"decode_params",
"decode_rfc2231",
"encode_rfc2231",
"formataddr",
"formatdate",
"format_datetime",
"getaddresses",
"make_msgid",
"mktime_tz",
"parseaddr",
"parsedate",
"parsedate_tz",
"parsedate_to_datetime",
"unquote",
]
_ParamType = Union[str, tuple[Optional[str], Optional[str], str]]
_PDTZ = tuple[int, int, int, int, int, int, int, int, int, Optional[int]]