@@ -2,7 +2,7 @@ from _typeshed import FileDescriptorOrPath, Incomplete, Unused
22from collections .abc import Callable , Mapping
33from socket import _Address , socket as _socket
44from ssl import SSLContext , _PasswordType
5- from typing import Any , AnyStr , Generic , overload
5+ from typing import Any , AnyStr , Generic , Literal , overload
66from typing_extensions import Self , TypeVar , deprecated
77
88from .charset import charset_by_id as charset_by_id , charset_by_name as charset_by_name
@@ -91,7 +91,7 @@ class Connection(Generic[_C]):
9191 binary_prefix : bool = False ,
9292 program_name : str | None = None ,
9393 server_public_key : bytes | None = None ,
94- ssl : dict [ str , Incomplete ] | SSLContext | None = None ,
94+ ssl : SSLContext | None = None , # Passing a dict is deprecated
9595 ssl_ca : str | None = None ,
9696 ssl_cert : str | None = None ,
9797 ssl_disabled : bool | None = None ,
@@ -106,6 +106,53 @@ class Connection(Generic[_C]):
106106 db : None = None , # deprecated
107107 ) -> None : ...
108108 @overload
109+ @deprecated ("Passing a dict for 'ssl' parameter is deprecated. Use 'ssl_*' parameters or 'ssl.SSLContext' instead." )
110+ def __init__ (
111+ self ,
112+ * ,
113+ user : str | bytes | None = None ,
114+ password : str | bytes = "" ,
115+ host : str | None = None ,
116+ database : str | bytes | None = None ,
117+ unix_socket : _Address | None = None ,
118+ port : int = 0 ,
119+ charset : str = "" ,
120+ collation : str | None = None ,
121+ sql_mode : str | None = None ,
122+ read_default_file : str | None = None ,
123+ conv : dict [int | type [Any ], Callable [[Any ], str ] | Callable [[str ], Any ]] | None = None ,
124+ use_unicode : bool = True ,
125+ client_flag : int = 0 ,
126+ cursorclass : type [_C ] = ...,
127+ init_command : str | None = None ,
128+ connect_timeout : float = 10 ,
129+ read_default_group : str | None = None ,
130+ autocommit : bool | None = False ,
131+ local_infile : bool = False ,
132+ max_allowed_packet : int = 16_777_216 ,
133+ defer_connect : bool = False ,
134+ auth_plugin_map : dict [str , Callable [[Connection [Any ]], Any ]] | None = None ,
135+ read_timeout : float | None = None ,
136+ write_timeout : float | None = None ,
137+ bind_address : str | None = None ,
138+ binary_prefix : bool = False ,
139+ program_name : str | None = None ,
140+ server_public_key : bytes | None = None ,
141+ ssl : dict [str , Incomplete ], # Passing a dict is deprecated
142+ ssl_ca : str | None = None ,
143+ ssl_cert : str | None = None ,
144+ ssl_disabled : bool | None = None ,
145+ ssl_key : str | None = None ,
146+ ssl_key_password : _PasswordType | None = None ,
147+ ssl_verify_cert : bool | None = None ,
148+ ssl_verify_identity : bool | None = None ,
149+ compress : Unused = None ,
150+ named_pipe : Unused = None ,
151+ # different between overloads:
152+ passwd : str | bytes | None = None , # deprecated
153+ db : str | bytes | None = None , # deprecated
154+ ) -> None : ...
155+ @overload
109156 @deprecated ("'passwd' and 'db' arguments are deprecated. Use 'password' and 'database' instead." )
110157 def __init__ (
111158 self ,
@@ -138,7 +185,7 @@ class Connection(Generic[_C]):
138185 binary_prefix : bool = False ,
139186 program_name : str | None = None ,
140187 server_public_key : bytes | None = None ,
141- ssl : dict [str , Incomplete ] | SSLContext | None = None ,
188+ ssl : dict [str , Incomplete ] | SSLContext | None = None , # Passing a dict is deprecated
142189 ssl_ca : str | None = None ,
143190 ssl_cert : str | None = None ,
144191 ssl_disabled : bool | None = None ,
@@ -176,8 +223,14 @@ class Connection(Generic[_C]):
176223 def next_result (self , unbuffered : bool = False ) -> int : ...
177224 def affected_rows (self ): ...
178225 def kill (self , thread_id ): ...
179- def ping (self , reconnect : bool = True ) -> None : ...
180- @deprecated ("Method is deprecated. Use set_character_set() instead." )
226+
227+ @overload
228+ def ping (self , reconnect : Literal [False ] | None = False ) -> None : ...
229+ @overload
230+ @deprecated ("The 'reconnect' parameter is deprecated. Create a new connection if you want to reconnect." )
231+ def ping (self , reconnect : Literal [True ]) -> None : ...
232+
233+ @deprecated ("Method is deprecated. Use 'set_character_set()' instead." )
181234 def set_charset (self , charset : str ) -> None : ...
182235 def set_character_set (self , charset : str , collation : str | None = None ) -> None : ...
183236 def connect (self , sock : _socket | None = None ) -> None : ...
0 commit comments