Reduce code duplication in the email module (#7558)

This commit is contained in:
Alex Waygood
2022-04-06 11:20:14 +01:00
committed by GitHub
parent 1ceb486b75
commit 3c85f36b7f
10 changed files with 31 additions and 35 deletions

View File

@@ -1,14 +1,13 @@
import email.feedparser
from email import _MessageT
from email.message import Message
from email.policy import Policy
from typing import BinaryIO, Callable, TextIO, TypeVar
from typing import BinaryIO, Callable, TextIO
__all__ = ["Parser", "HeaderParser", "BytesParser", "BytesHeaderParser", "FeedParser", "BytesFeedParser"]
_M = TypeVar("_M", bound=Message)
FeedParser = email.feedparser.FeedParser[_M]
BytesFeedParser = email.feedparser.BytesFeedParser[_M]
FeedParser = email.feedparser.FeedParser[_MessageT]
BytesFeedParser = email.feedparser.BytesFeedParser[_MessageT]
class Parser:
def __init__(self, _class: Callable[[], Message] | None = ..., *, policy: Policy = ...) -> None: ...