Files
typeshed/stdlib/email/feedparser.pyi
T
Sebastian Rittau 0eb44e574c Clean up and fix email message types (#13532)
* 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.
2025-05-05 11:59:51 -04:00

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]