-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce code duplication in the email module (#7558)
- Loading branch information
1 parent
1ceb486
commit 3c85f36
Showing
10 changed files
with
31 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
import email.message | ||
from email import _ParamsType | ||
from email.policy import Policy | ||
from typing import Union | ||
|
||
__all__ = ["MIMEBase"] | ||
|
||
_ParamsType = Union[str, None, tuple[str, str | None, str]] | ||
|
||
class MIMEBase(email.message.Message): | ||
def __init__(self, _maintype: str, _subtype: str, *, policy: Policy | None = ..., **_params: _ParamsType) -> None: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters