email.parser: narrow io types (#9737)

This commit is contained in:
Shantanu
2023-02-15 01:43:39 -08:00
committed by GitHub
parent c50ceada0f
commit 58edfea33f

View File

@@ -1,25 +1,26 @@
from _typeshed import SupportsRead
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 BinaryIO, TextIO
from typing import IO
__all__ = ["Parser", "HeaderParser", "BytesParser", "BytesHeaderParser", "FeedParser", "BytesFeedParser"]
class Parser:
def __init__(self, _class: Callable[[], Message] | None = None, *, policy: Policy = ...) -> None: ...
def parse(self, fp: TextIO, headersonly: bool = False) -> Message: ...
def parse(self, fp: SupportsRead[str], headersonly: bool = False) -> Message: ...
def parsestr(self, text: str, headersonly: bool = False) -> Message: ...
class HeaderParser(Parser):
def parse(self, fp: TextIO, headersonly: bool = True) -> Message: ...
def parse(self, fp: SupportsRead[str], headersonly: bool = True) -> Message: ...
def parsestr(self, text: str, headersonly: bool = True) -> Message: ...
class BytesParser:
def __init__(self, _class: Callable[[], Message] = ..., *, policy: Policy = ...) -> None: ...
def parse(self, fp: BinaryIO, headersonly: bool = False) -> Message: ...
def parse(self, fp: IO[bytes], headersonly: bool = False) -> Message: ...
def parsebytes(self, text: bytes | bytearray, headersonly: bool = False) -> Message: ...
class BytesHeaderParser(BytesParser):
def parse(self, fp: BinaryIO, headersonly: bool = True) -> Message: ...
def parse(self, fp: IO[bytes], headersonly: bool = True) -> Message: ...
def parsebytes(self, text: bytes | bytearray, headersonly: bool = True) -> Message: ...