Skip to content

Commit

Permalink
refactor: enhance and fix cimpl & admin (#149)
Browse files Browse the repository at this point in the history
BREAKING CHANGE
  • Loading branch information
benbenbang committed Sep 5, 2023
1 parent 3baea21 commit 802b99e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
12 changes: 9 additions & 3 deletions confluent_kafka-stubs/_model/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ from __future__ import annotations

# standard library
from enum import Enum
from typing import TYPE_CHECKING, ClassVar
from typing import ClassVar

if TYPE_CHECKING:
from ..cimpl import TopicPartition
from ..cimpl import TopicPartition

class Node:
id: ClassVar[int]
id_string: ClassVar[str]
host: ClassVar[str]
port: ClassVar[int]
rack: ClassVar[str]

def __init__(self, id: int, host: str, port: int, rack: str | None = None) -> None: ...

class ConsumerGroupTopicPartitions:
group_id: ClassVar[str]
topic_partitions: ClassVar[list["TopicPartition"]]

def __init__(self, group_id: str, topic_partitions: list["TopicPartition"] | None = None) -> None: ...

class ConsumerGroupState(Enum):
Expand Down
4 changes: 2 additions & 2 deletions confluent_kafka-stubs/admin/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class AdminClient(_AdminClientImpl):
def delete_topics(
self, topics: list[str], operation_timeout: float = 0, request_timeout: float = 1000.0
) -> dict[str, "Future[NewTopic | None]"]: ...
def list_topics(self, *args, **kwargs) -> list["TopicMetadata | None"]: ...
def list_topics(self, topic: str | None = None, timeout: float = -1) -> "ClusterMetadata": ...
def list_groups(self, *args, **kwargs) -> "ListConsumerGroupsResult | None": ...
def create_partitions(
self, new_partitions: list["NewPartitions"], operation_timeout: float = 0, request_timeout: float = 1000.0
Expand Down Expand Up @@ -105,7 +105,7 @@ class AdminClient(_AdminClientImpl):
list_consumer_group_offsets_request: list["ConsumerGroupTopicPartitions"],
require_stable: bool = False,
request_timeout: float = 1000.0,
) -> dict[str, "Future[ListConsumerGroupsResult]"]: ...
) -> dict[str, "Future[ConsumerGroupTopicPartitions]"]: ...
def alter_consumer_group_offsets(
self,
alter_consumer_group_offsets_request: list["ConsumerGroupTopicPartitions"],
Expand Down
2 changes: 1 addition & 1 deletion confluent_kafka-stubs/admin/_metadata.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ClusterMetadata:
cluster_id: ClassVar[str]
controller_id: ClassVar[int] = -1
brokers: ClassVar[dict[int, "BrokerMetadata"] | None] = None
topics: ClassVar[dict[int, "TopicMetadata"] | None] = None
topics: ClassVar[dict[str, "TopicMetadata"] | None] = None
orig_broker_id: ClassVar[int] = -1
orig_broker_name: ClassVar[str] = ""

Expand Down
12 changes: 12 additions & 0 deletions confluent_kafka-stubs/cimpl.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ class Message:
def __len__(self) -> int: ...

class NewTopic:
topic: ClassVar[str]
num_partitions: ClassVar[int]
replication_factor: ClassVar[int]
replica_assignment: ClassVar[list[list[str]]]
config: ClassVar[dict[str, str] | None]

def __init__(
self,
topic: str,
Expand Down Expand Up @@ -356,6 +362,12 @@ class NewPartitions:
def __ne__(self, other: "NewPartitions") -> bool: ...

class TopicPartition:
topic: ClassVar[str]
partition: ClassVar[int]
offset: ClassVar[int]
metadata: ClassVar[str | None]
leader_epoch: ClassVar[int | None]

def __init__(
self,
topic: str,
Expand Down

0 comments on commit 802b99e

Please sign in to comment.