mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 13:34:58 +08:00
Make email.message.Message generic over the header type (#11732)
Co-authored-by: Avasam <samuel.06@hotmail.com>
This commit is contained in:
@@ -3,24 +3,34 @@ from collections.abc import Callable
|
||||
from email.feedparser import BytesFeedParser as BytesFeedParser, FeedParser as FeedParser
|
||||
from email.message import Message
|
||||
from email.policy import Policy
|
||||
from typing import IO
|
||||
from io import _WrappedBuffer
|
||||
from typing import Generic, TypeVar, overload
|
||||
|
||||
__all__ = ["Parser", "HeaderParser", "BytesParser", "BytesHeaderParser", "FeedParser", "BytesFeedParser"]
|
||||
|
||||
class Parser:
|
||||
def __init__(self, _class: Callable[[], Message] | None = None, *, policy: Policy = ...) -> None: ...
|
||||
def parse(self, fp: SupportsRead[str], headersonly: bool = False) -> Message: ...
|
||||
def parsestr(self, text: str, headersonly: bool = False) -> Message: ...
|
||||
_MessageT = TypeVar("_MessageT", bound=Message, default=Message)
|
||||
|
||||
class HeaderParser(Parser):
|
||||
def parse(self, fp: SupportsRead[str], headersonly: bool = True) -> Message: ...
|
||||
def parsestr(self, text: str, headersonly: bool = True) -> Message: ...
|
||||
class Parser(Generic[_MessageT]):
|
||||
@overload
|
||||
def __init__(self: Parser[Message[str, str]], _class: None = None, *, policy: Policy = ...) -> None: ...
|
||||
@overload
|
||||
def __init__(self, _class: Callable[[], _MessageT], *, policy: Policy = ...) -> None: ...
|
||||
def parse(self, fp: SupportsRead[str], headersonly: bool = False) -> _MessageT: ...
|
||||
def parsestr(self, text: str, headersonly: bool = False) -> _MessageT: ...
|
||||
|
||||
class BytesParser:
|
||||
def __init__(self, _class: Callable[[], Message] = ..., *, policy: Policy = ...) -> None: ...
|
||||
def parse(self, fp: IO[bytes], headersonly: bool = False) -> Message: ...
|
||||
def parsebytes(self, text: bytes | bytearray, headersonly: bool = False) -> Message: ...
|
||||
class HeaderParser(Parser[_MessageT]):
|
||||
def parse(self, fp: SupportsRead[str], headersonly: bool = True) -> _MessageT: ...
|
||||
def parsestr(self, text: str, headersonly: bool = True) -> _MessageT: ...
|
||||
|
||||
class BytesHeaderParser(BytesParser):
|
||||
def parse(self, fp: IO[bytes], headersonly: bool = True) -> Message: ...
|
||||
def parsebytes(self, text: bytes | bytearray, headersonly: bool = True) -> Message: ...
|
||||
class BytesParser(Generic[_MessageT]):
|
||||
parser: Parser[_MessageT]
|
||||
@overload
|
||||
def __init__(self: BytesParser[Message[str, str]], _class: None = None, *, policy: Policy = ...) -> None: ...
|
||||
@overload
|
||||
def __init__(self, _class: Callable[[], _MessageT], *, policy: Policy = ...) -> None: ...
|
||||
def parse(self, fp: _WrappedBuffer, headersonly: bool = False) -> _MessageT: ...
|
||||
def parsebytes(self, text: bytes | bytearray, headersonly: bool = False) -> _MessageT: ...
|
||||
|
||||
class BytesHeaderParser(BytesParser[_MessageT]):
|
||||
def parse(self, fp: _WrappedBuffer, headersonly: bool = True) -> _MessageT: ...
|
||||
def parsebytes(self, text: bytes | bytearray, headersonly: bool = True) -> _MessageT: ...
|
||||
|
||||
Reference in New Issue
Block a user