From b10f482e36f67a9d7aae13c49a4d14cb17df97e6 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 23 Jun 2023 13:41:55 +0200 Subject: [PATCH] Bump mysqlclient to 2.2 (#10353) Co-authored-by: Alex Waygood --- stubs/mysqlclient/METADATA.toml | 5 +- stubs/mysqlclient/MySQLdb/__init__.pyi | 20 ++-- stubs/mysqlclient/MySQLdb/_mysql.pyi | 122 +++++++++++----------- stubs/mysqlclient/MySQLdb/connections.pyi | 19 ++-- stubs/mysqlclient/MySQLdb/converters.pyi | 6 +- stubs/mysqlclient/MySQLdb/cursors.pyi | 31 +++--- 6 files changed, 111 insertions(+), 92 deletions(-) diff --git a/stubs/mysqlclient/METADATA.toml b/stubs/mysqlclient/METADATA.toml index acdc22b5d..7892149a1 100644 --- a/stubs/mysqlclient/METADATA.toml +++ b/stubs/mysqlclient/METADATA.toml @@ -1 +1,4 @@ -version = "2.1.*" +version = "2.2.*" + +[tool.stubtest] +apt_dependencies = ["libmariadb-dev"] diff --git a/stubs/mysqlclient/MySQLdb/__init__.pyi b/stubs/mysqlclient/MySQLdb/__init__.pyi index 87fbcf2b2..887b28de1 100644 --- a/stubs/mysqlclient/MySQLdb/__init__.pyi +++ b/stubs/mysqlclient/MySQLdb/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any +from _typeshed import Incomplete from MySQLdb import connections as connections, constants as constants, converters as converters, cursors as cursors from MySQLdb._mysql import ( @@ -33,17 +33,17 @@ threadsafety: int apilevel: str paramstyle: str -class DBAPISet(frozenset[Any]): +class DBAPISet(frozenset[Incomplete]): def __eq__(self, other): ... -STRING: Any -BINARY: Any -NUMBER: Any -DATE: Any -TIME: Any -TIMESTAMP: Any -DATETIME: Any -ROWID: Any +STRING: Incomplete +BINARY: Incomplete +NUMBER: Incomplete +DATE: Incomplete +TIME: Incomplete +TIMESTAMP: Incomplete +DATETIME: Incomplete +ROWID: Incomplete def Binary(x): ... def Connect(*args, **kwargs): ... diff --git a/stubs/mysqlclient/MySQLdb/_mysql.pyi b/stubs/mysqlclient/MySQLdb/_mysql.pyi index b1dded226..4718cce16 100644 --- a/stubs/mysqlclient/MySQLdb/_mysql.pyi +++ b/stubs/mysqlclient/MySQLdb/_mysql.pyi @@ -1,9 +1,9 @@ import builtins -from typing import Any +from _typeshed import Incomplete import MySQLdb._exceptions -version_info: tuple[Any, ...] +version_info: tuple[Incomplete, ...] class DataError(MySQLdb._exceptions.DatabaseError): ... class DatabaseError(MySQLdb._exceptions.Error): ... @@ -18,70 +18,72 @@ class ProgrammingError(MySQLdb._exceptions.DatabaseError): ... class Warning(builtins.Warning, MySQLdb._exceptions.MySQLError): ... class connection: - client_flag: Any - converter: Any - open: Any - port: Any - server_capabilities: Any + client_flag: Incomplete + converter: Incomplete + open: Incomplete + port: Incomplete + server_capabilities: Incomplete def __init__(self, *args, **kwargs) -> None: ... - def _get_native_connection(self, *args, **kwargs) -> Any: ... - def affected_rows(self, *args, **kwargs) -> Any: ... - def autocommit(self, on) -> Any: ... - def change_user(self, *args, **kwargs) -> Any: ... - def character_set_name(self, *args, **kwargs) -> Any: ... - def close(self, *args, **kwargs) -> Any: ... - def commit(self, *args, **kwargs) -> Any: ... - def dump_debug_info(self, *args, **kwargs) -> Any: ... - def errno(self, *args, **kwargs) -> Any: ... - def error(self, *args, **kwargs) -> Any: ... - def escape(self, obj, dict) -> Any: ... - def escape_string(self, s) -> Any: ... - def field_count(self, *args, **kwargs) -> Any: ... - def fileno(self, *args, **kwargs) -> Any: ... - def get_autocommit(self, *args, **kwargs) -> Any: ... - def get_character_set_info(self, *args, **kwargs) -> Any: ... - def get_host_info(self, *args, **kwargs) -> Any: ... - def get_proto_info(self, *args, **kwargs) -> Any: ... - def get_server_info(self, *args, **kwargs) -> Any: ... - def info(self, *args, **kwargs) -> Any: ... - def insert_id(self, *args, **kwargs) -> Any: ... - def kill(self, *args, **kwargs) -> Any: ... - def next_result(self) -> Any: ... - def ping(self) -> Any: ... - def query(self, query) -> Any: ... - def read_query_result(self, *args, **kwargs) -> Any: ... - def rollback(self, *args, **kwargs) -> Any: ... - def select_db(self, *args, **kwargs) -> Any: ... - def send_query(self, *args, **kwargs) -> Any: ... - def set_character_set(self, charset) -> Any: ... - def set_server_option(self, option) -> Any: ... - def shutdown(self, *args, **kwargs) -> Any: ... - def sqlstate(self, *args, **kwargs) -> Any: ... - def stat(self, *args, **kwargs) -> Any: ... - def store_result(self, *args, **kwargs) -> Any: ... - def string_literal(self, obj) -> Any: ... - def thread_id(self, *args, **kwargs) -> Any: ... - def use_result(self, *args, **kwargs) -> Any: ... - def warning_count(self, *args, **kwargs) -> Any: ... + def _get_native_connection(self, *args, **kwargs): ... + def affected_rows(self, *args, **kwargs): ... + def autocommit(self, on): ... + def change_user(self, *args, **kwargs): ... + def character_set_name(self, *args, **kwargs): ... + def close(self, *args, **kwargs): ... + def commit(self, *args, **kwargs): ... + def dump_debug_info(self, *args, **kwargs): ... + def errno(self, *args, **kwargs): ... + def error(self, *args, **kwargs): ... + def escape(self, obj, dict): ... + def escape_string(self, s): ... + def field_count(self, *args, **kwargs): ... + def fileno(self, *args, **kwargs): ... + def get_autocommit(self, *args, **kwargs): ... + def get_character_set_info(self, *args, **kwargs): ... + def get_host_info(self, *args, **kwargs): ... + def get_proto_info(self, *args, **kwargs): ... + def get_server_info(self, *args, **kwargs): ... + def info(self, *args, **kwargs): ... + def insert_id(self, *args, **kwargs): ... + def kill(self, *args, **kwargs): ... + def next_result(self): ... + def ping(self): ... + def query(self, query): ... + def read_query_result(self, *args, **kwargs): ... + def rollback(self, *args, **kwargs): ... + def select_db(self, *args, **kwargs): ... + def send_query(self, *args, **kwargs): ... + def set_character_set(self, charset: str) -> None: ... + def set_server_option(self, option): ... + def shutdown(self, *args, **kwargs): ... + def sqlstate(self, *args, **kwargs): ... + def stat(self, *args, **kwargs): ... + def store_result(self, *args, **kwargs): ... + def string_literal(self, obj): ... + def thread_id(self, *args, **kwargs): ... + def use_result(self, *args, **kwargs): ... + def discard_result(self) -> None: ... + def warning_count(self, *args, **kwargs): ... def __delattr__(self, __name: str) -> None: ... def __setattr__(self, __name: str, __value) -> None: ... class result: - converter: Any - has_next: Any + converter: Incomplete + has_next: Incomplete def __init__(self, *args, **kwargs) -> None: ... - def data_seek(self, n) -> Any: ... - def describe(self, *args, **kwargs) -> Any: ... - def fetch_row(self, *args, **kwargs) -> Any: ... - def field_flags(self, *args, **kwargs) -> Any: ... - def num_fields(self, *args, **kwargs) -> Any: ... - def num_rows(self, *args, **kwargs) -> Any: ... + def data_seek(self, n): ... + def describe(self, *args, **kwargs): ... + def fetch_row(self, *args, **kwargs): ... + def discard(self) -> None: ... + def field_flags(self, *args, **kwargs): ... + def num_fields(self, *args, **kwargs): ... + def num_rows(self, *args, **kwargs): ... def __delattr__(self, __name: str) -> None: ... def __setattr__(self, __name: str, __value) -> None: ... -def connect(*args, **kwargs) -> Any: ... -def debug(*args, **kwargs) -> Any: ... -def escape(obj, dict) -> Any: ... -def escape_string(s) -> Any: ... -def get_client_info() -> Any: ... -def string_literal(obj) -> Any: ... +def connect(*args, **kwargs): ... +def debug(*args, **kwargs): ... +def escape(obj, dict): ... +def escape_string(s): ... +def get_client_info(): ... +def string_literal(obj): ... diff --git a/stubs/mysqlclient/MySQLdb/connections.pyi b/stubs/mysqlclient/MySQLdb/connections.pyi index 327e76137..0a4f8965f 100644 --- a/stubs/mysqlclient/MySQLdb/connections.pyi +++ b/stubs/mysqlclient/MySQLdb/connections.pyi @@ -1,6 +1,8 @@ +from _typeshed import Incomplete +from re import Pattern from types import TracebackType from typing import Any -from typing_extensions import Self +from typing_extensions import LiteralString, Self, TypeAlias from . import _mysql, cursors from ._exceptions import ( @@ -16,16 +18,21 @@ from ._exceptions import ( Warning as Warning, ) -re_numeric_part: Any +# Any kind of object that can be passed to Connection.literal(). +# The allowed types depend on the defined encoders, but the following +# types are always allowed. +_Literal: TypeAlias = str | bytearray | bytes | tuple[_Literal, ...] | list[_Literal] | Any + +re_numeric_part: Pattern[str] def numeric_part(s): ... class Connection(_mysql.connection): default_cursor: type[cursors.Cursor] cursorclass: type[cursors.BaseCursor] - encoders: Any + encoders: Incomplete encoding: str - messages: Any + messages: Incomplete def __init__(self, *args, **kwargs) -> None: ... def __enter__(self) -> Self: ... def __exit__( @@ -34,10 +41,10 @@ class Connection(_mysql.connection): def autocommit(self, on: bool) -> None: ... def cursor(self, cursorclass: type[cursors.BaseCursor] | None = None): ... def query(self, query) -> None: ... - def literal(self, o): ... + def literal(self, o: _Literal) -> bytes: ... def begin(self) -> None: ... def warning_count(self): ... - def set_character_set(self, charset) -> None: ... + def set_character_set(self, charset: LiteralString, collation: LiteralString | None = None) -> None: ... def set_sql_mode(self, sql_mode) -> None: ... def show_warnings(self): ... Warning: type[BaseException] diff --git a/stubs/mysqlclient/MySQLdb/converters.pyi b/stubs/mysqlclient/MySQLdb/converters.pyi index d350ee383..510e795cf 100644 --- a/stubs/mysqlclient/MySQLdb/converters.pyi +++ b/stubs/mysqlclient/MySQLdb/converters.pyi @@ -1,5 +1,5 @@ import array -from typing import Any +from _typeshed import Incomplete from MySQLdb._exceptions import ProgrammingError as ProgrammingError from MySQLdb._mysql import string_literal as string_literal @@ -15,7 +15,7 @@ from MySQLdb.times import ( TimeDelta_or_None as TimeDelta_or_None, ) -NoneType: Any +NoneType: Incomplete ArrayType = array.array def Bool2Str(s, d): ... @@ -27,4 +27,4 @@ def Thing2Literal(o, d): ... def Decimal2Literal(o, d): ... def array2Str(o, d): ... -conversions: Any +conversions: Incomplete diff --git a/stubs/mysqlclient/MySQLdb/cursors.pyi b/stubs/mysqlclient/MySQLdb/cursors.pyi index a739d1228..f572c38e1 100644 --- a/stubs/mysqlclient/MySQLdb/cursors.pyi +++ b/stubs/mysqlclient/MySQLdb/cursors.pyi @@ -1,7 +1,13 @@ from _typeshed import Incomplete -from typing import Any +from collections.abc import Iterable +from re import Pattern +from typing_extensions import LiteralString, TypeAlias -RE_INSERT_VALUES: Any +from .connections import _Literal + +_Arguments: TypeAlias = dict[str, _Literal] | dict[bytes, _Literal] | Iterable[_Literal] + +RE_INSERT_VALUES: Pattern[str] class BaseCursor: from ._exceptions import ( @@ -18,14 +24,14 @@ class BaseCursor: Warning as Warning, ) - max_stmt_length: Any - connection: Any - description: Any - description_flags: Any + max_stmt_length: Incomplete + connection: Incomplete + description: Incomplete + description_flags: Incomplete rowcount: int arraysize: int - lastrowid: Any - rownumber: Any + lastrowid: Incomplete + rownumber: Incomplete def __init__(self, connection) -> None: ... def close(self) -> None: ... def __enter__(self): ... @@ -34,12 +40,13 @@ class BaseCursor: def setinputsizes(self, *args) -> None: ... def setoutputsizes(self, *args) -> None: ... def execute(self, query, args: Incomplete | None = None): ... - def executemany(self, query: str, args: list[Any]) -> int: ... + def mogrify(self, query: str | bytes, args: _Arguments | None = None) -> str: ... + def executemany(self, query: LiteralString, args: Iterable[_Arguments]) -> int | None: ... def callproc(self, procname, args=()): ... def __iter__(self): ... class CursorStoreResultMixIn: - rownumber: Any + rownumber: Incomplete def fetchone(self): ... def fetchmany(self, size: Incomplete | None = None): ... def fetchall(self): ... @@ -47,13 +54,13 @@ class CursorStoreResultMixIn: def __iter__(self): ... class CursorUseResultMixIn: - rownumber: Any + rownumber: Incomplete def fetchone(self): ... def fetchmany(self, size: Incomplete | None = None): ... def fetchall(self): ... def __iter__(self): ... def next(self): ... - __next__: Any + __next__ = next class CursorTupleRowsMixIn: ... class CursorDictRowsMixIn: ...