mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 21:46:42 +08:00
Reduce code duplication in the email module (#7558)
This commit is contained in:
@@ -1,23 +1,22 @@
|
||||
from email import _MessageT
|
||||
from email.message import Message
|
||||
from email.policy import Policy
|
||||
from typing import Callable, Generic, TypeVar, overload
|
||||
from typing import Callable, Generic, overload
|
||||
|
||||
__all__ = ["FeedParser", "BytesFeedParser"]
|
||||
|
||||
_M = TypeVar("_M", bound=Message)
|
||||
|
||||
class FeedParser(Generic[_M]):
|
||||
class FeedParser(Generic[_MessageT]):
|
||||
@overload
|
||||
def __init__(self: FeedParser[Message], _factory: None = ..., *, policy: Policy = ...) -> None: ...
|
||||
@overload
|
||||
def __init__(self, _factory: Callable[[], _M], *, policy: Policy = ...) -> None: ...
|
||||
def __init__(self, _factory: Callable[[], _MessageT], *, policy: Policy = ...) -> None: ...
|
||||
def feed(self, data: str) -> None: ...
|
||||
def close(self) -> _M: ...
|
||||
def close(self) -> _MessageT: ...
|
||||
|
||||
class BytesFeedParser(Generic[_M]):
|
||||
class BytesFeedParser(Generic[_MessageT]):
|
||||
@overload
|
||||
def __init__(self: BytesFeedParser[Message], _factory: None = ..., *, policy: Policy = ...) -> None: ...
|
||||
@overload
|
||||
def __init__(self, _factory: Callable[[], _M], *, policy: Policy = ...) -> None: ...
|
||||
def __init__(self, _factory: Callable[[], _MessageT], *, policy: Policy = ...) -> None: ...
|
||||
def feed(self, data: bytes) -> None: ...
|
||||
def close(self) -> _M: ...
|
||||
def close(self) -> _MessageT: ...
|
||||
|
||||
Reference in New Issue
Block a user