mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-06 21:43:59 +08:00
0eb44e574c
* Unify the `_MessageT` type var in `email._policybase`. * Use explicit type arguments for `Message` type in `_MessageT` type var. In particular, change bound from `Message[str, str]` to `Message[Any, Any]`. * Change `__init__()` overloads of `Parser` and `BytesParser` to accept `Message` objects that are not `Message[str, str]` if `_class` is not also given.
23 lines
978 B
Python
23 lines
978 B
Python
from collections.abc import Callable
|
|
from email._policybase import _MessageT
|
|
from email.message import Message
|
|
from email.policy import Policy
|
|
from typing import Generic, overload
|
|
|
|
__all__ = ["FeedParser", "BytesFeedParser"]
|
|
|
|
class FeedParser(Generic[_MessageT]):
|
|
@overload
|
|
def __init__(self: FeedParser[Message], _factory: None = None, *, policy: Policy[Message] = ...) -> None: ...
|
|
@overload
|
|
def __init__(self, _factory: Callable[[], _MessageT], *, policy: Policy[_MessageT] = ...) -> None: ...
|
|
def feed(self, data: str) -> None: ...
|
|
def close(self) -> _MessageT: ...
|
|
|
|
class BytesFeedParser(FeedParser[_MessageT]):
|
|
@overload
|
|
def __init__(self: BytesFeedParser[Message], _factory: None = None, *, policy: Policy[Message] = ...) -> None: ...
|
|
@overload
|
|
def __init__(self, _factory: Callable[[], _MessageT], *, policy: Policy[_MessageT] = ...) -> None: ...
|
|
def feed(self, data: bytes | bytearray) -> None: ... # type: ignore[override]
|