11import sys
22from _socket import _Address as _SourceAddress
3- from _typeshed import ReadableBuffer , SizedBuffer
3+ from _typeshed import ReadableBuffer , SizedBuffer , StrOrBytesPath
44from collections .abc import Sequence
55from email .message import Message as _Message
66from re import Pattern
77from socket import socket
88from ssl import SSLContext
99from types import TracebackType
1010from typing import Any , Final , Protocol , overload , type_check_only
11- from typing_extensions import Self , TypeAlias
11+ from typing_extensions import Self , TypeAlias , deprecated
1212
1313__all__ = [
1414 "SMTPException" ,
@@ -131,8 +131,15 @@ class SMTP:
131131 if sys .version_info >= (3 , 12 ):
132132 def starttls (self , * , context : SSLContext | None = None ) -> _Reply : ...
133133 else :
134+ @overload
135+ def starttls (self , keyfile : None = None , certfile : None = None , context : SSLContext | None = None ) -> _Reply : ...
136+ @overload
137+ @deprecated (
138+ "The `keyfile`, `certfile` parameters are deprecated since Python 3.6; "
139+ "removed in Python 3.12. Use `context` parameter instead."
140+ )
134141 def starttls (
135- self , keyfile : str | None = None , certfile : str | None = None , context : SSLContext | None = None
142+ self , keyfile : StrOrBytesPath | None = None , certfile : StrOrBytesPath | None = None , context : None = None
136143 ) -> _Reply : ...
137144
138145 def sendmail (
@@ -155,8 +162,6 @@ class SMTP:
155162 def quit (self ) -> _Reply : ...
156163
157164class SMTP_SSL (SMTP ):
158- keyfile : str | None
159- certfile : str | None
160165 context : SSLContext
161166 if sys .version_info >= (3 , 12 ):
162167 def __init__ (
@@ -170,17 +175,36 @@ class SMTP_SSL(SMTP):
170175 context : SSLContext | None = None ,
171176 ) -> None : ...
172177 else :
178+ @overload
173179 def __init__ (
174180 self ,
175181 host : str = "" ,
176182 port : int = 0 ,
177183 local_hostname : str | None = None ,
178- keyfile : str | None = None ,
179- certfile : str | None = None ,
184+ keyfile : None = None ,
185+ certfile : None = None ,
180186 timeout : float = ...,
181187 source_address : _SourceAddress | None = None ,
182188 context : SSLContext | None = None ,
183189 ) -> None : ...
190+ @overload
191+ @deprecated (
192+ "The `keyfile`, `certfile` parameters are deprecated since Python 3.6; "
193+ "removed in Python 3.12. Use `context` parameter instead."
194+ )
195+ def __init__ (
196+ self ,
197+ host : str = "" ,
198+ port : int = 0 ,
199+ local_hostname : str | None = None ,
200+ keyfile : StrOrBytesPath | None = None ,
201+ certfile : StrOrBytesPath | None = None ,
202+ timeout : float = ...,
203+ source_address : _SourceAddress | None = None ,
204+ context : None = None ,
205+ ) -> None : ...
206+ keyfile : StrOrBytesPath | None
207+ certfile : StrOrBytesPath | None
184208
185209LMTP_PORT : Final = 2003
186210
0 commit comments