From b93eae52affaedfda79c00f662f50a2ef3b24c46 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 18 Mar 2025 02:22:34 +0100 Subject: [PATCH] Fix various argument of extension modules (#13651) * Mark various positional-only arguments: These are all positional-only arguments in C code using the `METH_O` flag. * Remove various `*args, **kwargs` arguments that are using the `METH_NOARGS` flag in C. --- stubs/hdbcli/hdbcli/dbapi.pyi | 2 +- stubs/mysqlclient/MySQLdb/_mysql.pyi | 64 ++++++++++++------------- stubs/psycopg2/psycopg2/_psycopg.pyi | 2 +- stubs/regex/regex/regex.pyi | 4 +- stubs/simplejson/simplejson/encoder.pyi | 2 +- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/stubs/hdbcli/hdbcli/dbapi.pyi b/stubs/hdbcli/hdbcli/dbapi.pyi index 4ba75f81b..3d28a2121 100644 --- a/stubs/hdbcli/hdbcli/dbapi.pyi +++ b/stubs/hdbcli/hdbcli/dbapi.pyi @@ -85,7 +85,7 @@ class Cursor: def prepare(self, operation: str, newcursor: Literal[True]) -> Cursor: ... @overload def prepare(self, operation: str, newcursor: Literal[False]) -> Any: ... - def print_message(self, *args, **kwargs): ... + def print_message(self): ... def parsenamedquery(self, *args, **kwargs): ... def scroll(self, value: int, mode: Literal["absolute", "relative"] = ...) -> None: ... def server_cpu_time(self) -> int: ... diff --git a/stubs/mysqlclient/MySQLdb/_mysql.pyi b/stubs/mysqlclient/MySQLdb/_mysql.pyi index b8246512d..0ab789e41 100644 --- a/stubs/mysqlclient/MySQLdb/_mysql.pyi +++ b/stubs/mysqlclient/MySQLdb/_mysql.pyi @@ -24,46 +24,46 @@ class connection: port: Incomplete server_capabilities: Incomplete def __init__(self, *args, **kwargs) -> None: ... - def _get_native_connection(self, *args, **kwargs): ... - def affected_rows(self, *args, **kwargs): ... + def _get_native_connection(self): ... + def affected_rows(self): ... 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 character_set_name(self): ... + def close(self): ... + def commit(self): ... + def dump_debug_info(self): ... + def errno(self): ... + def error(self): ... 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 field_count(self): ... + def fileno(self): ... + def get_autocommit(self): ... + def get_character_set_info(self): ... + def get_host_info(self): ... + def get_proto_info(self): ... + def get_server_info(self): ... + def info(self): ... + def insert_id(self): ... 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 read_query_result(self): ... + def rollback(self): ... 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 shutdown(self): ... + def sqlstate(self): ... + def stat(self): ... + def store_result(self): ... + def string_literal(self, obj, /) -> str: ... + def thread_id(self): ... + def use_result(self): ... def discard_result(self) -> None: ... - def warning_count(self, *args, **kwargs): ... + def warning_count(self): ... def __delattr__(self, name: str, /) -> None: ... def __setattr__(self, name: str, value, /) -> None: ... @@ -72,12 +72,12 @@ class result: has_next: Incomplete def __init__(self, *args, **kwargs) -> None: ... def data_seek(self, n): ... - def describe(self, *args, **kwargs): ... + def describe(self): ... 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 field_flags(self): ... + def num_fields(self): ... + def num_rows(self): ... def __delattr__(self, name: str, /) -> None: ... def __setattr__(self, name: str, value, /) -> None: ... @@ -86,4 +86,4 @@ def debug(*args, **kwargs): ... def escape(obj, dict): ... def escape_string(s): ... def get_client_info(): ... -def string_literal(obj): ... +def string_literal(obj, /) -> str: ... diff --git a/stubs/psycopg2/psycopg2/_psycopg.pyi b/stubs/psycopg2/psycopg2/_psycopg.pyi index 2f5ba5032..1eac96169 100644 --- a/stubs/psycopg2/psycopg2/_psycopg.pyi +++ b/stubs/psycopg2/psycopg2/_psycopg.pyi @@ -378,7 +378,7 @@ class ReplicationCursor(cursor): wal_end: Any def __init__(self, *args, **kwargs) -> None: ... def consume_stream(self, consumer, keepalive_interval=...): ... - def read_message(self, *args, **kwargs): ... + def read_message(self) -> Incomplete | None: ... def send_feedback(self, write_lsn=..., flush_lsn=..., apply_lsn=..., reply=..., force=...): ... def start_replication_expert(self, command, decode=..., status_interval=...): ... diff --git a/stubs/regex/regex/regex.pyi b/stubs/regex/regex/regex.pyi index 07b11b145..b77767738 100644 --- a/stubs/regex/regex/regex.pyi +++ b/stubs/regex/regex/regex.pyi @@ -632,8 +632,8 @@ class Match(Generic[AnyStr]): def ends(self, group: int | str = ..., /) -> list[int]: ... @overload def ends(self, group1: int | str, group2: int | str, /, *groups: int | str) -> tuple[list[int], ...]: ... - def expand(self, template: AnyStr) -> AnyStr: ... - def expandf(self, format: AnyStr) -> AnyStr: ... + def expand(self, template: AnyStr, /) -> AnyStr: ... + def expandf(self, format: AnyStr, /) -> AnyStr: ... @overload def captures(self, group: int | str = ..., /) -> list[AnyStr]: ... @overload diff --git a/stubs/simplejson/simplejson/encoder.pyi b/stubs/simplejson/simplejson/encoder.pyi index a4a09c654..41017f0c1 100644 --- a/stubs/simplejson/simplejson/encoder.pyi +++ b/stubs/simplejson/simplejson/encoder.pyi @@ -57,4 +57,4 @@ class JSONEncoder: class JSONEncoderForHTML(JSONEncoder): ... def encode_basestring(s: str | bytes, _PY3: Literal[True] = ..., _q: str = ...) -> str: ... -def encode_basestring_ascii(s: str | bytes, _PY3: Literal[True] = ...) -> str: ... +def encode_basestring_ascii(s: str | bytes, /) -> str: ...