diff --git a/stubs/PyMySQL/@tests/stubtest_allowlist.txt b/stubs/PyMySQL/@tests/stubtest_allowlist.txt index f8fe06591..8619761d4 100644 --- a/stubs/PyMySQL/@tests/stubtest_allowlist.txt +++ b/stubs/PyMySQL/@tests/stubtest_allowlist.txt @@ -1,6 +1,5 @@ pymysql.connections.byte2int pymysql.connections.int2byte -pymysql.connections.lenenc_int pymysql.connections.pack_int24 pymysql.cursors.Cursor.__del__ # DictCursorMixin changes method types of inherited classes, but doesn't contain much at runtime diff --git a/stubs/PyMySQL/pymysql/_auth.pyi b/stubs/PyMySQL/pymysql/_auth.pyi new file mode 100644 index 000000000..d8fe1ba35 --- /dev/null +++ b/stubs/PyMySQL/pymysql/_auth.pyi @@ -0,0 +1,13 @@ +from _typeshed import Incomplete, ReadableBuffer +from typing import Final + +DEBUG: Final[bool] +SCRAMBLE_LENGTH: Final[int] +sha1_new: Incomplete + +def scramble_native_password(password: ReadableBuffer | None, message: ReadableBuffer | None) -> bytes: ... +def ed25519_password(password: ReadableBuffer, scramble: ReadableBuffer) -> bytes: ... +def sha2_rsa_encrypt(password: bytes, salt: bytes, public_key: bytes) -> bytes: ... +def sha256_password_auth(conn, pkt): ... +def scramble_caching_sha2(password: ReadableBuffer, nonce: ReadableBuffer) -> bytes: ... +def caching_sha2_password_auth(conn, pkt) -> Incomplete | None: ... diff --git a/stubs/PyMySQL/pymysql/charset.pyi b/stubs/PyMySQL/pymysql/charset.pyi index 21d211fbc..5dce19cce 100644 --- a/stubs/PyMySQL/pymysql/charset.pyi +++ b/stubs/PyMySQL/pymysql/charset.pyi @@ -1,15 +1,22 @@ -from typing import Any +from collections.abc import Callable +from typing import Final -MBLENGTH: Any +MBLENGTH: Final[dict[int, int]] class Charset: is_default: bool - def __init__(self, id, name, collation, is_default: bool = False) -> None: ... + def __init__(self, id: int, name: str, collation: str, is_default: bool = False) -> None: ... + @property + def encoding(self) -> str: ... + @property + def is_binary(self) -> bool: ... class Charsets: - def add(self, c): ... - def by_id(self, id): ... - def by_name(self, name): ... + def __init__(self) -> None: ... + def add(self, c: Charset) -> None: ... + def by_id(self, id: int) -> Charset: ... + def by_name(self, name: str) -> Charset: ... -def charset_by_name(name): ... -def charset_by_id(id): ... +_charsets: Charsets +charset_by_name: Callable[[str], Charset] +charset_by_id: Callable[[int], Charset] diff --git a/stubs/PyMySQL/pymysql/connections.pyi b/stubs/PyMySQL/pymysql/connections.pyi index 8604f7c81..967f9f949 100644 --- a/stubs/PyMySQL/pymysql/connections.pyi +++ b/stubs/PyMySQL/pymysql/connections.pyi @@ -10,17 +10,19 @@ from .constants import CLIENT as CLIENT, COMMAND as COMMAND, FIELD_TYPE as FIELD from .cursors import Cursor from .util import byte2int as byte2int, int2byte as int2byte -SSL_ENABLED: Any -DEFAULT_USER: Any -DEBUG: Any -DEFAULT_CHARSET: Any +SSL_ENABLED: bool +DEFAULT_USER: str | None +DEBUG: bool +DEFAULT_CHARSET: str +TEXT_TYPES: set[int] +MAX_PACKET_LEN: int _C = TypeVar("_C", bound=Cursor) _C2 = TypeVar("_C2", bound=Cursor) def dump_packet(data): ... def pack_int24(n): ... -def lenenc_int(i: int) -> bytes: ... +def _lenenc_int(i: int) -> bytes: ... class MysqlPacket: connection: Any diff --git a/stubs/PyMySQL/pymysql/protocol.pyi b/stubs/PyMySQL/pymysql/protocol.pyi new file mode 100644 index 000000000..f645af4b1 --- /dev/null +++ b/stubs/PyMySQL/pymysql/protocol.pyi @@ -0,0 +1,39 @@ +from _typeshed import Incomplete +from typing import Final + +DEBUG: Final[bool] +NULL_COLUMN: Final[int] +UNSIGNED_CHAR_COLUMN: Final[int] +UNSIGNED_SHORT_COLUMN: Final[int] +UNSIGNED_INT24_COLUMN: Final[int] +UNSIGNED_INT64_COLUMN: Final[int] + +def dump_packet(data) -> None: ... + +class MysqlPacket: + def __init__(self, data, encoding) -> None: ... + def get_all_data(self): ... + def read(self, size): ... + def read_all(self): ... + def advance(self, length: int) -> None: ... + def rewind(self, position: int = 0) -> None: ... + def get_bytes(self, position: int, length: int = 1): ... + def read_uint8(self): ... + def read_uint16(self): ... + def read_uint24(self): ... + def read_uint32(self): ... + def read_uint64(self): ... + def read_string(self): ... + def read_length_encoded_integer(self) -> Incomplete | None: ... + def read_length_coded_string(self): ... + def read_struct(self, fmt): ... + def is_ok_packet(self) -> bool: ... + def is_eof_packet(self) -> bool: ... + def is_auth_switch_request(self) -> bool: ... + def is_extra_auth_data(self) -> bool: ... + def is_resultset_packet(self) -> bool: ... + def is_load_local_packet(self) -> bool: ... + def is_error_packet(self) -> bool: ... + def check_error(self) -> None: ... + def raise_for_error(self) -> None: ... + def dump(self) -> None: ...