Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions aiosmtpd/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from aiosmtpd import _get_or_new_eventloop
from aiosmtpd.smtp import SMTP as SMTPServer
from aiosmtpd.smtp import Envelope as SMTPEnvelope
from aiosmtpd.smtp import PeerType
from aiosmtpd.smtp import Session as SMTPSession

T = TypeVar("T")
Expand All @@ -38,7 +39,7 @@
log = logging.getLogger("mail.debug")


def _format_peer(peer: str) -> str:
def _format_peer(peer: PeerType) -> str:
# This is a separate function mostly so the test suite can craft a
# reproducible output.
return "X-Peer: {!r}".format(peer)
Expand Down Expand Up @@ -76,7 +77,7 @@ def from_cli(cls: Type[T], parser: ArgumentParser, *args) -> T:
parser.error("Debugging usage: [stdout|stderr]")
return cls(stream) # type: ignore[call-arg]

def _print_message_content(self, peer: str, data: Union[str, bytes]) -> None:
def _print_message_content(self, peer: PeerType, data: Union[str, bytes]) -> None:
in_headers = True
for line in data.splitlines():
# Dump the RFC 2822 headers first.
Expand Down
4 changes: 3 additions & 1 deletion aiosmtpd/smtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class _DataState(enum.Enum):
RT = TypeVar("RT") # "ReturnType"
DecoratorType = Callable[[Callable[..., RT]], Callable[..., RT]]

# IPv4, IPv6, UNIX socket, not set
PeerType = Union[Tuple[str, int], Tuple[str, int, int, int], str, None]

# endregion

Expand Down Expand Up @@ -155,7 +157,7 @@ def __repr__(self) -> str:
@public
class Session:
def __init__(self, loop: asyncio.AbstractEventLoop):
self.peer: Optional[str] = None
self.peer: PeerType = None
self.ssl: Optional[dict[str, Any]] = None
self.host_name: Optional[str] = None
self.extended_smtp = False
Expand Down
Loading