1
1
import sys
2
- from _typeshed import Self
2
+ from _typeshed import ReadableBuffer , Self , _BufferWithLen
3
3
from collections .abc import Sequence
4
4
from email .message import Message as _Message
5
5
from re import Pattern
@@ -9,6 +9,8 @@ from types import TracebackType
9
9
from typing import Any , Protocol , overload
10
10
from typing_extensions import TypeAlias
11
11
12
+ from _socket import _Address as _SourceAddress
13
+
12
14
__all__ = [
13
15
"SMTPException" ,
14
16
"SMTPServerDisconnected" ,
@@ -28,8 +30,6 @@ __all__ = [
28
30
29
31
_Reply : TypeAlias = tuple [int , bytes ]
30
32
_SendErrs : TypeAlias = dict [str , _Reply ]
31
- # Should match source_address for socket.create_connection
32
- _SourceAddress : TypeAlias = tuple [bytearray | bytes | str , int ]
33
33
34
34
SMTP_PORT : int
35
35
SMTP_SSL_PORT : int
@@ -102,7 +102,7 @@ class SMTP:
102
102
) -> None : ...
103
103
def set_debuglevel (self , debuglevel : int ) -> None : ...
104
104
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 : ...
106
106
def putcmd (self , cmd : str , args : str = ...) -> None : ...
107
107
def getreply (self ) -> _Reply : ...
108
108
def docmd (self , cmd : str , args : str = ...) -> _Reply : ...
@@ -114,7 +114,7 @@ class SMTP:
114
114
def noop (self ) -> _Reply : ...
115
115
def mail (self , sender : str , options : Sequence [str ] = ...) -> _Reply : ...
116
116
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 : ...
118
118
def verify (self , address : str ) -> _Reply : ...
119
119
vrfy = verify
120
120
def expn (self , address : str ) -> _Reply : ...
@@ -125,16 +125,16 @@ class SMTP:
125
125
@overload
126
126
def auth_cram_md5 (self , challenge : None = ...) -> None : ...
127
127
@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 : ...
131
131
def login (self , user : str , password : str , * , initial_response_ok : bool = ...) -> _Reply : ...
132
132
def starttls (self , keyfile : str | None = ..., certfile : str | None = ..., context : SSLContext | None = ...) -> _Reply : ...
133
133
def sendmail (
134
134
self ,
135
135
from_addr : str ,
136
136
to_addrs : str | Sequence [str ],
137
- msg : bytes | str ,
137
+ msg : _BufferWithLen | str ,
138
138
mail_options : Sequence [str ] = ...,
139
139
rcpt_options : Sequence [str ] = ...,
140
140
) -> _SendErrs : ...
0 commit comments