Visitar URL original
[stdlib] Deprecate keyfile, certfile and check_hostname parameters · donbarbos/typeshed@46f2965 · GitHub
Skip to content

Commit 46f2965

Browse files
committed
[stdlib] Deprecate keyfile, certfile and check_hostname parameters
Source: python/cpython#94173
1 parent 4092415 commit 46f2965

5 files changed

Lines changed: 87 additions & 10 deletions

File tree

‎stdlib/ftplib.pyi‎

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ from collections.abc import Callable, Iterable, Iterator
44
from socket import socket
55
from ssl import SSLContext
66
from types import TracebackType
7-
from typing import Any, Final, Literal, TextIO
8-
from typing_extensions import Self
7+
from typing import Any, Final, Literal, TextIO, overload
8+
from typing_extensions import Self, deprecated
99

1010
__all__ = ["FTP", "error_reply", "error_temp", "error_perm", "error_proto", "all_errors", "FTP_TLS"]
1111

@@ -120,6 +120,24 @@ class FTP_TLS(FTP):
120120
encoding: str = "utf-8",
121121
) -> None: ...
122122
else:
123+
@overload
124+
def __init__(
125+
self,
126+
host: str = "",
127+
user: str = "",
128+
passwd: str = "",
129+
acct: str = "",
130+
*,
131+
context: SSLContext | None = None,
132+
timeout: float | None = ...,
133+
source_address: tuple[str, int] | None = None,
134+
encoding: str = "utf-8",
135+
) -> None: ...
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+
)
123141
def __init__(
124142
self,
125143
host: str = "",
@@ -134,9 +152,9 @@ class FTP_TLS(FTP):
134152
*,
135153
encoding: str = "utf-8",
136154
) -> None: ...
137-
ssl_version: int
138-
keyfile: str | None
139-
certfile: str | None
155+
ssl_version: int
156+
keyfile: str | None
157+
certfile: str | None
140158
context: SSLContext
141159
def login(self, user: str = "", passwd: str = "", acct: str = "", secure: bool = True) -> str: ...
142160
def auth(self) -> str: ...

‎stdlib/http/client.pyi‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,22 @@ class HTTPSConnection(HTTPConnection):
223223
blocksize: int = 8192,
224224
) -> None: ...
225225
else:
226+
@overload
227+
def __init__(
228+
self,
229+
host: str,
230+
port: int | None = None,
231+
timeout: float | None = ...,
232+
source_address: tuple[str, int] | None = None,
233+
*,
234+
context: ssl.SSLContext | None = None,
235+
blocksize: int = 8192,
236+
) -> None: ...
237+
@overload
238+
@deprecated(
239+
"The `key_file`, `cert_file`, `check_hostname` parameters are deprecated since Python 3.6; "
240+
"removed in Python 3.12. Use `context` parameter instead."
241+
)
226242
def __init__(
227243
self,
228244
host: str,
@@ -236,6 +252,8 @@ class HTTPSConnection(HTTPConnection):
236252
check_hostname: bool | None = None,
237253
blocksize: int = 8192,
238254
) -> None: ...
255+
key_file: str | None
256+
cert_file: str | None
239257

240258
class HTTPException(Exception): ...
241259

‎stdlib/imaplib.pyi‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ from re import Pattern
99
from socket import socket as _socket
1010
from ssl import SSLContext, SSLSocket
1111
from types import TracebackType
12-
from typing import IO, Any, Literal, SupportsAbs, SupportsInt
12+
from typing import IO, Any, Literal, SupportsAbs, SupportsInt, overload
1313
from typing_extensions import Self, TypeAlias, deprecated
1414

1515
__all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple", "Int2AP", "ParseFlags", "Time2Internaldate", "IMAP4_SSL"]
@@ -128,6 +128,15 @@ class IMAP4_SSL(IMAP4):
128128
self, host: str = "", port: int = 993, *, ssl_context: SSLContext | None = None, timeout: float | None = None
129129
) -> None: ...
130130
else:
131+
@overload
132+
def __init__(
133+
self, host: str = "", port: int = 993, *, ssl_context: SSLContext | None = None, timeout: float | None = None
134+
) -> None: ...
135+
@overload
136+
@deprecated(
137+
"The `keyfile`, `certfile` parameters are deprecated since Python 3.6; "
138+
"removed in Python 3.12. Use `ssl_context` parameter instead."
139+
)
131140
def __init__(
132141
self,
133142
host: str = "",

‎stdlib/poplib.pyi‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import sys
44
from builtins import list as _list # conflicts with a method named "list"
55
from re import Pattern
66
from typing import Any, BinaryIO, Final, NoReturn, overload
7-
from typing_extensions import TypeAlias
7+
from typing_extensions import TypeAlias, deprecated
88

99
__all__ = ["POP3", "error_proto", "POP3_SSL"]
1010

@@ -58,6 +58,15 @@ class POP3_SSL(POP3):
5858
) -> None: ...
5959
def stls(self, context: Any = None) -> NoReturn: ...
6060
else:
61+
@overload
62+
def __init__(
63+
self, host: str, port: int = 995, *, timeout: float = ..., context: ssl.SSLContext | None = None
64+
) -> None: ...
65+
@overload
66+
@deprecated(
67+
"The `keyfile`, `certfile` parameters are deprecated since Python 3.6; "
68+
"removed in Python 3.12. Use `context` parameter instead."
69+
)
6170
def __init__(
6271
self,
6372
host: str,

‎stdlib/smtplib.pyi‎

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ from socket import socket
88
from ssl import SSLContext
99
from types import TracebackType
1010
from 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,6 +131,13 @@ 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, *, 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(
135142
self, keyfile: str | None = None, certfile: str | None = None, context: SSLContext | None = None
136143
) -> _Reply: ...
@@ -155,8 +162,6 @@ class SMTP:
155162
def quit(self) -> _Reply: ...
156163

157164
class 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,6 +175,22 @@ class SMTP_SSL(SMTP):
170175
context: SSLContext | None = None,
171176
) -> None: ...
172177
else:
178+
@overload
179+
def __init__(
180+
self,
181+
host: str = "",
182+
port: int = 0,
183+
local_hostname: str | None = None,
184+
*,
185+
timeout: float = ...,
186+
source_address: _SourceAddress | None = None,
187+
context: SSLContext | None = None,
188+
) -> None: ...
189+
@overload
190+
@deprecated(
191+
"The `keyfile`, `certfile` parameters are deprecated since Python 3.6; "
192+
"removed in Python 3.12. Use `context` parameter instead."
193+
)
173194
def __init__(
174195
self,
175196
host: str = "",
@@ -181,6 +202,8 @@ class SMTP_SSL(SMTP):
181202
source_address: _SourceAddress | None = None,
182203
context: SSLContext | None = None,
183204
) -> None: ...
205+
keyfile: str | None
206+
certfile: str | None
184207

185208
LMTP_PORT: Final = 2003
186209

0 commit comments

Comments
 (0)