Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stubs/PyMySQL/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "1.1.*"
version = "1.2.*"
upstream-repository = "https://github.com/PyMySQL/PyMySQL"
63 changes: 58 additions & 5 deletions stubs/PyMySQL/pymysql/connections.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from _typeshed import FileDescriptorOrPath, Incomplete, Unused
from collections.abc import Callable, Mapping
from socket import _Address, socket as _socket
from ssl import SSLContext, _PasswordType
from typing import Any, AnyStr, Generic, overload
from typing import Any, AnyStr, Generic, Literal, overload
from typing_extensions import Self, TypeVar, deprecated

from .charset import charset_by_id as charset_by_id, charset_by_name as charset_by_name
Expand Down Expand Up @@ -91,7 +91,7 @@ class Connection(Generic[_C]):
binary_prefix: bool = False,
program_name: str | None = None,
server_public_key: bytes | None = None,
ssl: dict[str, Incomplete] | SSLContext | None = None,
ssl: SSLContext | None = None, # Passing a dict is deprecated
ssl_ca: str | None = None,
ssl_cert: str | None = None,
ssl_disabled: bool | None = None,
Expand All @@ -106,6 +106,53 @@ class Connection(Generic[_C]):
db: None = None, # deprecated
) -> None: ...
@overload
@deprecated("Passing a dict for 'ssl' parameter is deprecated. Use 'ssl_*' parameters or 'ssl.SSLContext' instead.")
def __init__(
self,
*,
user: str | bytes | None = None,
password: str | bytes = "",
host: str | None = None,
database: str | bytes | None = None,
unix_socket: _Address | None = None,
port: int = 0,
charset: str = "",
collation: str | None = None,
sql_mode: str | None = None,
read_default_file: str | None = None,
conv: dict[int | type[Any], Callable[[Any], str] | Callable[[str], Any]] | None = None,
use_unicode: bool = True,
client_flag: int = 0,
cursorclass: type[_C] = ...,
init_command: str | None = None,
connect_timeout: float = 10,
read_default_group: str | None = None,
autocommit: bool | None = False,
local_infile: bool = False,
max_allowed_packet: int = 16_777_216,
defer_connect: bool = False,
auth_plugin_map: dict[str, Callable[[Connection[Any]], Any]] | None = None,
read_timeout: float | None = None,
write_timeout: float | None = None,
bind_address: str | None = None,
binary_prefix: bool = False,
program_name: str | None = None,
server_public_key: bytes | None = None,
ssl: dict[str, Incomplete], # Passing a dict is deprecated
ssl_ca: str | None = None,
ssl_cert: str | None = None,
ssl_disabled: bool | None = None,
ssl_key: str | None = None,
ssl_key_password: _PasswordType | None = None,
ssl_verify_cert: bool | None = None,
ssl_verify_identity: bool | None = None,
compress: Unused = None,
named_pipe: Unused = None,
# different between overloads:
passwd: str | bytes | None = None, # deprecated
db: str | bytes | None = None, # deprecated
) -> None: ...
@overload
@deprecated("'passwd' and 'db' arguments are deprecated. Use 'password' and 'database' instead.")
def __init__(
self,
Expand Down Expand Up @@ -138,7 +185,7 @@ class Connection(Generic[_C]):
binary_prefix: bool = False,
program_name: str | None = None,
server_public_key: bytes | None = None,
ssl: dict[str, Incomplete] | SSLContext | None = None,
ssl: dict[str, Incomplete] | SSLContext | None = None, # Passing a dict is deprecated
ssl_ca: str | None = None,
ssl_cert: str | None = None,
ssl_disabled: bool | None = None,
Expand Down Expand Up @@ -176,8 +223,14 @@ class Connection(Generic[_C]):
def next_result(self, unbuffered: bool = False) -> int: ...
def affected_rows(self): ...
def kill(self, thread_id): ...
def ping(self, reconnect: bool = True) -> None: ...
@deprecated("Method is deprecated. Use set_character_set() instead.")

@overload
def ping(self, reconnect: Literal[False] | None = False) -> None: ...
@overload
@deprecated("The 'reconnect' parameter is deprecated. Create a new connection if you want to reconnect.")
def ping(self, reconnect: Literal[True]) -> None: ...

@deprecated("Method is deprecated. Use 'set_character_set()' instead.")
def set_charset(self, charset: str) -> None: ...
def set_character_set(self, charset: str, collation: str | None = None) -> None: ...
def connect(self, sock: _socket | None = None) -> None: ...
Expand Down
6 changes: 5 additions & 1 deletion stubs/PyMySQL/pymysql/err.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ from .constants import ER as ER

class MySQLError(Exception): ...
class Warning(builtins.Warning, MySQLError): ...
class Error(MySQLError): ...

class Error(MySQLError):
sqlstate: str | None
def __init__(self, *args: object, sqlstate: str | None = None) -> None: ...

class InterfaceError(Error): ...
class DatabaseError(Error): ...
class DataError(DatabaseError): ...
Expand Down