E60E smtplib: Improve bytes handling (#9094) · python/typeshed@7ef7029 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7ef7029

Browse files
smtplib: Improve bytes handling (#9094)
1 parent 9f0d0b9 commit 7ef7029

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

stdlib/smtplib.pyi

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
from _typeshed import Self
2+
from _typeshed import ReadableBuffer, Self, _BufferWithLen
33
from collections.abc import Sequence
44
from email.message import Message as _Message
55
from re import Pattern
@@ -9,6 +9,8 @@ from types import TracebackType
99
from typing import Any, Protocol, overload
1010
from typing_extensions import TypeAlias
1111

12+
from _socket import _Address as _SourceAddress
13+
1214
__all__ = [
1315
"SMTPException",
1416
"SMTPServerDisconnected",
@@ -28,8 +30,6 @@ __all__ = [
2830

2931
_Reply: TypeAlias = tuple[int, bytes]
3032
_SendErrs: TypeAlias = dict[str, _Reply]
31-
# Should match source_address for socket.create_connection
32-
_SourceAddress: TypeAlias = tuple[bytearray | bytes | str, int]
3333

3434
SMTP_PORT: int
3535
SMTP_SSL_PORT: int
@@ -102,7 +102,7 @@ class SMTP:
102102
) -> None: ...
103103
def set_debuglevel(self, debuglevel: int) -> None: ...
104104
def connect(self, host: str = ..., port: int = ..., source_address: _SourceAddress | None = ...) -> _Reply: ...
105-
def send(self, s: bytes | str) -> None: ...
105+
def send(self, s: ReadableBuffer | str) -> None: ...
106106
def putcmd(self, cmd: str, args: str = ...) -> None: ...
107107
def getreply(self) -> _Reply: ...
108108
def docmd(self, cmd: str, args: str = ...) -> _Reply: ...
@@ -114,7 +114,7 @@ class SMTP:
114114
def noop(self) -> _Reply: ...
115115
def mail(self, sender: str, options: Sequence[str] = ...) -> _Reply: ...
116116
def rcpt(self, recip: str, options: Sequence[str] = ...) -> _Reply: ...
117-
def data(self, msg: bytes | str) -> _Reply: ...
117+
def data(self, msg: ReadableBuffer | str) -> _Reply: ...
118118
def verify(self, address: str) -> _Reply: ...
119119
vrfy = verify
120120
def expn(self, address: str) -> _Reply: ...
@@ -125,16 +125,16 @@ class SMTP:
125125
@overload
126126
def auth_cram_md5(self, challenge: None = ...) -> None: ...
127127
@overload
128-
def auth_cram_md5(self, challenge: bytes) -> str: ...
129-
def auth_plain(self, challenge: bytes | None = ...) -> str: ...
130-
def auth_login(self, challenge: bytes | None = ...) -> str: ...
128+
def auth_cram_md5(self, challenge: ReadableBuffer) -> str: ...
129+
def auth_plain(self, challenge: ReadableBuffer | None = ...) -> str: ...
130+
def auth_login(self, challenge: ReadableBuffer | None = ...) -> str: ...
131131
def login(self, user: str, password: str, *, initial_response_ok: bool = ...) -> _Reply: ...
132132
def starttls(self, keyfile: str | None = ..., certfile: str | None = ..., context: SSLContext | None = ...) -> _Reply: ...
133133
def sendmail(
134134
self,
135135
from_addr: str,
136136
to_addrs: str | Sequence[str],
137-
msg: bytes | str,
137+
msg: _BufferWithLen | str,
138138
mail_options: Sequence[str] = ...,
139139
rcpt_options: Sequence[str] = ...,
140140
) -> _SendErrs: ...

0 commit comments

Comments
 (0)
0