From 489aedf9b96179328470c53d1f8866e27a9a30b7 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Le Borgne Date: Fri, 13 Nov 2026 22:50:33 +0000 Subject: [PATCH] Name the arguments of describe_consumer_groups() and describe_topics() in order The C methods describe_consumer_groups() and describe_topics() of _AdminClientImpl take the group ids or topic names first and the future second, but their keyword list named them in the opposite order: called with keywords, as in describe_consumer_groups(group_ids=..., future=...), the group ids went to the future and the call failed with "Expected non-empty list of group_ids". AdminClient passes them by position, so only direct callers were affected. Name them in the order they are parsed, fix the order in both doc strings and in the describe_topics() stub, and drop the type: ignore that the stub made necessary in AdminClient.describe_topics(). Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01GwUvhmzgfkiZ6vo4uGyesN --- src/confluent_kafka/admin/__init__.py | 2 +- src/confluent_kafka/cimpl.pyi | 2 +- src/confluent_kafka/src/Admin.c | 8 ++++---- tests/test_Admin.py | 9 +++++++++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/confluent_kafka/admin/__init__.py b/src/confluent_kafka/admin/__init__.py index d42653de2..4743fbe76 100644 --- a/src/confluent_kafka/admin/__init__.py +++ b/src/confluent_kafka/admin/__init__.py @@ -1046,7 +1046,7 @@ def describe_topics( # type: ignore[override] f, futmap = AdminClient._make_futures_v2(topic_names, None, AdminClient._make_futmap_result_from_list) - super(AdminClient, self).describe_topics(topic_names, f, **kwargs) # type: ignore[arg-type] + super(AdminClient, self).describe_topics(topic_names, f, **kwargs) return futmap diff --git a/src/confluent_kafka/cimpl.pyi b/src/confluent_kafka/cimpl.pyi index 9a212540b..2ebc398b4 100644 --- a/src/confluent_kafka/cimpl.pyi +++ b/src/confluent_kafka/cimpl.pyi @@ -657,8 +657,8 @@ class _AdminClientImpl: ) -> None: ... def describe_topics( self, - future: Any, topic_names: List[str], + future: Any, request_timeout: float = -1, include_authorized_operations: bool = False, ) -> None: ... diff --git a/src/confluent_kafka/src/Admin.c b/src/confluent_kafka/src/Admin.c index 30e6cba1e..d51e3ceab 100644 --- a/src/confluent_kafka/src/Admin.c +++ b/src/confluent_kafka/src/Admin.c @@ -2625,7 +2625,7 @@ Admin_describe_consumer_groups(Handle *self, PyObject *args, PyObject *kwargs) { int i = 0; int entered_rk_use = 0; - static char *kws[] = {"future", "group_ids", + static char *kws[] = {"group_ids", "future", /* options */ "request_timeout", "include_authorized_operations", NULL}; @@ -2740,7 +2740,7 @@ Admin_describe_consumer_groups(Handle *self, PyObject *args, PyObject *kwargs) { const char Admin_describe_consumer_groups_doc[] = PyDoc_STR( - ".. py:function:: describe_consumer_groups(future, group_ids, " + ".. py:function:: describe_consumer_groups(group_ids, future, " "[request_timeout], [include_authorized_operations])\n" "\n" " Describes the provided consumer groups.\n" @@ -2767,7 +2767,7 @@ Admin_describe_topics(Handle *self, PyObject *args, PyObject *kwargs) { int i = 0; int entered_rk_use = 0; - static char *kws[] = {"future", "topic_names", + static char *kws[] = {"topic_names", "future", /* options */ "request_timeout", "include_authorized_operations", NULL}; @@ -2895,7 +2895,7 @@ Admin_describe_topics(Handle *self, PyObject *args, PyObject *kwargs) { const char Admin_describe_topics_doc[] = PyDoc_STR( - ".. py:function:: describe_topics(future, topic_names, [request_timeout], " + ".. py:function:: describe_topics(topic_names, future, [request_timeout], " "[include_authorized_operations])\n" "\n" " Describes the provided topics.\n" diff --git a/tests/test_Admin.py b/tests/test_Admin.py index 455e5f0d8..4fb38347e 100644 --- a/tests/test_Admin.py +++ b/tests/test_Admin.py @@ -698,6 +698,15 @@ def test_describe_topics_api(): a.describe_topics(*args, **kwargs) +def test_describe_consumer_groups_and_topics_keyword_arguments(): + """The C methods take their positional arguments by the same names.""" + a = AdminClient({"socket.timeout.ms": 10}) + impl = super(AdminClient, a) + + assert impl.describe_consumer_groups(group_ids=["test-group-1"], future=AdminClient._create_future()) is None + assert impl.describe_topics(topic_names=["test-topic-1"], future=AdminClient._create_future()) is None + + def test_describe_cluster(): a = AdminClient({"socket.timeout.ms": 10})