diff --git a/stubs/kafka-python/@tests/stubtest_allowlist.txt b/stubs/kafka-python/@tests/stubtest_allowlist.txt index b8dfd146c7cc..d58243279e96 100644 --- a/stubs/kafka-python/@tests/stubtest_allowlist.txt +++ b/stubs/kafka-python/@tests/stubtest_allowlist.txt @@ -7,18 +7,25 @@ kafka.producer.__main__ # Benchmark modules are not included in type stubs. kafka.benchmarks.* -# Concrete subclasses define these abstract properties as class attributes. -kafka.protocol.api.Request.API_KEY -kafka.protocol.api.Request.API_VERSION -kafka.protocol.api.Request.RESPONSE_TYPE -kafka.protocol.api.Request.SCHEMA -kafka.protocol.api.Response.API_KEY -kafka.protocol.api.Response.API_VERSION -kafka.protocol.api.Response.SCHEMA - # Vendored compatibility modules are implementation details. kafka.vendor -kafka.vendor.enum34 -kafka.vendor.selectors34 -kafka.vendor.six -kafka.vendor.socketpair + +# Undocumented and clearly not meant to be exposed. +kafka.coordinator.base.heartbeat_log +kafka.net.selector.log_trace +kafka.*\.log +kafka.*\.logger +kafka.*\.__license__ + +# The max_version param expects an int, even though it has as default value of float('inf'). +kafka.protocol.broker_version_data.BrokerVersionData.api_version + +# TODO: This has more attributes. +kafka.protocol.api_header.RequestHeader.client_id +kafka.protocol.api_header.RequestHeader.correlation_id +kafka.protocol.api_header.RequestHeader.request_api_key +kafka.protocol.api_header.RequestHeader.request_api_version +kafka.protocol.api_header.ResponseHeader.correlation_id +kafka.coordinator.assignors.sticky.user_data.StickyAssignorUserData.TopicPartition +kafka.coordinator.assignors.sticky.user_data.StickyAssignorUserData.generation +kafka.coordinator.assignors.sticky.user_data.StickyAssignorUserData.previous_assignment diff --git a/stubs/kafka-python/METADATA.toml b/stubs/kafka-python/METADATA.toml index 33686d2d9baf..ea3e8dab4bfa 100644 --- a/stubs/kafka-python/METADATA.toml +++ b/stubs/kafka-python/METADATA.toml @@ -1,2 +1,2 @@ -version = "2.3.2" +version = "3.0.9" upstream-repository = "https://github.com/dpkp/kafka-python" diff --git a/stubs/kafka-python/kafka/__init__.pyi b/stubs/kafka-python/kafka/__init__.pyi index 36252752f501..b4df0bc6fad8 100644 --- a/stubs/kafka-python/kafka/__init__.pyi +++ b/stubs/kafka-python/kafka/__init__.pyi @@ -1,13 +1,38 @@ -import logging - from kafka.admin import KafkaAdminClient as KafkaAdminClient -from kafka.client_async import KafkaClient as KafkaClient -from kafka.conn import BrokerConnection as BrokerConnection from kafka.consumer import KafkaConsumer as KafkaConsumer -from kafka.consumer.subscription_state import ConsumerRebalanceListener as ConsumerRebalanceListener +from kafka.consumer.subscription_state import ( + AsyncConsumerRebalanceListener as AsyncConsumerRebalanceListener, + ConsumerRebalanceListener as ConsumerRebalanceListener, +) from kafka.producer import KafkaProducer as KafkaProducer +from kafka.protocol.consumer import IsolationLevel as IsolationLevel, OffsetSpec as OffsetSpec +from kafka.serializer import ( + DefaultSerializer as DefaultSerializer, + Deserializer as Deserializer, + JsonSerializer as JsonSerializer, + Serializer as Serializer, +) +from kafka.structs import ( + ConsumerGroupMetadata as ConsumerGroupMetadata, + OffsetAndMetadata as OffsetAndMetadata, + TopicPartition as TopicPartition, + TopicPartitionReplica as TopicPartitionReplica, +) -__all__ = ["BrokerConnection", "ConsumerRebalanceListener", "KafkaAdminClient", "KafkaClient", "KafkaConsumer", "KafkaProducer"] - -class NullHandler(logging.Handler): - def emit(self, record) -> None: ... +__all__ = [ + "KafkaAdminClient", + "KafkaConsumer", + "KafkaProducer", + "AsyncConsumerRebalanceListener", + "ConsumerRebalanceListener", + "DefaultSerializer", + "JsonSerializer", + "Serializer", + "Deserializer", + "ConsumerGroupMetadata", + "OffsetAndMetadata", + "TopicPartition", + "TopicPartitionReplica", + "IsolationLevel", + "OffsetSpec", +] diff --git a/stubs/kafka-python/kafka/admin/__init__.pyi b/stubs/kafka-python/kafka/admin/__init__.pyi index d895bbf521e0..8db21243ba72 100644 --- a/stubs/kafka-python/kafka/admin/__init__.pyi +++ b/stubs/kafka-python/kafka/admin/__init__.pyi @@ -1,4 +1,4 @@ -from kafka.admin.acl_resource import ( +from kafka.admin._acls import ( ACL as ACL, ACLFilter as ACLFilter, ACLOperation as ACLOperation, @@ -8,23 +8,61 @@ from kafka.admin.acl_resource import ( ResourcePatternFilter as ResourcePatternFilter, ResourceType as ResourceType, ) +from kafka.admin._cluster import UpdateFeatureType as UpdateFeatureType +from kafka.admin._configs import ( + AlterConfigOp as AlterConfigOp, + ConfigFilterType as ConfigFilterType, + ConfigResource as ConfigResource, + ConfigResourceType as ConfigResourceType, + ConfigSourceType as ConfigSourceType, + ConfigType as ConfigType, +) +from kafka.admin._groups import GroupState as GroupState, GroupType as GroupType, MemberToRemove as MemberToRemove +from kafka.admin._partitions import NewPartitions as NewPartitions, OffsetSpec as OffsetSpec, OffsetTimestamp as OffsetTimestamp +from kafka.admin._topics import NewTopic as NewTopic +from kafka.admin._transactions import ( + AbortTransactionSpec as AbortTransactionSpec, + PartitionProducerState as PartitionProducerState, + ProducerState as ProducerState, + TransactionDescription as TransactionDescription, + TransactionListing as TransactionListing, + TransactionState as TransactionState, +) +from kafka.admin._users import ( + ScramMechanism as ScramMechanism, + UserScramCredentialDeletion as UserScramCredentialDeletion, + UserScramCredentialUpsertion as UserScramCredentialUpsertion, +) from kafka.admin.client import KafkaAdminClient as KafkaAdminClient -from kafka.admin.config_resource import ConfigResource as ConfigResource, ConfigResourceType as ConfigResourceType -from kafka.admin.new_partitions import NewPartitions as NewPartitions -from kafka.admin.new_topic import NewTopic as NewTopic __all__ = [ - "ConfigResource", - "ConfigResourceType", "KafkaAdminClient", - "NewTopic", - "NewPartitions", "ACL", "ACLFilter", - "ResourcePattern", - "ResourcePatternFilter", "ACLOperation", - "ResourceType", "ACLPermissionType", "ACLResourcePatternType", + "ResourceType", + "ResourcePattern", + "ResourcePatternFilter", + "AlterConfigOp", + "ConfigResource", + "ConfigResourceType", + "ConfigType", + "ConfigSourceType", + "UpdateFeatureType", + "GroupState", + "GroupType", + "MemberToRemove", + "OffsetSpec", + "OffsetTimestamp", + "AbortTransactionSpec", + "PartitionProducerState", + "ProducerState", + "TransactionDescription", + "TransactionListing", + "TransactionState", + "ScramMechanism", + "UserScramCredentialDeletion", + "UserScramCredentialUpsertion", ] diff --git a/stubs/kafka-python/kafka/admin/acl_resource.pyi b/stubs/kafka-python/kafka/admin/_acls.pyi similarity index 69% rename from stubs/kafka-python/kafka/admin/acl_resource.pyi rename to stubs/kafka-python/kafka/admin/_acls.pyi index ea613c07dbe3..cb348d886743 100644 --- a/stubs/kafka-python/kafka/admin/acl_resource.pyi +++ b/stubs/kafka-python/kafka/admin/_acls.pyi @@ -1,13 +1,30 @@ +from _typeshed import Incomplete +from collections.abc import Sequence from enum import IntEnum +from typing import TypedDict, type_check_only + +from kafka.errors import KafkaError + +@type_check_only +class _CreateAclsResult(TypedDict): + succeeded: list[ACL] + failed: list[type[KafkaError]] + +class ACLAdminMixin: + config: dict[Incomplete, Incomplete] + def describe_acls(self, acl_filter: ACLFilter) -> tuple[list[ACL], type[KafkaError]]: ... + def create_acls(self, acls: Sequence[ACL]) -> _CreateAclsResult: ... + def delete_acls(self, acl_filters: Sequence[ACLFilter]) -> list[tuple[ACLFilter, list[ACL], type[KafkaError]]]: ... class ResourceType(IntEnum): UNKNOWN = 0 ANY = 1 - CLUSTER = 4 - DELEGATION_TOKEN = 6 - GROUP = 3 TOPIC = 2 + GROUP = 3 + CLUSTER = 4 TRANSACTIONAL_ID = 5 + DELEGATION_TOKEN = 6 + USER = 7 class ACLOperation(IntEnum): UNKNOWN = 0 @@ -24,7 +41,7 @@ class ACLOperation(IntEnum): ALTER_CONFIGS = 11 IDEMPOTENT_WRITE = 12 CREATE_TOKENS = 13 - DESCRIBE_TOKENS = 13 + DESCRIBE_TOKENS = 14 class ACLPermissionType(IntEnum): UNKNOWN = 0 @@ -39,6 +56,25 @@ class ACLResourcePatternType(IntEnum): LITERAL = 3 PREFIXED = 4 +class ResourcePatternFilter: + resource_type: ResourceType + resource_name: str | None + pattern_type: ACLResourcePatternType + def __init__(self, resource_type: ResourceType, resource_name: str | None, pattern_type: ACLResourcePatternType) -> None: ... + def validate(self) -> None: ... + def __eq__(self, other: ResourcePatternFilter) -> bool: ... # type: ignore[override] + def __hash__(self) -> int: ... + +class ResourcePattern(ResourcePatternFilter): + resource_name: str + def __init__( + self, + resource_type: ResourceType, + resource_name: str, + pattern_type: ACLResourcePatternType = ACLResourcePatternType.LITERAL, + ) -> None: ... + def validate(self) -> None: ... + class ACLFilter: principal: str | None host: str | None @@ -54,8 +90,8 @@ class ACLFilter: resource_pattern: ResourcePatternFilter, ) -> None: ... def validate(self) -> None: ... - def __eq__(self, other): ... - def __hash__(self): ... + def __eq__(self, other: ACLFilter) -> bool: ... # type: ignore[override] + def __hash__(self) -> int: ... class ACL(ACLFilter): resource_pattern: ResourcePattern @@ -69,23 +105,4 @@ class ACL(ACLFilter): ) -> None: ... def validate(self) -> None: ... -class ResourcePatternFilter: - resource_type: ResourceType - resource_name: str | None - pattern_type: ACLResourcePatternType - def __init__(self, resource_type: ResourceType, resource_name: str | None, pattern_type: ACLResourcePatternType) -> None: ... - def validate(self) -> None: ... - def __eq__(self, other): ... - def __hash__(self): ... - -class ResourcePattern(ResourcePatternFilter): - resource_name: str - def __init__( - self, - resource_type: ResourceType, - resource_name: str, - pattern_type: ACLResourcePatternType = ACLResourcePatternType.LITERAL, - ) -> None: ... - def validate(self) -> None: ... - def valid_acl_operations(int_vals) -> set[ACLOperation]: ... diff --git a/stubs/kafka-python/kafka/admin/_cluster.pyi b/stubs/kafka-python/kafka/admin/_cluster.pyi new file mode 100644 index 000000000000..4faa7f80c99c --- /dev/null +++ b/stubs/kafka-python/kafka/admin/_cluster.pyi @@ -0,0 +1,27 @@ +from _typeshed import Incomplete +from enum import IntEnum + +from kafka.protocol.api_key import ApiKey +from kafka.util import EnumHelper + +class ClusterAdminMixin: + def describe_cluster(self) -> dict[str, Incomplete]: ... + def describe_log_dirs( + self, + topic_partitions: dict[Incomplete, Incomplete] | list[Incomplete] | None = None, + brokers: list[Incomplete] | None = None, + ) -> list[dict[str, Incomplete]]: ... + def alter_replica_log_dirs(self, replica_assignments): ... + def describe_metadata_quorum(self): ... + def get_broker_version_data(self, broker_id): ... + def api_versions(self) -> dict[ApiKey, tuple[int, int] | Incomplete]: ... + def describe_features(self, send_request_to_controller: bool = False) -> dict[str, Incomplete]: ... + def update_features( + self, feature_updates: dict[Incomplete, Incomplete], validate_only: bool = False, timeout_ms: int = 60000 + ) -> dict[Incomplete, Incomplete]: ... + +class UpdateFeatureType(EnumHelper, IntEnum): + UNKNOWN = 0 + UPGRADE = 1 + SAFE_DOWNGRADE = 2 + UNSAFE_DOWNGRADE = 3 diff --git a/stubs/kafka-python/kafka/admin/_configs.pyi b/stubs/kafka-python/kafka/admin/_configs.pyi new file mode 100644 index 000000000000..8842b8c4a17b --- /dev/null +++ b/stubs/kafka-python/kafka/admin/_configs.pyi @@ -0,0 +1,83 @@ +from _typeshed import Incomplete +from collections.abc import Mapping, Sequence +from enum import IntEnum + +from kafka.util import EnumHelper + +class ConfigAdminMixin: + config: dict[Incomplete, Incomplete] + def describe_configs( + self, + config_resources: Sequence[ConfigResource], + include_synonyms: bool = False, + config_filter: ConfigFilterType | str = "modified", + ): ... + def list_config_resources(self, resource_types: Sequence[ConfigResourceType | str] | None = None): ... + def alter_configs( + self, + config_resources: Sequence[ConfigResource], + validate_only: bool = False, + raise_on_unknown: bool = True, + incremental: bool | None = None, + ): ... + def reset_configs( + self, + config_resources: Sequence[ConfigResource], + validate_only: bool = False, + raise_on_unknown: bool = True, + incremental: bool | None = None, + ): ... + +class AlterConfigOp(EnumHelper, IntEnum): + SET = 0 + DELETE = 1 + APPEND = 2 + SUBTRACT = 3 + +class ConfigFilterType(EnumHelper, IntEnum): + ALL = 0 + DYNAMIC = 1 + MODIFIED = 2 + DEFAULT = 3 + STATIC = 4 + def should_skip(self, config_source: ConfigSourceType) -> bool: ... + +class ConfigResourceType(EnumHelper, IntEnum): + UNKNOWN = 0 + TOPIC = 2 + BROKER = 4 + BROKER_LOGGER = 8 + CLIENT_METRICS = 16 + GROUP = 32 + +class ConfigResource: + resource_type: ConfigResourceType + name: str + configs: Mapping[str, str] | None + def __init__(self, resource_type: ConfigResourceType | str, name: str, configs: Mapping[str, str] | None = None) -> None: ... + +class ConfigType(EnumHelper, IntEnum): + UNKNOWN = 0 + BOOLEAN = 1 + STRING = 2 + INT = 3 + SHORT = 4 + LONG = 5 + DOUBLE = 6 + LIST = 7 + CLASS = 8 + PASSWORD = 9 + +class ConfigSourceType(EnumHelper, IntEnum): + UNKNOWN = 0 + DYNAMIC_TOPIC_CONFIG = 1 + DYNAMIC_BROKER_CONFIG = 2 + DYNAMIC_DEFAULT_BROKER_CONFIG = 3 + STATIC_BROKER_CONFIG = 4 + DEFAULT_CONFIG = 5 + DYNAMIC_BROKER_LOGGER_CONFIG = 6 + DYNAMIC_CLIENT_METRICS_CONFIG = 7 + DYNAMIC_GROUP_CONFIG = 8 + def is_modified(self) -> bool: ... + @classmethod + def dynamic_for_resource_type(cls, resource_type: ConfigResourceType) -> ConfigSourceType: ... diff --git a/stubs/kafka-python/kafka/admin/_groups.pyi b/stubs/kafka-python/kafka/admin/_groups.pyi new file mode 100644 index 000000000000..abe2d632c507 --- /dev/null +++ b/stubs/kafka-python/kafka/admin/_groups.pyi @@ -0,0 +1,64 @@ +import sys +from _typeshed import Incomplete + +from kafka.util import EnumHelper + +class GroupAdminMixin: + config: dict[Incomplete, Incomplete] + def describe_groups( + self, group_ids, group_coordinator_id: int | None = None, include_authorized_operations: bool = False + ): ... + def list_groups(self, broker_ids=None, states_filter=None, types_filter=None): ... + def list_group_offsets(self, group_specs): ... + def delete_groups(self, group_ids, group_coordinator_id: int | None = None): ... + def alter_group_offsets(self, group_id: str, offsets, group_coordinator_id: int | None = None): ... + def reset_group_offsets(self, group_id: str, offset_specs, group_coordinator_id: int | None = None): ... + def delete_group_offsets(self, group_id: str, partitions, group_coordinator_id: int | None = None): ... + def remove_group_members(self, group_id: str, members, group_coordinator_id: int | None = None): ... + +class MemberToRemove: + __slots__ = ("member_id", "group_instance_id", "reason") + member_id: str | None + group_instance_id: str | None + reason: str | None + def __init__(self, member_id: str | None = None, group_instance_id: str | None = None, reason: str | None = None) -> None: ... + def __eq__(self, other: MemberToRemove) -> bool: ... # type: ignore[override] + def __hash__(self) -> int: ... + +if sys.version_info >= (3, 11): + from enum import StrEnum + + class GroupState(EnumHelper, StrEnum): + UNKNOWN = "Unknown" + PREPARING_REBALANCE = "PreparingRebalance" + COMPLETING_REBALANCE = "CompletingRebalance" + STABLE = "Stable" + DEAD = "Dead" + EMPTY = "Empty" + ASSIGNING = "Assigning" + RECONCILING = "Reconciling" + + class GroupType(EnumHelper, StrEnum): + UNKNOWN = "Unknown" + CLASSIC = "classic" + CONSUMER = "consumer" + SHARE = "share" + +else: + from enum import Enum + + class GroupState(EnumHelper, str, Enum): + UNKNOWN = "Unknown" + PREPARING_REBALANCE = "PreparingRebalance" + COMPLETING_REBALANCE = "CompletingRebalance" + STABLE = "Stable" + DEAD = "Dead" + EMPTY = "Empty" + ASSIGNING = "Assigning" + RECONCILING = "Reconciling" + + class GroupType(EnumHelper, str, Enum): + UNKNOWN = "Unknown" + CLASSIC = "classic" + CONSUMER = "consumer" + SHARE = "share" diff --git a/stubs/kafka-python/kafka/admin/_partitions.pyi b/stubs/kafka-python/kafka/admin/_partitions.pyi new file mode 100644 index 000000000000..fde83e35b19f --- /dev/null +++ b/stubs/kafka-python/kafka/admin/_partitions.pyi @@ -0,0 +1,32 @@ +from _typeshed import Incomplete +from collections.abc import Mapping, Sequence +from typing_extensions import deprecated + +from kafka.protocol.consumer import IsolationLevel, OffsetSpec as OffsetSpec, OffsetTimestamp as OffsetTimestamp +from kafka.structs import TopicPartition + +class PartitionAdminMixin: + config: dict[Incomplete, Incomplete] + def create_partitions( + self, + topic_partitions: Mapping[str, int | dict[Incomplete, Incomplete] | NewPartitions], + timeout_ms: int | None = None, + validate_only: bool = False, + raise_errors: bool = True, + ): ... + def delete_records( + self, records_to_delete: Mapping[TopicPartition, int], timeout_ms: float | None = None, partition_leader_id=None + ) -> dict[TopicPartition, Incomplete]: ... + def elect_leaders(self, election_type, topic_partitions=None, timeout_ms=None, raise_errors: bool = True): ... + def alter_partition_reassignments(self, reassignments, timeout_ms=None): ... + def list_partition_reassignments(self, topic_partitions=None, timeout_ms=None): ... + def describe_topic_partitions(self, topics, response_partition_limit: int = 2000, cursor=None): ... + def list_partition_offsets( + self, topic_partition_specs, isolation_level: IsolationLevel = IsolationLevel.READ_UNCOMMITTED, timeout_ms=None + ): ... + +@deprecated("Deprecated since v3.0.0. Use simple `dict` instead.") +class NewPartitions: + total_count: int + new_assignments: Sequence[Sequence[int]] | None + def __init__(self, total_count: int, new_assignments: Sequence[Sequence[int]] | None = None) -> None: ... diff --git a/stubs/kafka-python/kafka/admin/_topics.pyi b/stubs/kafka-python/kafka/admin/_topics.pyi new file mode 100644 index 000000000000..ccdb7cc6c93c --- /dev/null +++ b/stubs/kafka-python/kafka/admin/_topics.pyi @@ -0,0 +1,35 @@ +import uuid +from _typeshed import Incomplete +from collections.abc import Mapping, Sequence +from typing_extensions import deprecated + +class TopicAdminMixin: + config: dict[Incomplete, Incomplete] + def list_topics(self) -> list[str]: ... + def describe_topics(self, topics: Sequence[str | uuid.UUID] | None = None) -> list[dict[str, Incomplete]]: ... + def create_topics( + self, + new_topics: dict[str, dict[Incomplete, Incomplete]] | Sequence[NewTopic], + timeout_ms: float | None = None, + validate_only: bool = False, + raise_errors: bool = True, + wait_for_metadata: bool = False, + ): ... + def wait_for_topics(self, topic_names, timeout_ms: float | None = 10000): ... + def delete_topics(self, topics: Sequence[str | uuid.UUID], timeout_ms: float | None = None, raise_errors: bool = True): ... + +@deprecated("Deprecated since v3.0.0. Use simple `dict` instead.") +class NewTopic: + name: str + num_partitions: int + replication_factor: int + replica_assignments: Mapping[int, Sequence[int]] | None + topic_configs: Mapping[str, str] | None + def __init__( + self, + name: str, + num_partitions: int = -1, + replication_factor: int = -1, + replica_assignments: Mapping[int, Sequence[int]] | None = None, + topic_configs: Mapping[str, str] | None = None, + ) -> None: ... diff --git a/stubs/kafka-python/kafka/admin/_transactions.pyi b/stubs/kafka-python/kafka/admin/_transactions.pyi new file mode 100644 index 000000000000..fb381a30b34f --- /dev/null +++ b/stubs/kafka-python/kafka/admin/_transactions.pyi @@ -0,0 +1,80 @@ +import sys +from _typeshed import Incomplete +from typing import NamedTuple + +from kafka.structs import TopicPartition +from kafka.util import EnumHelper + +if sys.version_info >= (3, 11): + from enum import StrEnum + + class TransactionState(EnumHelper, StrEnum): + EMPTY = "Empty" + ONGOING = "Ongoing" + PREPARE_COMMIT = "PrepareCommit" + PREPARE_ABORT = "PrepareAbort" + COMPLETE_COMMIT = "CompleteCommit" + COMPLETE_ABORT = "CompleteAbort" + DEAD = "Dead" + PREPARE_EPOCH_FENCE = "PrepareEpochFence" + UNKNOWN = "Unknown" + +else: + from enum import Enum + + class TransactionState(EnumHelper, str, Enum): + EMPTY = "Empty" + ONGOING = "Ongoing" + PREPARE_COMMIT = "PrepareCommit" + PREPARE_ABORT = "PrepareAbort" + COMPLETE_COMMIT = "CompleteCommit" + COMPLETE_ABORT = "CompleteAbort" + DEAD = "Dead" + PREPARE_EPOCH_FENCE = "PrepareEpochFence" + UNKNOWN = "Unknown" + +class TransactionListing(NamedTuple): + transactional_id: str + producer_id: int + state: TransactionState + +class TransactionDescription(NamedTuple): + coordinator_id: int + state: TransactionState + producer_id: int + producer_epoch: int + transaction_timeout_ms: int + transaction_start_time_ms: int + topic_partitions: set[TopicPartition] + +class ProducerState(NamedTuple): + producer_id: int + producer_epoch: int + last_sequence: int + last_timestamp: int + coordinator_epoch: int + current_transaction_start_offset: int + +class PartitionProducerState(NamedTuple): + active_producers: list[ProducerState] + +class AbortTransactionSpec(NamedTuple): + topic_partition: TopicPartition + producer_id: int + producer_epoch: int + coordinator_epoch: int = -1 + +class TransactionsAdminMixin: + config: dict[Incomplete, Incomplete] + def list_transactions( + self, + broker_ids=None, + producer_id_filters=None, + state_filters=None, + duration_filter_ms: float | None = None, + transactional_id_pattern: str | None = None, + ): ... + def describe_transactions(self, transactional_ids): ... + def describe_producers(self, partitions, broker_id: int | None = None): ... + def abort_transaction(self, spec): ... + def find_hanging_transactions(self, broker_ids=None, max_transaction_timeout_ms: float = 900000): ... diff --git a/stubs/kafka-python/kafka/admin/_users.pyi b/stubs/kafka-python/kafka/admin/_users.pyi new file mode 100644 index 000000000000..9937bc64f07d --- /dev/null +++ b/stubs/kafka-python/kafka/admin/_users.pyi @@ -0,0 +1,36 @@ +from _typeshed import ReadableBuffer +from collections.abc import Sequence +from enum import IntEnum +from typing import Final + +class UserAdminMixin: + def alter_user_scram_credentials(self, alterations: Sequence[UserScramCredentialDeletion | UserScramCredentialUpsertion]): ... + def describe_user_scram_credentials(self, users: Sequence[str] | None = None): ... + +class ScramMechanism(IntEnum): + UNKNOWN = 0 + SCRAM_SHA_256 = 1 + SCRAM_SHA_512 = 2 + @property + def hash_name(self) -> str: ... + +class UserScramCredentialDeletion: + user: str + mechanism: ScramMechanism + def __init__(self, user: str, mechanism: ScramMechanism | int | str) -> None: ... + +class UserScramCredentialUpsertion: + DEFAULT_ITERATIONS: Final = 4096 + user: str + mechanism: ScramMechanism + iterations: int + salt: ReadableBuffer + salted_password: bytes + def __init__( + self, + user: str, + mechanism: ScramMechanism | int | str, + password: str | ReadableBuffer, + iterations: int | None = None, + salt: ReadableBuffer | None = None, + ) -> None: ... diff --git a/stubs/kafka-python/kafka/admin/client.pyi b/stubs/kafka-python/kafka/admin/client.pyi index bbda95e50889..f83c11bd361f 100644 --- a/stubs/kafka-python/kafka/admin/client.pyi +++ b/stubs/kafka-python/kafka/admin/client.pyi @@ -1,114 +1,77 @@ import selectors import ssl from _typeshed import Incomplete -from collections.abc import Callable, Iterable, Mapping, Sequence -from typing import Literal, TypeAlias, TypedDict, type_check_only -from typing_extensions import Unpack +from collections.abc import Callable, Sequence +from types import TracebackType +from typing import Literal +from typing_extensions import Self -from kafka.admin.acl_resource import ACL, ACLFilter -from kafka.admin.config_resource import ConfigResource -from kafka.admin.new_partitions import NewPartitions -from kafka.admin.new_topic import NewTopic -from kafka.errors import KafkaError -from kafka.protocol.admin import ElectionType -from kafka.structs import GroupInformation, OffsetAndMetadata, TopicPartition +from kafka.admin._acls import ACLAdminMixin +from kafka.admin._cluster import ClusterAdminMixin +from kafka.admin._configs import ConfigAdminMixin +from kafka.admin._groups import GroupAdminMixin +from kafka.admin._partitions import PartitionAdminMixin +from kafka.admin._topics import TopicAdminMixin +from kafka.admin._transactions import TransactionsAdminMixin +from kafka.admin._users import UserAdminMixin +from kafka.net.sasl.oauth import AbstractTokenProvider -_ApiVersion: TypeAlias = tuple[int, ...] -_BootstrapServers: TypeAlias = str | Sequence[str] -_KafkaClientFactory: TypeAlias = Callable[..., object] -_SaslMechanism: TypeAlias = Literal["PLAIN", "GSSAPI", "OAUTHBEARER", "SCRAM-SHA-256", "SCRAM-SHA-512"] -_SecurityProtocol: TypeAlias = Literal["PLAINTEXT", "SSL", "SASL_PLAINTEXT", "SASL_SSL"] -_SocketOption: TypeAlias = tuple[int, int, int] - -@type_check_only -class _KafkaAdminClientConfig(TypedDict, total=False): - bootstrap_servers: _BootstrapServers - client_id: str - request_timeout_ms: int - connections_max_idle_ms: int - reconnect_backoff_ms: int - reconnect_backoff_max_ms: int - max_in_flight_requests_per_connection: int - receive_buffer_bytes: int | None - send_buffer_bytes: int | None - socket_options: Sequence[_SocketOption] - sock_chunk_bytes: int - sock_chunk_buffer_count: int - retry_backoff_ms: int - metadata_max_age_ms: int - security_protocol: _SecurityProtocol - ssl_context: ssl.SSLContext | None - ssl_check_hostname: bool - ssl_cafile: str | None - ssl_certfile: str | None - ssl_keyfile: str | None - ssl_password: str | None - ssl_crlfile: str | None - api_version: _ApiVersion | None - api_version_auto_timeout_ms: int - selector: type[selectors.BaseSelector] - sasl_mechanism: _SaslMechanism | None - sasl_plain_username: str | None - sasl_plain_password: str | None - sasl_kerberos_name: object | None - sasl_kerberos_service_name: str - sasl_kerberos_domain_name: str | None - sasl_oauth_token_provider: object | None - socks5_proxy: str | None - metric_reporters: Sequence[type[object]] - metrics_num_samples: int - metrics_sample_window_ms: int - kafka_client: _KafkaClientFactory - -@type_check_only -class _CreateAclsResult(TypedDict): - succeeded: list[ACL] - failed: list[tuple[ACL, KafkaError]] - -log: Incomplete - -class KafkaAdminClient: - DEFAULT_CONFIG: Incomplete - config: Incomplete - def __init__(self, **configs: Unpack[_KafkaAdminClientConfig]) -> None: ... - def close(self) -> None: ... - def send_request(self, request, node_id=None): ... - def send_requests(self, requests_and_node_ids, response_fn=...): ... - def create_topics(self, new_topics: Sequence[NewTopic], timeout_ms: int | None = None, validate_only: bool = False): ... - def delete_topics(self, topics: Sequence[str], timeout_ms: int | None = None): ... - def list_topics(self) -> list[str]: ... - def describe_topics(self, topics: Sequence[str] | None = None) -> list[dict[str, Incomplete]]: ... - def describe_cluster(self) -> dict[str, Incomplete]: ... - def describe_acls(self, acl_filter: ACLFilter) -> tuple[list[ACL], KafkaError]: ... - def create_acls(self, acls: Sequence[ACL]) -> _CreateAclsResult: ... - def delete_acls( - self, acl_filters: Sequence[ACLFilter] - ) -> list[tuple[ACLFilter, list[tuple[ACL, KafkaError]], KafkaError]]: ... - def describe_configs(self, config_resources: Sequence[ConfigResource], include_synonyms: bool = False): ... - def alter_configs(self, config_resources: Sequence[ConfigResource]): ... - def create_partitions( - self, topic_partitions: Mapping[str, NewPartitions], timeout_ms: int | None = None, validate_only: bool = False - ): ... - def delete_records( - self, - records_to_delete: Mapping[TopicPartition, int], - timeout_ms: float | None = None, - partition_leader_id: int | None = None, - ) -> dict[TopicPartition, Incomplete]: ... - def describe_consumer_groups( - self, group_ids: Sequence[str], group_coordinator_id: int | None = None, include_authorized_operations: bool = False - ) -> list[GroupInformation]: ... - def list_consumer_groups(self, broker_ids: Sequence[int] | None = None) -> list[tuple[str, str]]: ... - def list_consumer_group_offsets( - self, group_id: str, group_coordinator_id: int | None = None, partitions: Iterable[TopicPartition] | None = None - ) -> dict[TopicPartition, OffsetAndMetadata]: ... - def delete_consumer_groups( - self, group_ids: Sequence[str], group_coordinator_id: int | None = None - ) -> list[tuple[str, KafkaError]]: ... - def perform_leader_election( +class KafkaAdminClient( + ACLAdminMixin, + ClusterAdminMixin, + ConfigAdminMixin, + GroupAdminMixin, + PartitionAdminMixin, + TopicAdminMixin, + TransactionsAdminMixin, + UserAdminMixin, +): + DEFAULT_CONFIG: dict[str, Incomplete] + config: dict[str, Incomplete] + def __init__( self, - election_type: int | ElectionType, - topic_partitions: Mapping[str, Sequence[int]] | None = None, - timeout_ms: int | None = None, - ): ... - def describe_log_dirs(self): ... + *, + bootstrap_servers: str | Sequence[str] = "localhost", + client_id: str = ..., + request_timeout_ms: int = 30_000, + connections_max_idle_ms: int = 540_000, + reconnect_backoff_ms: int = 50, + reconnect_backoff_max_ms: int = 30_000, + max_in_flight_requests_per_connection: int = 5, + receive_message_max_bytes: int = 100_000_000, + receive_buffer_bytes: int | None = None, + send_buffer_bytes: int | None = None, + socket_options: Sequence[tuple[int, int, int]] = ..., + retry_backoff_ms: int = 100, + metadata_max_age_ms: int = 300_000, + client_dns_lookup: str = "use_all_dns_ips", + security_protocol: Literal["PLAINTEXT", "SSL", "SASL_PLAINTEXT", "SASL_SSL"] = "PLAINTEXT", + ssl_context: ssl.SSLContext | None = None, + ssl_check_hostname: bool = True, + ssl_cafile: str | None = None, + ssl_certfile: str | None = None, + ssl_keyfile: str | None = None, + ssl_password: str | None = None, + ssl_crlfile: str | None = None, + api_version: tuple[int, ...] | None = None, + bootstrap_timeout_ms: int = 30_000, + selector: type[selectors.BaseSelector] = selectors.DefaultSelector, + sasl_mechanism: Literal["PLAIN", "GSSAPI", "OAUTHBEARER", "SCRAM-SHA-256", "SCRAM-SHA-512"] | None = None, + sasl_plain_username: str | None = None, + sasl_plain_password: str | None = None, + sasl_kerberos_name: object | None = None, + sasl_kerberos_service_name: str = "kafka", + sasl_kerberos_domain_name: str | None = None, + sasl_oauth_token_provider: AbstractTokenProvider | None = None, + proxy_url: str | None = None, + socks5_proxy: str | None = None, + metric_reporters: Sequence[type[object]] = [], + metrics_num_samples: int = 2, + metrics_sample_window_ms: int = 30_000, + kafka_client: Callable[..., object] = ..., + ) -> None: ... + def __enter__(self) -> Self: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> None: ... + def close(self) -> None: ... diff --git a/stubs/kafka-python/kafka/admin/config_resource.pyi b/stubs/kafka-python/kafka/admin/config_resource.pyi deleted file mode 100644 index 8a54cca3b482..000000000000 --- a/stubs/kafka-python/kafka/admin/config_resource.pyi +++ /dev/null @@ -1,12 +0,0 @@ -from collections.abc import Mapping -from enum import IntEnum - -class ConfigResourceType(IntEnum): - BROKER = 4 - TOPIC = 2 - -class ConfigResource: - resource_type: ConfigResourceType - name: str - configs: Mapping[str, str] | None - def __init__(self, resource_type: ConfigResourceType, name: str, configs: Mapping[str, str] | None = None) -> None: ... diff --git a/stubs/kafka-python/kafka/admin/new_partitions.pyi b/stubs/kafka-python/kafka/admin/new_partitions.pyi deleted file mode 100644 index b828f1f5fef6..000000000000 --- a/stubs/kafka-python/kafka/admin/new_partitions.pyi +++ /dev/null @@ -1,6 +0,0 @@ -from collections.abc import Sequence - -class NewPartitions: - total_count: int - new_assignments: Sequence[Sequence[int]] | None - def __init__(self, total_count: int, new_assignments: Sequence[Sequence[int]] | None = None) -> None: ... diff --git a/stubs/kafka-python/kafka/admin/new_topic.pyi b/stubs/kafka-python/kafka/admin/new_topic.pyi deleted file mode 100644 index 4a1d64ba08c0..000000000000 --- a/stubs/kafka-python/kafka/admin/new_topic.pyi +++ /dev/null @@ -1,16 +0,0 @@ -from collections.abc import Mapping, Sequence - -class NewTopic: - name: str - num_partitions: int - replication_factor: int - replica_assignments: Mapping[int, Sequence[int]] | None - topic_configs: Mapping[str, str] | None - def __init__( - self, - name: str, - num_partitions: int = -1, - replication_factor: int = -1, - replica_assignments: Mapping[int, Sequence[int]] | None = None, - topic_configs: Mapping[str, str] | None = None, - ) -> None: ... diff --git a/stubs/kafka-python/kafka/cli/__init__.pyi b/stubs/kafka-python/kafka/cli/__init__.pyi index e69de29bb2d1..0ff9583c55d3 100644 --- a/stubs/kafka-python/kafka/cli/__init__.pyi +++ b/stubs/kafka-python/kafka/cli/__init__.pyi @@ -0,0 +1,6 @@ +from collections.abc import Sequence +from typing import Final + +USAGE: Final[str] + +def run_cli(args: Sequence[str] | None = None): ... diff --git a/stubs/kafka-python/kafka/cli/admin/__init__.pyi b/stubs/kafka-python/kafka/cli/admin/__init__.pyi index 50eefc19daa8..858a47e2a4f4 100644 --- a/stubs/kafka-python/kafka/cli/admin/__init__.pyi +++ b/stubs/kafka-python/kafka/cli/admin/__init__.pyi @@ -1,3 +1,10 @@ -def main_parser(): ... -def build_kwargs(props): ... -def run_cli(args=None): ... +from _typeshed import Incomplete +from argparse import ArgumentParser +from collections.abc import Iterable, Sequence +from typing import Final, Literal + +DEFAULT_COMMAND_GROUPS: Final[tuple[type[Incomplete], ...]] + +def main_parser(prog: str | None = None) -> ArgumentParser: ... +def build_parser(groups: Iterable[Incomplete] = (), prog: str | None = None) -> ArgumentParser: ... +def run_cli(args: Sequence[str] | None = None, prog: str | None = None) -> Literal[0, 1]: ... diff --git a/stubs/kafka-python/kafka/cli/admin/acls/__init__.pyi b/stubs/kafka-python/kafka/cli/admin/acls/__init__.pyi new file mode 100644 index 000000000000..e912ffc496f7 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/acls/__init__.pyi @@ -0,0 +1,10 @@ +from typing import ClassVar + +from .create import CreateACLs as CreateACLs +from .delete import DeleteACLs as DeleteACLs +from .describe import DescribeACLs as DescribeACLs + +class ACLsCommandGroup: + GROUP: ClassVar[str] + HELP: ClassVar[str] + COMMANDS: ClassVar[list[type[CreateACLs | DeleteACLs | DescribeACLs]]] diff --git a/stubs/kafka-python/kafka/cli/admin/acls/common.pyi b/stubs/kafka-python/kafka/cli/admin/acls/common.pyi new file mode 100644 index 000000000000..e8240e52f66b --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/acls/common.pyi @@ -0,0 +1,8 @@ +from argparse import ArgumentParser, Namespace + +from kafka.admin._acls import ACL, ACLFilter + +def add_acl_filter_args(parser: ArgumentParser) -> None: ... +def add_acl_args(parser: ArgumentParser, required: bool = False) -> None: ... +def acl_filter_from_args(args: Namespace) -> ACLFilter: ... +def acl_from_args(args: Namespace) -> ACL: ... diff --git a/stubs/kafka-python/kafka/cli/admin/acls/create.pyi b/stubs/kafka-python/kafka/cli/admin/acls/create.pyi new file mode 100644 index 000000000000..ec0cb1769a1f --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/acls/create.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class CreateACLs: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace) -> dict[str, list[str]]: ... diff --git a/stubs/kafka-python/kafka/cli/admin/acls/delete.pyi b/stubs/kafka-python/kafka/cli/admin/acls/delete.pyi new file mode 100644 index 000000000000..2d01a119b10b --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/acls/delete.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class DeleteACLs: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace) -> list[dict[str, str | list[str]]]: ... diff --git a/stubs/kafka-python/kafka/cli/admin/acls/describe.pyi b/stubs/kafka-python/kafka/cli/admin/acls/describe.pyi new file mode 100644 index 000000000000..efec8643f6c7 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/acls/describe.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class DescribeACLs: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace) -> list[str]: ... diff --git a/stubs/kafka-python/kafka/cli/admin/cluster/__init__.pyi b/stubs/kafka-python/kafka/cli/admin/cluster/__init__.pyi index 3a1217ed3605..3648c304df63 100644 --- a/stubs/kafka-python/kafka/cli/admin/cluster/__init__.pyi +++ b/stubs/kafka-python/kafka/cli/admin/cluster/__init__.pyi @@ -1,3 +1,25 @@ -class ClusterSubCommand: - @classmethod - def add_subparser(cls, subparsers): ... +from typing import ClassVar + +from .describe import DescribeCluster as DescribeCluster +from .describe_quorum import DescribeQuorum as DescribeQuorum +from .features import DescribeFeatures as DescribeFeatures, UpdateFeatures as UpdateFeatures +from .log_dirs import AlterLogDirs as AlterLogDirs, DescribeLogDirs as DescribeLogDirs +from .versions import GetApiVersions as GetApiVersions, GetBrokerVersion as GetBrokerVersion + +class ClusterCommandGroup: + GROUP: ClassVar[str] + HELP: ClassVar[str] + COMMANDS: ClassVar[ + list[ + type[ + DescribeCluster + | DescribeQuorum + | GetApiVersions + | GetBrokerVersion + | DescribeFeatures + | UpdateFeatures + | DescribeLogDirs + | AlterLogDirs + ] + ] + ] diff --git a/stubs/kafka-python/kafka/cli/admin/cluster/describe.pyi b/stubs/kafka-python/kafka/cli/admin/cluster/describe.pyi index d68bcbed33cb..61da926f0817 100644 --- a/stubs/kafka-python/kafka/cli/admin/cluster/describe.pyi +++ b/stubs/kafka-python/kafka/cli/admin/cluster/describe.pyi @@ -1,3 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + class DescribeCluster: + COMMAND: ClassVar[str] + HELP: ClassVar[str] @classmethod - def add_subparser(cls, subparsers): ... + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/cluster/describe_quorum.pyi b/stubs/kafka-python/kafka/cli/admin/cluster/describe_quorum.pyi new file mode 100644 index 000000000000..cb62c6776c4a --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/cluster/describe_quorum.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class DescribeQuorum: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/cluster/features.pyi b/stubs/kafka-python/kafka/cli/admin/cluster/features.pyi new file mode 100644 index 000000000000..ddaaac6c8093 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/cluster/features.pyi @@ -0,0 +1,18 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class DescribeFeatures: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... + +class UpdateFeatures: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/cluster/log_dirs.pyi b/stubs/kafka-python/kafka/cli/admin/cluster/log_dirs.pyi new file mode 100644 index 000000000000..8c93a9394494 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/cluster/log_dirs.pyi @@ -0,0 +1,18 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class DescribeLogDirs: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... + +class AlterLogDirs: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/cluster/versions.pyi b/stubs/kafka-python/kafka/cli/admin/cluster/versions.pyi new file mode 100644 index 000000000000..c586e68ea2b2 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/cluster/versions.pyi @@ -0,0 +1,18 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class GetApiVersions: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... + +class GetBrokerVersion: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/configs/__init__.pyi b/stubs/kafka-python/kafka/cli/admin/configs/__init__.pyi index bf9567add55a..eb707fc5f581 100644 --- a/stubs/kafka-python/kafka/cli/admin/configs/__init__.pyi +++ b/stubs/kafka-python/kafka/cli/admin/configs/__init__.pyi @@ -1,3 +1,12 @@ -class ConfigsSubCommand: - @classmethod - def add_subparser(cls, subparsers): ... +from builtins import list as _list +from typing import ClassVar + +from .alter import AlterConfigs as AlterConfigs +from .describe import DescribeConfigs as DescribeConfigs +from .list import ListConfigResources as ListConfigResources +from .reset import ResetConfigs as ResetConfigs + +class ConfigsCommandGroup: + GROUP: ClassVar[str] + HELP: ClassVar[str] + COMMANDS: ClassVar[_list[type[DescribeConfigs | AlterConfigs | ListConfigResources | ResetConfigs]]] diff --git a/stubs/kafka-python/kafka/cli/admin/configs/alter.pyi b/stubs/kafka-python/kafka/cli/admin/configs/alter.pyi new file mode 100644 index 000000000000..352545904c6e --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/configs/alter.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class AlterConfigs: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/configs/common.pyi b/stubs/kafka-python/kafka/cli/admin/configs/common.pyi new file mode 100644 index 000000000000..1cb0927ffb12 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/configs/common.pyi @@ -0,0 +1,7 @@ +from argparse import ArgumentParser, Namespace +from collections.abc import Mapping + +from kafka.admin import ConfigResource + +def add_resource_arguments(parser: ArgumentParser) -> None: ... +def parse_resources(args: Namespace, configs: Mapping[str, str] | None = None) -> list[ConfigResource]: ... diff --git a/stubs/kafka-python/kafka/cli/admin/configs/describe.pyi b/stubs/kafka-python/kafka/cli/admin/configs/describe.pyi index 175fad7af132..00911c79ea40 100644 --- a/stubs/kafka-python/kafka/cli/admin/configs/describe.pyi +++ b/stubs/kafka-python/kafka/cli/admin/configs/describe.pyi @@ -1,5 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + class DescribeConfigs: + COMMAND: ClassVar[str] + HELP: ClassVar[str] @classmethod - def add_subparser(cls, subparsers) -> None: ... + def add_arguments(cls, parser: ArgumentParser) -> None: ... @classmethod - def command(cls, client, args): ... + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/configs/list.pyi b/stubs/kafka-python/kafka/cli/admin/configs/list.pyi new file mode 100644 index 000000000000..1b25e66036ba --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/configs/list.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class ListConfigResources: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/configs/reset.pyi b/stubs/kafka-python/kafka/cli/admin/configs/reset.pyi new file mode 100644 index 000000000000..2d64756dbce7 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/configs/reset.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class ResetConfigs: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/consumer_groups/__init__.pyi b/stubs/kafka-python/kafka/cli/admin/consumer_groups/__init__.pyi deleted file mode 100644 index 782b1765b411..000000000000 --- a/stubs/kafka-python/kafka/cli/admin/consumer_groups/__init__.pyi +++ /dev/null @@ -1,3 +0,0 @@ -class ConsumerGroupsSubCommand: - @classmethod - def add_subparser(cls, subparsers): ... diff --git a/stubs/kafka-python/kafka/cli/admin/consumer_groups/delete.pyi b/stubs/kafka-python/kafka/cli/admin/consumer_groups/delete.pyi deleted file mode 100644 index 90e373374fc5..000000000000 --- a/stubs/kafka-python/kafka/cli/admin/consumer_groups/delete.pyi +++ /dev/null @@ -1,3 +0,0 @@ -class DeleteConsumerGroups: - @classmethod - def add_subparser(cls, subparsers): ... diff --git a/stubs/kafka-python/kafka/cli/admin/consumer_groups/describe.pyi b/stubs/kafka-python/kafka/cli/admin/consumer_groups/describe.pyi deleted file mode 100644 index ce25bc8a0d33..000000000000 --- a/stubs/kafka-python/kafka/cli/admin/consumer_groups/describe.pyi +++ /dev/null @@ -1,3 +0,0 @@ -class DescribeConsumerGroups: - @classmethod - def add_subparser(cls, subparsers): ... diff --git a/stubs/kafka-python/kafka/cli/admin/consumer_groups/list.pyi b/stubs/kafka-python/kafka/cli/admin/consumer_groups/list.pyi deleted file mode 100644 index 9e16c1de775f..000000000000 --- a/stubs/kafka-python/kafka/cli/admin/consumer_groups/list.pyi +++ /dev/null @@ -1,3 +0,0 @@ -class ListConsumerGroups: - @classmethod - def add_subparser(cls, subparsers): ... diff --git a/stubs/kafka-python/kafka/cli/admin/consumer_groups/list_offsets.pyi b/stubs/kafka-python/kafka/cli/admin/consumer_groups/list_offsets.pyi deleted file mode 100644 index e175d4510b08..000000000000 --- a/stubs/kafka-python/kafka/cli/admin/consumer_groups/list_offsets.pyi +++ /dev/null @@ -1,3 +0,0 @@ -class ListConsumerGroupOffsets: - @classmethod - def add_subparser(cls, subparsers): ... diff --git a/stubs/kafka-python/kafka/cli/admin/groups/__init__.pyi b/stubs/kafka-python/kafka/cli/admin/groups/__init__.pyi new file mode 100644 index 000000000000..9c172a682635 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/groups/__init__.pyi @@ -0,0 +1,29 @@ +from builtins import list as _list +from typing import ClassVar + +from .alter_offsets import AlterGroupOffsets as AlterGroupOffsets +from .delete import DeleteGroups as DeleteGroups +from .delete_offsets import DeleteGroupOffsets as DeleteGroupOffsets +from .describe import DescribeGroups as DescribeGroups +from .list import ListGroups as ListGroups +from .list_offsets import ListGroupOffsets as ListGroupOffsets +from .remove_members import RemoveGroupMembers as RemoveGroupMembers +from .reset_offsets import ResetGroupOffsets as ResetGroupOffsets + +class GroupsCommandGroup: + GROUP: ClassVar[str] + HELP: ClassVar[str] + COMMANDS: ClassVar[ + _list[ + type[ + ListGroups + | DescribeGroups + | DeleteGroups + | ListGroupOffsets + | AlterGroupOffsets + | ResetGroupOffsets + | DeleteGroupOffsets + | RemoveGroupMembers + ] + ] + ] diff --git a/stubs/kafka-python/kafka/cli/admin/groups/alter_offsets.pyi b/stubs/kafka-python/kafka/cli/admin/groups/alter_offsets.pyi new file mode 100644 index 000000000000..ff1638fbfca2 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/groups/alter_offsets.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class AlterGroupOffsets: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/groups/delete.pyi b/stubs/kafka-python/kafka/cli/admin/groups/delete.pyi new file mode 100644 index 000000000000..0709db861eb4 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/groups/delete.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class DeleteGroups: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/groups/delete_offsets.pyi b/stubs/kafka-python/kafka/cli/admin/groups/delete_offsets.pyi new file mode 100644 index 000000000000..043b8de719c9 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/groups/delete_offsets.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class DeleteGroupOffsets: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/groups/describe.pyi b/stubs/kafka-python/kafka/cli/admin/groups/describe.pyi new file mode 100644 index 000000000000..cd072ca86a4d --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/groups/describe.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class DescribeGroups: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/groups/list.pyi b/stubs/kafka-python/kafka/cli/admin/groups/list.pyi new file mode 100644 index 000000000000..8b3d45ceae35 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/groups/list.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class ListGroups: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/groups/list_offsets.pyi b/stubs/kafka-python/kafka/cli/admin/groups/list_offsets.pyi new file mode 100644 index 000000000000..50cbd4de698f --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/groups/list_offsets.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class ListGroupOffsets: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/groups/remove_members.pyi b/stubs/kafka-python/kafka/cli/admin/groups/remove_members.pyi new file mode 100644 index 000000000000..0eca80d14f68 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/groups/remove_members.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class RemoveGroupMembers: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/groups/reset_offsets.pyi b/stubs/kafka-python/kafka/cli/admin/groups/reset_offsets.pyi new file mode 100644 index 000000000000..c8ca4b195239 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/groups/reset_offsets.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class ResetGroupOffsets: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/log_dirs/__init__.pyi b/stubs/kafka-python/kafka/cli/admin/log_dirs/__init__.pyi deleted file mode 100644 index a42ac1f93a4e..000000000000 --- a/stubs/kafka-python/kafka/cli/admin/log_dirs/__init__.pyi +++ /dev/null @@ -1,3 +0,0 @@ -class LogDirsSubCommand: - @classmethod - def add_subparser(cls, subparsers): ... diff --git a/stubs/kafka-python/kafka/cli/admin/log_dirs/describe.pyi b/stubs/kafka-python/kafka/cli/admin/log_dirs/describe.pyi deleted file mode 100644 index a9ab6d5a7bc9..000000000000 --- a/stubs/kafka-python/kafka/cli/admin/log_dirs/describe.pyi +++ /dev/null @@ -1,3 +0,0 @@ -class DescribeLogDirs: - @classmethod - def add_subparser(cls, subparsers): ... diff --git a/stubs/kafka-python/kafka/cli/admin/partitions/__init__.pyi b/stubs/kafka-python/kafka/cli/admin/partitions/__init__.pyi new file mode 100644 index 000000000000..86830132391c --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/partitions/__init__.pyi @@ -0,0 +1,26 @@ +from typing import ClassVar + +from .alter_reassignments import AlterPartitionReassignments as AlterPartitionReassignments +from .create import CreatePartitions as CreatePartitions +from .delete_records import DeleteRecords as DeleteRecords +from .describe import DescribeTopicPartitions as DescribeTopicPartitions +from .elect_leaders import ElectLeaders as ElectLeaders +from .list_offsets import ListPartitionOffsets as ListPartitionOffsets +from .list_reassignments import ListPartitionReassignments as ListPartitionReassignments + +class PartitionsCommandGroup: + GROUP: ClassVar[str] + HELP: ClassVar[str] + COMMANDS: ClassVar[ + list[ + type[ + CreatePartitions + | DescribeTopicPartitions + | ListPartitionOffsets + | ListPartitionReassignments + | AlterPartitionReassignments + | DeleteRecords + | ElectLeaders + ] + ] + ] diff --git a/stubs/kafka-python/kafka/cli/admin/partitions/alter_reassignments.pyi b/stubs/kafka-python/kafka/cli/admin/partitions/alter_reassignments.pyi new file mode 100644 index 000000000000..97ad131b2043 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/partitions/alter_reassignments.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class AlterPartitionReassignments: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/partitions/create.pyi b/stubs/kafka-python/kafka/cli/admin/partitions/create.pyi new file mode 100644 index 000000000000..1fa2cff1d847 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/partitions/create.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class CreatePartitions: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/partitions/delete_records.pyi b/stubs/kafka-python/kafka/cli/admin/partitions/delete_records.pyi new file mode 100644 index 000000000000..ab09f0b76a36 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/partitions/delete_records.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class DeleteRecords: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/partitions/describe.pyi b/stubs/kafka-python/kafka/cli/admin/partitions/describe.pyi new file mode 100644 index 000000000000..0b8e09da01ae --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/partitions/describe.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class DescribeTopicPartitions: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/partitions/elect_leaders.pyi b/stubs/kafka-python/kafka/cli/admin/partitions/elect_leaders.pyi new file mode 100644 index 000000000000..fb32599c1e4e --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/partitions/elect_leaders.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class ElectLeaders: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/partitions/list_offsets.pyi b/stubs/kafka-python/kafka/cli/admin/partitions/list_offsets.pyi new file mode 100644 index 000000000000..0a9bbae86dd7 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/partitions/list_offsets.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class ListPartitionOffsets: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/partitions/list_reassignments.pyi b/stubs/kafka-python/kafka/cli/admin/partitions/list_reassignments.pyi new file mode 100644 index 000000000000..cbd232b083a8 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/partitions/list_reassignments.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class ListPartitionReassignments: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/topics/__init__.pyi b/stubs/kafka-python/kafka/cli/admin/topics/__init__.pyi index 0345a054a456..8bd2b923b143 100644 --- a/stubs/kafka-python/kafka/cli/admin/topics/__init__.pyi +++ b/stubs/kafka-python/kafka/cli/admin/topics/__init__.pyi @@ -1,3 +1,12 @@ -class TopicsSubCommand: - @classmethod - def add_subparser(cls, subparsers): ... +from builtins import list as _list +from typing import ClassVar + +from .create import CreateTopic as CreateTopic +from .delete import DeleteTopic as DeleteTopic +from .describe import DescribeTopics as DescribeTopics +from .list import ListTopics as ListTopics + +class TopicsCommandGroup: + GROUP: ClassVar[str] + HELP: ClassVar[str] + COMMANDS: ClassVar[_list[type[ListTopics | DescribeTopics | CreateTopic | DeleteTopic]]] diff --git a/stubs/kafka-python/kafka/cli/admin/topics/create.pyi b/stubs/kafka-python/kafka/cli/admin/topics/create.pyi index 2902efef9999..2b93872c070e 100644 --- a/stubs/kafka-python/kafka/cli/admin/topics/create.pyi +++ b/stubs/kafka-python/kafka/cli/admin/topics/create.pyi @@ -1,5 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + class CreateTopic: + COMMAND: ClassVar[str] + HELP: ClassVar[str] @classmethod - def add_subparser(cls, subparsers) -> None: ... + def add_arguments(cls, parser: ArgumentParser) -> None: ... @classmethod - def command(cls, client, args): ... + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/topics/delete.pyi b/stubs/kafka-python/kafka/cli/admin/topics/delete.pyi index 128a5c51365e..c233c135783b 100644 --- a/stubs/kafka-python/kafka/cli/admin/topics/delete.pyi +++ b/stubs/kafka-python/kafka/cli/admin/topics/delete.pyi @@ -1,3 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + class DeleteTopic: + COMMAND: ClassVar[str] + HELP: ClassVar[str] @classmethod - def add_subparser(cls, subparsers): ... + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/topics/describe.pyi b/stubs/kafka-python/kafka/cli/admin/topics/describe.pyi index ab0ec7438f58..400eb72ba029 100644 --- a/stubs/kafka-python/kafka/cli/admin/topics/describe.pyi +++ b/stubs/kafka-python/kafka/cli/admin/topics/describe.pyi @@ -1,3 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + class DescribeTopics: + COMMAND: ClassVar[str] + HELP: ClassVar[str] @classmethod - def add_subparser(cls, subparsers): ... + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/topics/list.pyi b/stubs/kafka-python/kafka/cli/admin/topics/list.pyi index b23a865b72e4..9ce08a5b60a3 100644 --- a/stubs/kafka-python/kafka/cli/admin/topics/list.pyi +++ b/stubs/kafka-python/kafka/cli/admin/topics/list.pyi @@ -1,3 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + class ListTopics: + COMMAND: ClassVar[str] + HELP: ClassVar[str] @classmethod - def add_subparser(cls, subparsers): ... + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/transactions/__init__.pyi b/stubs/kafka-python/kafka/cli/admin/transactions/__init__.pyi new file mode 100644 index 000000000000..9aaf5f38b1dc --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/transactions/__init__.pyi @@ -0,0 +1,15 @@ +from builtins import list as _list +from typing import ClassVar + +from .abort import AbortTransaction as AbortTransaction +from .describe import DescribeTransactions as DescribeTransactions +from .describe_producers import DescribeProducers as DescribeProducers +from .find_hanging import FindHangingTransactions as FindHangingTransactions +from .list import ListTransactions as ListTransactions + +class TransactionsCommandGroup: + GROUP: ClassVar[str] + HELP: ClassVar[str] + COMMANDS: ClassVar[ + _list[type[ListTransactions | DescribeTransactions | DescribeProducers | FindHangingTransactions | AbortTransaction]] + ] diff --git a/stubs/kafka-python/kafka/cli/admin/transactions/abort.pyi b/stubs/kafka-python/kafka/cli/admin/transactions/abort.pyi new file mode 100644 index 000000000000..ab041e45d67a --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/transactions/abort.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class AbortTransaction: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/transactions/describe.pyi b/stubs/kafka-python/kafka/cli/admin/transactions/describe.pyi new file mode 100644 index 000000000000..a7c24dbe1af1 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/transactions/describe.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class DescribeTransactions: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/transactions/describe_producers.pyi b/stubs/kafka-python/kafka/cli/admin/transactions/describe_producers.pyi new file mode 100644 index 000000000000..00dc69493027 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/transactions/describe_producers.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class DescribeProducers: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/transactions/find_hanging.pyi b/stubs/kafka-python/kafka/cli/admin/transactions/find_hanging.pyi new file mode 100644 index 000000000000..225137449936 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/transactions/find_hanging.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class FindHangingTransactions: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/transactions/list.pyi b/stubs/kafka-python/kafka/cli/admin/transactions/list.pyi new file mode 100644 index 000000000000..917f0a7254a6 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/transactions/list.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class ListTransactions: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/users/__init__.pyi b/stubs/kafka-python/kafka/cli/admin/users/__init__.pyi new file mode 100644 index 000000000000..79ef7b8e2222 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/users/__init__.pyi @@ -0,0 +1,9 @@ +from typing import ClassVar + +from .alter_user_scram_credentials import AlterUserScramCredentials as AlterUserScramCredentials +from .describe_user_scram_credentials import DescribeUserScramCredentials as DescribeUserScramCredentials + +class UsersCommandGroup: + GROUP: ClassVar[str] + HELP: ClassVar[str] + COMMANDS: ClassVar[list[type[DescribeUserScramCredentials | AlterUserScramCredentials]]] diff --git a/stubs/kafka-python/kafka/cli/admin/users/alter_user_scram_credentials.pyi b/stubs/kafka-python/kafka/cli/admin/users/alter_user_scram_credentials.pyi new file mode 100644 index 000000000000..0351c7c5a8e7 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/users/alter_user_scram_credentials.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class AlterUserScramCredentials: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/admin/users/describe_user_scram_credentials.pyi b/stubs/kafka-python/kafka/cli/admin/users/describe_user_scram_credentials.pyi new file mode 100644 index 000000000000..b597cc3defd1 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/admin/users/describe_user_scram_credentials.pyi @@ -0,0 +1,10 @@ +from argparse import ArgumentParser, Namespace +from typing import ClassVar + +class DescribeUserScramCredentials: + COMMAND: ClassVar[str] + HELP: ClassVar[str] + @classmethod + def add_arguments(cls, parser: ArgumentParser) -> None: ... + @classmethod + def command(cls, client, args: Namespace): ... diff --git a/stubs/kafka-python/kafka/cli/common.pyi b/stubs/kafka-python/kafka/cli/common.pyi new file mode 100644 index 000000000000..6ec3dec8e395 --- /dev/null +++ b/stubs/kafka-python/kafka/cli/common.pyi @@ -0,0 +1,11 @@ +from _typeshed import Incomplete +from argparse import ArgumentParser +from collections.abc import Iterable + +def add_connect_cli_args(parser: ArgumentParser, bootstrap_required: bool = True) -> None: ... +def build_kwargs(props: Iterable[str]) -> dict[str, Incomplete]: ... +def build_connect_kwargs(config) -> dict[str, Incomplete]: ... +def add_logging_cli_args(parser: ArgumentParser) -> None: ... +def add_extended_cli_args(parser: ArgumentParser) -> None: ... +def configure_logging(config) -> None: ... +def add_common_cli_args(parser: ArgumentParser, bootstrap_required: bool = True) -> None: ... diff --git a/stubs/kafka-python/kafka/cli/consumer/__init__.pyi b/stubs/kafka-python/kafka/cli/consumer/__init__.pyi index 50eefc19daa8..47c52debb8e8 100644 --- a/stubs/kafka-python/kafka/cli/consumer/__init__.pyi +++ b/stubs/kafka-python/kafka/cli/consumer/__init__.pyi @@ -1,3 +1,6 @@ -def main_parser(): ... -def build_kwargs(props): ... -def run_cli(args=None): ... +from argparse import ArgumentParser +from collections.abc import Iterable +from typing import Literal + +def main_parser(prog: str | None = None) -> ArgumentParser: ... +def run_cli(args: Iterable[str] | None = None, prog: str | None = None) -> Literal[0, 1] | None: ... diff --git a/stubs/kafka-python/kafka/cli/producer/__init__.pyi b/stubs/kafka-python/kafka/cli/producer/__init__.pyi index 50eefc19daa8..7fdb378ee5f8 100644 --- a/stubs/kafka-python/kafka/cli/producer/__init__.pyi +++ b/stubs/kafka-python/kafka/cli/producer/__init__.pyi @@ -1,3 +1,6 @@ -def main_parser(): ... -def build_kwargs(props): ... -def run_cli(args=None): ... +from argparse import ArgumentParser +from collections.abc import Iterable +from typing import Literal + +def main_parser(prog: str | None = None) -> ArgumentParser: ... +def run_cli(args: Iterable[str] | None = None, prog: str | None = None) -> Literal[0, 1]: ... diff --git a/stubs/kafka-python/kafka/client_async.pyi b/stubs/kafka-python/kafka/client_async.pyi deleted file mode 100644 index 3946ec2b79a9..000000000000 --- a/stubs/kafka-python/kafka/client_async.pyi +++ /dev/null @@ -1,56 +0,0 @@ -from _typeshed import Incomplete -from collections import OrderedDict as OrderedDict - -log: Incomplete -socketpair: Incomplete - -class KafkaClient: - DEFAULT_CONFIG: Incomplete - config: Incomplete - cluster: Incomplete - def __init__(self, **configs) -> None: ... - def maybe_connect(self, node_id, wakeup: bool = True): ... - def connection_failed(self, node_id): ... - def ready(self, node_id, metadata_priority: bool = True): ... - def connected(self, node_id): ... - def close(self, node_id=None) -> None: ... - def __del__(self) -> None: ... - def is_disconnected(self, node_id): ... - def connection_delay(self, node_id): ... - def throttle_delay(self, node_id): ... - def is_ready(self, node_id, metadata_priority: bool = True): ... - def send(self, node_id, request, wakeup: bool = True, request_timeout_ms=None): ... - def poll(self, timeout_ms=None, future=None): ... - def in_flight_request_count(self, node_id=None): ... - def least_loaded_node(self): ... - def least_loaded_node_refresh_ms(self): ... - def set_topics(self, topics): ... - def add_topic(self, topic): ... - def get_api_versions(self): ... - def check_version(self, node_id=None, timeout=None, **kwargs): ... - def api_version(self, operation, max_version=None): ... - def wakeup(self) -> None: ... - def bootstrap_connected(self): ... - def await_ready(self, node_id, timeout_ms: int = 30000): ... - def send_and_receive(self, node_id, request): ... - -class IdleConnectionManager: - connections_max_idle: Incomplete - next_idle_close_check_time: Incomplete - lru_connections: Incomplete - def __init__(self, connections_max_idle_ms) -> None: ... - def update(self, conn_id) -> None: ... - def remove(self, conn_id) -> None: ... - def is_expired(self, conn_id): ... - def next_check_ms(self): ... - def update_next_idle_close_check_time(self, ts) -> None: ... - def poll_expired_connection(self): ... - -class KafkaClientMetrics: - metrics: Incomplete - metric_group_name: Incomplete - connection_closed: Incomplete - connection_created: Incomplete - select_time: Incomplete - io_time: Incomplete - def __init__(self, metrics, metric_group_prefix, conns) -> None: ... diff --git a/stubs/kafka-python/kafka/cluster.pyi b/stubs/kafka-python/kafka/cluster.pyi index bcfab555ca99..7c0107194ce1 100644 --- a/stubs/kafka-python/kafka/cluster.pyi +++ b/stubs/kafka-python/kafka/cluster.pyi @@ -1,36 +1,58 @@ from _typeshed import Incomplete +from socket import AddressFamily +from typing import Final -log: Incomplete +from kafka.future import Future +from kafka.protocol.metadata import CoordinatorType, MetadataRequest class ClusterMetadata: - DEFAULT_CONFIG: Incomplete + DEFAULT_CONFIG: dict[str, Incomplete] need_all_topic_metadata: bool unauthorized_topics: Incomplete internal_topics: Incomplete controller: Incomplete cluster_id: Incomplete - config: Incomplete + config: dict[str, Incomplete] + closed: bool def __init__(self, **configs) -> None: ... - def is_bootstrap(self, node_id): ... - def brokers(self): ... + @property + def metadata_refresh_in_progress(self) -> bool: ... + def attach(self, manager) -> None: ... + def close(self) -> None: ... + def start_refresh_loop(self) -> None: ... + async def refresh_metadata(self, node_id=None) -> None: ... + def is_bootstrap(self, node_id) -> bool: ... + def set_topics(self, topics) -> Future: ... + def add_topic(self, topic: str) -> Future: ... + def brokers(self) -> list[Incomplete]: ... + def bootstrap_brokers(self) -> list[Incomplete]: ... def broker_metadata(self, broker_id): ... def partitions_for_topic(self, topic): ... def available_partitions_for_topic(self, topic): ... def leader_for_partition(self, partition): ... + def is_replica_node(self, partition, node_id): ... def leader_epoch_for_partition(self, partition): ... + def update_partition_leader(self, partition, leader_id: int, leader_epoch: int) -> bool: ... def partitions_for_broker(self, broker_id): ... - def coordinator_for_group(self, group): ... + def get_coordinator(self, key: str, key_type: CoordinatorType = CoordinatorType.GROUP): ... def ttl(self): ... def refresh_backoff(self): ... - def request_update(self): ... + def request_update(self) -> Future: ... @property - def need_update(self): ... + def need_update(self) -> bool: ... def topics(self, exclude_internal_topics: bool = True): ... + def metadata_request(self) -> MetadataRequest: ... + def topic_id(self, topic_name): ... + def topic_name_for_id(self, topic_id): ... def failed_update(self, exception) -> None: ... def update_metadata(self, metadata): ... def add_listener(self, listener) -> None: ... def remove_listener(self, listener) -> None: ... - def add_coordinator(self, response, coord_type, coord_key): ... - def with_partitions(self, partitions_to_add): ... + def add_coordinator(self, response, key_type: CoordinatorType, key: str, synthesize_node_id: bool = True): ... + +def collect_hosts(hosts, randomize: bool = True) -> list[Incomplete]: ... +def expand_to_canonical_bootstrap_hosts(hosts) -> list[Incomplete]: ... + +DEFAULT_KAFKA_PORT: Final = 9092 -def collect_hosts(hosts, randomize: bool = True): ... +def get_ip_port_afi(host_and_port_str: str) -> tuple[str, int, AddressFamily]: ... diff --git a/stubs/kafka-python/kafka/conn.pyi b/stubs/kafka-python/kafka/conn.pyi deleted file mode 100644 index dd7d99adbc3a..000000000000 --- a/stubs/kafka-python/kafka/conn.pyi +++ /dev/null @@ -1,70 +0,0 @@ -import ssl -from _typeshed import Incomplete - -log: Incomplete -DEFAULT_KAFKA_PORT: int -ssl_available: bool -SSLEOFError = ssl.SSLEOFError -SSLWantReadError = ssl.SSLWantReadError -SSLWantWriteError = ssl.SSLWantWriteError -SSLZeroReturnError = ssl.SSLZeroReturnError - -AFI_NAMES: Incomplete - -class ConnectionStates: - DISCONNECTED: str - CONNECTING: str - HANDSHAKE: str - CONNECTED: str - AUTHENTICATING: str - API_VERSIONS_SEND: str - API_VERSIONS_RECV: str - -class BrokerConnection: - DEFAULT_CONFIG: Incomplete - SECURITY_PROTOCOLS: Incomplete - VERSION_CHECKS: Incomplete - host: Incomplete - port: Incomplete - afi: Incomplete - config: Incomplete - node_id: Incomplete - in_flight_requests: Incomplete - state: Incomplete - last_attempt: int - def __init__(self, host, port, afi, **configs) -> None: ... - def connect_blocking(self, timeout=...): ... - def connect(self): ... - def blacked_out(self): ... - def throttled(self): ... - def throttle_delay(self): ... - def connection_delay(self): ... - def connected(self): ... - def connecting(self): ... - def initializing(self): ... - def disconnected(self): ... - def connect_failed(self): ... - def __del__(self) -> None: ... - def close(self, error=None) -> None: ... - def send(self, request, blocking: bool = True, request_timeout_ms=None): ... - def send_pending_requests(self): ... - def send_pending_requests_v2(self): ... - def can_send_more(self): ... - def recv(self): ... - def requests_timed_out(self): ... - def timed_out_ifrs(self): ... - def next_ifr_request_timeout_ms(self): ... - def get_api_versions(self): ... - def check_version(self, timeout: int = 2, **kwargs): ... - -class BrokerConnectionMetrics: - metrics: Incomplete - bytes_sent: Incomplete - bytes_received: Incomplete - request_time: Incomplete - throttle_time: Incomplete - def __init__(self, metrics, metric_group_prefix, node_id) -> None: ... - -def get_ip_port_afi(host_and_port_str): ... -def is_inet_4_or_6(gai): ... -def dns_lookup(host, port, afi=...): ... diff --git a/stubs/kafka-python/kafka/consumer/fetcher.pyi b/stubs/kafka-python/kafka/consumer/fetcher.pyi index a34ae667d98b..5807c0a18b9e 100644 --- a/stubs/kafka-python/kafka/consumer/fetcher.pyi +++ b/stubs/kafka-python/kafka/consumer/fetcher.pyi @@ -3,11 +3,6 @@ from typing import ClassVar, NamedTuple import kafka.errors as Errors -log: Incomplete -READ_UNCOMMITTED: int -READ_COMMITTED: int -ISOLATION_LEVEL_CONFIG: Incomplete - class ConsumerRecord(NamedTuple): topic: str partition: int @@ -35,21 +30,23 @@ class ExceptionMetadata(NamedTuple): fetched_offset: Incomplete exception: Incomplete -class NoOffsetForPartitionError(Errors.KafkaError): ... class RecordTooLargeError(Errors.KafkaError): ... class Fetcher: - DEFAULT_CONFIG: Incomplete - config: Incomplete + DEFAULT_CONFIG: dict[str, Incomplete] + config: dict[str, Incomplete] def __init__(self, client, subscriptions, **configs) -> None: ... + def fetch_records(self, max_records: int | None = None, update_offsets: bool = True, timeout_ms=None): ... def send_fetches(self): ... - def in_flight_fetches(self): ... - def reset_offsets_if_needed(self): ... + def in_flight_fetches(self) -> bool: ... + def reset_offsets_if_needed(self, timeout_ms=None): ... def offsets_by_times(self, timestamps, timeout_ms=None): ... - def beginning_offsets(self, partitions, timeout_ms): ... - def end_offsets(self, partitions, timeout_ms): ... - def beginning_or_end_offset(self, partitions, timestamp, timeout_ms): ... - def fetched_records(self, max_records=None, update_offsets: bool = True): ... + def beginning_offsets(self, partitions, timeout_ms=None): ... + def end_offsets(self, partitions, timeout_ms=None): ... + def beginning_or_end_offset(self, partitions, timestamp, timeout_ms=None): ... + def fetched_records(self, max_records: int | None = None, update_offsets: bool = True): ... + def maybe_validate_positions(self) -> None: ... + def validate_offsets_if_needed(self, timeout_ms=None): ... def close(self) -> None: ... class PartitionRecords: @@ -74,15 +71,14 @@ class Fetcher: key_deserializer=None, value_deserializer=None, check_crcs: bool = True, - isolation_level=0, + isolation_level=..., aborted_transactions=None, metric_aggregator=None, on_drain=..., ) -> None: ... def __bool__(self) -> bool: ... - __nonzero__ = __bool__ def drain(self) -> None: ... - def take(self, n=None): ... + def take(self, n=None) -> list[Incomplete]: ... class FetchSessionHandler: node_id: Incomplete @@ -94,6 +90,7 @@ class FetchSessionHandler: def handle_error(self, _exception) -> None: ... class FetchMetadata: + __slots__ = ("session_id", "epoch") MAX_EPOCH: int INVALID_SESSION_ID: int THROTTLED_SESSION_ID: int @@ -114,6 +111,7 @@ class FetchMetadata: def next_incremental(self): ... class FetchRequestData: + __slots__ = ("_to_send", "_to_forget", "_metadata") def __init__(self, to_send, to_forget, metadata) -> None: ... @property def metadata(self): ... @@ -127,6 +125,7 @@ class FetchRequestData: def to_forget(self): ... class FetchMetrics: + __slots__ = ("total_bytes", "total_records") total_bytes: int total_records: int def __init__(self) -> None: ... diff --git a/stubs/kafka-python/kafka/consumer/group.pyi b/stubs/kafka-python/kafka/consumer/group.pyi index e18e3cf3dc33..e92809f99202 100644 --- a/stubs/kafka-python/kafka/consumer/group.pyi +++ b/stubs/kafka-python/kafka/consumer/group.pyi @@ -2,8 +2,9 @@ import selectors import ssl from _typeshed import Incomplete from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence -from typing import Literal, TypeAlias, TypedDict, overload, type_check_only -from typing_extensions import Self, Unpack +from types import TracebackType +from typing import Final, Literal, TypeAlias, overload +from typing_extensions import Self from kafka.consumer.fetcher import ConsumerRecord from kafka.consumer.subscription_state import ConsumerRebalanceListener @@ -11,118 +12,118 @@ from kafka.future import Future from kafka.serializer.abstract import Deserializer from kafka.structs import OffsetAndMetadata, OffsetAndTimestamp, TopicPartition -_ApiVersion: TypeAlias = tuple[int, ...] -_BootstrapServers: TypeAlias = str | Sequence[str] _CommitCallback: TypeAlias = Callable[[Mapping[TopicPartition, OffsetAndMetadata], object], object] _ConsumerDeserializer: TypeAlias = Deserializer | Callable[[bytes | None], object] -_KafkaClientFactory: TypeAlias = Callable[..., object] -_SaslMechanism: TypeAlias = Literal["PLAIN", "GSSAPI", "OAUTHBEARER", "SCRAM-SHA-256", "SCRAM-SHA-512"] -_SecurityProtocol: TypeAlias = Literal["PLAINTEXT", "SSL", "SASL_PLAINTEXT", "SASL_SSL"] -_SocketOption: TypeAlias = tuple[int, int, int] - -@type_check_only -class _KafkaConsumerConfig(TypedDict, total=False): - bootstrap_servers: _BootstrapServers - client_id: str - group_id: str | None - group_instance_id: str | None - key_deserializer: _ConsumerDeserializer | None - value_deserializer: _ConsumerDeserializer | None - enable_incremental_fetch_sessions: bool - fetch_max_wait_ms: int - fetch_min_bytes: int - fetch_max_bytes: int - max_partition_fetch_bytes: int - request_timeout_ms: int - retry_backoff_ms: int - reconnect_backoff_ms: int - reconnect_backoff_max_ms: int - max_in_flight_requests_per_connection: int - auto_offset_reset: Literal["earliest", "latest", "smallest", "largest"] - enable_auto_commit: bool - auto_commit_interval_ms: int - default_offset_commit_callback: _CommitCallback - check_crcs: bool - isolation_level: Literal["read_uncommitted", "read_committed"] - allow_auto_create_topics: bool - metadata_max_age_ms: int - partition_assignment_strategy: Sequence[type[object]] - max_poll_records: int - max_poll_interval_ms: int - session_timeout_ms: int - heartbeat_interval_ms: int - receive_buffer_bytes: int | None - send_buffer_bytes: int | None - socket_options: Sequence[_SocketOption] - sock_chunk_bytes: int - sock_chunk_buffer_count: int - consumer_timeout_ms: int | float - security_protocol: _SecurityProtocol - ssl_context: ssl.SSLContext | None - ssl_check_hostname: bool - ssl_cafile: str | None - ssl_certfile: str | None - ssl_keyfile: str | None - ssl_crlfile: str | None - ssl_password: str | None - ssl_ciphers: str | None - api_version: _ApiVersion | None - api_version_auto_timeout_ms: int - connections_max_idle_ms: int - metric_reporters: Sequence[type[object]] - metrics_enabled: bool - metrics_num_samples: int - metrics_sample_window_ms: int - metric_group_prefix: str - selector: type[selectors.BaseSelector] - exclude_internal_topics: bool - sasl_mechanism: _SaslMechanism | None - sasl_plain_username: str | None - sasl_plain_password: str | None - sasl_kerberos_name: object | None - sasl_kerberos_service_name: str - sasl_kerberos_domain_name: str | None - sasl_oauth_token_provider: object | None - socks5_proxy: str | None - kafka_client: _KafkaClientFactory - -log: Incomplete class KafkaConsumer(Iterator[ConsumerRecord]): - DEFAULT_CONFIG: Incomplete - DEFAULT_SESSION_TIMEOUT_MS_0_9: int - config: Incomplete - def __init__(self, *topics: str, **configs: Unpack[_KafkaConsumerConfig]) -> None: ... + DEFAULT_CONFIG: dict[str, Incomplete] + DEFAULT_SESSION_TIMEOUT_MS_PRE_KIP_735: Final = 30000 + config: dict[str, Incomplete] + def __init__( + self, + *topics: str, + bootstrap_servers: str | Sequence[str] = "localhost", + client_id: str = ..., + client_rack: str = "", + group_id: str | None = None, + group_instance_id: str | None = None, + key_deserializer: _ConsumerDeserializer | None = None, + value_deserializer: _ConsumerDeserializer | None = None, + enable_incremental_fetch_sessions: bool = True, + fetch_max_wait_ms: int = 500, + fetch_min_bytes: int = 1, + fetch_max_bytes: int = 52_428_800, + max_partition_fetch_bytes: int = 1_048_576, + request_timeout_ms: int = 30_000, + retry_backoff_ms: int = 100, + reconnect_backoff_ms: int = 50, + reconnect_backoff_max_ms: int = 30000, + max_in_flight_requests_per_connection: int = 5, + auto_offset_reset: Literal["earliest", "latest", "smallest", "largest"] = "latest", + enable_auto_commit: bool = True, + auto_commit_interval_ms: int = 5000, + default_offset_commit_callback: _CommitCallback = ..., + check_crcs: bool = True, + isolation_level: Literal["read_uncommitted", "read_committed"] = "read_uncommitted", + allow_auto_create_topics: bool = True, + metadata_max_age_ms: int = 300000, + client_dns_lookup: str = "use_all_dns_ips", + partition_assignment_strategy: Sequence[type[object]] = ..., + max_poll_records: int = 500, + max_poll_interval_ms: int = 300000, + session_timeout_ms: int = 45000, + heartbeat_interval_ms: int = 3000, + receive_buffer_bytes: int | None = None, + send_buffer_bytes: int | None = None, + receive_message_max_bytes: int = 100_000_000, + socket_options: Sequence[tuple[int, int, int]] = ..., + consumer_timeout_ms: int | float = ..., + security_protocol: Literal["PLAINTEXT", "SSL", "SASL_PLAINTEXT", "SASL_SSL"] = "PLAINTEXT", + ssl_context: ssl.SSLContext | None = None, + ssl_check_hostname: bool = True, + ssl_cafile: str | None = None, + ssl_certfile: str | None = None, + ssl_keyfile: str | None = None, + ssl_crlfile: str | None = None, + ssl_password: str | None = None, + ssl_ciphers: str | None = None, + api_version: tuple[int, ...] | None = None, + bootstrap_timeout_ms: int = 30000, + connections_max_idle_ms: int = 540000, + metric_reporters: Sequence[type[object]] = [], + metrics_enabled: bool = True, + metrics_num_samples: int = 2, + metrics_sample_window_ms: int = 30000, + metric_group_prefix: str = "consumer", + selector: type[selectors.BaseSelector] = selectors.DefaultSelector, + exclude_internal_topics: bool = True, + sasl_mechanism: Literal["PLAIN", "GSSAPI", "OAUTHBEARER", "SCRAM-SHA-256", "SCRAM-SHA-512"] | None = None, + sasl_plain_username: str | None = None, + sasl_plain_password: str | None = None, + sasl_kerberos_name: object | None = None, + sasl_kerberos_service_name: str = "kafka", + sasl_kerberos_domain_name: str | None = None, + sasl_oauth_token_provider: object | None = None, + proxy_url: str | None = None, + socks5_proxy: str | None = None, + kafka_client: Callable[..., object] = ..., + ) -> None: ... def bootstrap_connected(self): ... + def bootstrap(self, timeout_ms: float | None = None, refresh: bool = False) -> None: ... def assign(self, partitions: Iterable[TopicPartition]) -> None: ... def assignment(self) -> set[TopicPartition]: ... - def close(self, autocommit: bool = True, timeout_ms: int | None = None) -> None: ... + def __enter__(self) -> Self: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> None: ... + def close(self, autocommit: bool = True, timeout_ms: float | None = None) -> None: ... def commit_async( self, offsets: Mapping[TopicPartition, OffsetAndMetadata] | None = None, callback: _CommitCallback | None = None ) -> Future: ... def commit( - self, offsets: Mapping[TopicPartition, OffsetAndMetadata] | None = None, timeout_ms: int | None = None + self, offsets: Mapping[TopicPartition, OffsetAndMetadata] | None = None, timeout_ms: float | None = None ) -> None: ... + def group_metadata(self): ... @overload def committed( - self, partition: TopicPartition, metadata: Literal[False] = False, timeout_ms: int | None = None + self, partition: TopicPartition, metadata: Literal[False] = False, timeout_ms: float | None = None ) -> int | None: ... @overload def committed( - self, partition: TopicPartition, metadata: Literal[True], timeout_ms: int | None = None + self, partition: TopicPartition, metadata: Literal[True], timeout_ms: float | None = None ) -> OffsetAndMetadata | None: ... @overload def committed( - self, partition: TopicPartition, metadata: bool, timeout_ms: int | None = None + self, partition: TopicPartition, metadata: bool, timeout_ms: float | None = None ) -> int | OffsetAndMetadata | None: ... def topics(self) -> set[str]: ... def partitions_for_topic(self, topic: str) -> set[int]: ... def poll( - self, timeout_ms: int = 0, max_records: int | None = None, update_offsets: bool = True + self, timeout_ms: float = 0, max_records: int | None = None, update_offsets: bool = True ) -> dict[TopicPartition, list[ConsumerRecord]]: ... - def position(self, partition: TopicPartition, timeout_ms: int | None = None) -> int | None: ... + def position(self, partition: TopicPartition, timeout_ms: float | None = None) -> int | None: ... def highwater(self, partition: TopicPartition) -> int | None: ... def pause(self, *partitions: TopicPartition) -> None: ... def paused(self) -> set[TopicPartition]: ... @@ -136,8 +137,12 @@ class KafkaConsumer(Iterator[ConsumerRecord]): def subscription(self) -> set[str]: ... def unsubscribe(self) -> None: ... def metrics(self, raw: bool = False) -> dict[str, dict[str, object]] | dict[object, object] | None: ... - def offsets_for_times(self, timestamps: Mapping[TopicPartition, int]) -> dict[TopicPartition, OffsetAndTimestamp | None]: ... - def beginning_offsets(self, partitions: Iterable[TopicPartition]) -> dict[TopicPartition, int]: ... - def end_offsets(self, partitions: Iterable[TopicPartition]) -> dict[TopicPartition, int]: ... + def offsets_for_times( + self, timestamps: Mapping[TopicPartition, int], timeout_ms: float | None = None + ) -> dict[TopicPartition, OffsetAndTimestamp | None]: ... + def beginning_offsets( + self, partitions: Iterable[TopicPartition], timeout_ms: float | None = None + ) -> dict[TopicPartition, int]: ... + def end_offsets(self, partitions: Iterable[TopicPartition], timeout_ms: float | None = None) -> dict[TopicPartition, int]: ... def __iter__(self) -> Self: ... def __next__(self) -> ConsumerRecord: ... diff --git a/stubs/kafka-python/kafka/consumer/subscription_state.pyi b/stubs/kafka-python/kafka/consumer/subscription_state.pyi index e085b78873cf..c72410406b58 100644 --- a/stubs/kafka-python/kafka/consumer/subscription_state.pyi +++ b/stubs/kafka-python/kafka/consumer/subscription_state.pyi @@ -2,10 +2,9 @@ import abc from _typeshed import Incomplete from enum import IntEnum +from kafka.structs import OffsetAndMetadata from kafka.util import synchronized -log: Incomplete - class SubscriptionType(IntEnum): NONE = 0 AUTO_TOPICS = 1 @@ -67,16 +66,36 @@ class SubscriptionState: @synchronized def partitions_needing_reset(self): ... @synchronized - def is_assigned(self, partition): ... + def next_offset_reset_retry_time(self): ... + @synchronized + def maybe_validate_position_for_current_leader(self, partition, current_leader_epoch) -> bool: ... + @synchronized + def request_position_validation(self, partition) -> bool: ... + @synchronized + def partitions_needing_validation(self) -> set[Incomplete]: ... + @synchronized + def next_offset_validation_retry_time(self): ... + @synchronized + def set_validation_pending(self, partitions, next_allowed_retry_time) -> None: ... + @synchronized + def validation_failed(self, partitions, next_allowed_retry_time) -> None: ... + @synchronized + def complete_validation(self, partition, validated_position=None) -> None: ... + @synchronized + def is_offset_validation_needed(self, partition) -> bool: ... + @synchronized + def is_assigned(self, partition) -> bool: ... @synchronized def is_paused(self, partition): ... @synchronized - def is_fetchable(self, partition): ... + def is_fetchable(self, partition) -> bool: ... @synchronized def pause(self, partition) -> None: ... @synchronized def resume(self, partition) -> None: ... @synchronized + def mark_pending_revocation(self, partitions) -> None: ... + @synchronized def reset_failed(self, partitions, next_retry_time) -> None: ... @synchronized def move_partition_to_end(self, partition) -> None: ... @@ -90,23 +109,48 @@ class TopicPartitionState: drop_pending_record_batch: bool next_allowed_retry_time: Incomplete def __init__(self) -> None: ... - position: Incomplete + + @property + def position(self) -> OffsetAndMetadata | None: ... + @position.setter + def position(self, offset: OffsetAndMetadata) -> None: ... + def reset(self, strategy) -> None: ... - def is_reset_allowed(self): ... + def is_reset_allowed(self) -> bool: ... @property - def awaiting_reset(self): ... + def awaiting_reset(self) -> bool: ... def set_reset_pending(self, next_allowed_retry_time) -> None: ... def reset_failed(self, next_allowed_retry_time) -> None: ... @property - def has_valid_position(self): ... - def is_missing_position(self): ... + def has_valid_position(self) -> bool: ... + def is_missing_position(self) -> bool: ... def seek(self, offset) -> None: ... def pause(self) -> None: ... def resume(self) -> None: ... - def is_fetchable(self): ... + def mark_pending_revocation(self, val: bool = True) -> None: ... + def is_fetchable(self) -> bool: ... + def preferred_read_replica(self): ... + def update_preferred_read_replica(self, node_id, expiration_time) -> bool: ... + def clear_preferred_read_replica(self): ... + @property + def awaiting_validation(self) -> bool: ... + def maybe_validate_position(self, current_leader_epoch) -> bool: ... + def request_position_validation(self) -> bool: ... + def is_validation_allowed(self) -> bool: ... + def set_validation_pending(self, next_allowed_retry_time) -> None: ... + def validation_failed(self, next_allowed_retry_time) -> None: ... + def complete_validation(self, validated_position=None) -> None: ... class ConsumerRebalanceListener(metaclass=abc.ABCMeta): @abc.abstractmethod def on_partitions_revoked(self, revoked): ... @abc.abstractmethod def on_partitions_assigned(self, assigned): ... + def on_partitions_lost(self, lost): ... + +class AsyncConsumerRebalanceListener(metaclass=abc.ABCMeta): + @abc.abstractmethod + async def on_partitions_revoked(self, revoked): ... + @abc.abstractmethod + async def on_partitions_assigned(self, assigned): ... + async def on_partitions_lost(self, lost): ... diff --git a/stubs/kafka-python/kafka/coordinator/assignors/abstract.pyi b/stubs/kafka-python/kafka/coordinator/assignors/abstract.pyi index 898c5dc4d676..c7240602d27f 100644 --- a/stubs/kafka-python/kafka/coordinator/assignors/abstract.pyi +++ b/stubs/kafka-python/kafka/coordinator/assignors/abstract.pyi @@ -1,15 +1,18 @@ import abc -from _typeshed import Incomplete +from enum import IntEnum -log: Incomplete +class RebalanceProtocol(IntEnum): + EAGER = 0 + COOPERATIVE = 1 class AbstractPartitionAssignor(metaclass=abc.ABCMeta): @property @abc.abstractmethod def name(self): ... + def supported_protocols(self) -> list[RebalanceProtocol]: ... @abc.abstractmethod def assign(self, cluster, members): ... @abc.abstractmethod def metadata(self, topics): ... @abc.abstractmethod - def on_assignment(self, assignment): ... + def on_assignment(self, assignment, generation): ... diff --git a/stubs/kafka-python/kafka/coordinator/assignors/cooperative_sticky.pyi b/stubs/kafka-python/kafka/coordinator/assignors/cooperative_sticky.pyi new file mode 100644 index 000000000000..90a108a19604 --- /dev/null +++ b/stubs/kafka-python/kafka/coordinator/assignors/cooperative_sticky.pyi @@ -0,0 +1,14 @@ +from _typeshed import Incomplete + +from kafka.coordinator.assignors.abstract import RebalanceProtocol +from kafka.coordinator.assignors.sticky.sticky_assignor import StickyAssignorMemberMetadataV1, StickyPartitionAssignor +from kafka.protocol.consumer.metadata import ConsumerProtocolAssignment, ConsumerProtocolSubscription + +class CooperativeStickyAssignor(StickyPartitionAssignor): + name: str + version: int + def supported_protocols(self) -> list[RebalanceProtocol]: ... + def metadata(self, topics) -> ConsumerProtocolSubscription: ... + @classmethod + def parse_member_metadata(cls, metadata) -> StickyAssignorMemberMetadataV1: ... + def assign(self, cluster, members) -> dict[Incomplete, ConsumerProtocolAssignment]: ... diff --git a/stubs/kafka-python/kafka/coordinator/assignors/range.pyi b/stubs/kafka-python/kafka/coordinator/assignors/range.pyi index 667d52af7efd..aad327525b18 100644 --- a/stubs/kafka-python/kafka/coordinator/assignors/range.pyi +++ b/stubs/kafka-python/kafka/coordinator/assignors/range.pyi @@ -1,15 +1,12 @@ -from _typeshed import Incomplete - from kafka.coordinator.assignors.abstract import AbstractPartitionAssignor - -log: Incomplete +from kafka.protocol.consumer.metadata import ConsumerProtocolSubscription class RangePartitionAssignor(AbstractPartitionAssignor): name: str version: int @classmethod - def assign(cls, cluster, group_subscriptions): ... + def assign(cls, cluster, members): ... @classmethod - def metadata(cls, topics): ... + def metadata(cls, topics) -> ConsumerProtocolSubscription: ... @classmethod - def on_assignment(cls, assignment) -> None: ... + def on_assignment(cls, assignment, generation) -> None: ... diff --git a/stubs/kafka-python/kafka/coordinator/assignors/roundrobin.pyi b/stubs/kafka-python/kafka/coordinator/assignors/roundrobin.pyi index b876b9cec002..f09cc9f47677 100644 --- a/stubs/kafka-python/kafka/coordinator/assignors/roundrobin.pyi +++ b/stubs/kafka-python/kafka/coordinator/assignors/roundrobin.pyi @@ -1,15 +1,12 @@ -from _typeshed import Incomplete - from kafka.coordinator.assignors.abstract import AbstractPartitionAssignor - -log: Incomplete +from kafka.protocol.consumer.metadata import ConsumerProtocolSubscription class RoundRobinPartitionAssignor(AbstractPartitionAssignor): name: str version: int @classmethod - def assign(cls, cluster, group_subscriptions): ... + def assign(cls, cluster, members): ... @classmethod - def metadata(cls, topics): ... + def metadata(cls, topics) -> ConsumerProtocolSubscription: ... @classmethod - def on_assignment(cls, assignment) -> None: ... + def on_assignment(cls, assignment, generation) -> None: ... diff --git a/stubs/kafka-python/kafka/coordinator/assignors/sticky/partition_movements.pyi b/stubs/kafka-python/kafka/coordinator/assignors/sticky/partition_movements.pyi index 1b3620d3623c..ff8e506ab9a0 100644 --- a/stubs/kafka-python/kafka/coordinator/assignors/sticky/partition_movements.pyi +++ b/stubs/kafka-python/kafka/coordinator/assignors/sticky/partition_movements.pyi @@ -1,8 +1,6 @@ from _typeshed import Incomplete from typing import NamedTuple -log: Incomplete - class ConsumerPair(NamedTuple): src_member_id: Incomplete dst_member_id: Incomplete diff --git a/stubs/kafka-python/kafka/coordinator/assignors/sticky/sticky_assignor.pyi b/stubs/kafka-python/kafka/coordinator/assignors/sticky/sticky_assignor.pyi index ad40223ebbfd..225f3a05d47f 100644 --- a/stubs/kafka-python/kafka/coordinator/assignors/sticky/sticky_assignor.pyi +++ b/stubs/kafka-python/kafka/coordinator/assignors/sticky/sticky_assignor.pyi @@ -1,10 +1,8 @@ from _typeshed import Incomplete -from typing import NamedTuple +from typing import Final, NamedTuple from kafka.coordinator.assignors.abstract import AbstractPartitionAssignor -from kafka.protocol.struct import Struct - -log: Incomplete +from kafka.protocol.consumer.metadata import ConsumerProtocolAssignment, ConsumerProtocolSubscription class ConsumerGenerationPair(NamedTuple): consumer: Incomplete @@ -20,9 +18,6 @@ class StickyAssignorMemberMetadataV1(NamedTuple): partitions: Incomplete generation: Incomplete -class StickyAssignorUserDataV1(Struct): - SCHEMA: Incomplete - class StickyAssignmentExecutor: members: Incomplete current_assignment: Incomplete @@ -42,18 +37,14 @@ class StickyAssignmentExecutor: def get_final_assignment(self, member_id): ... class StickyPartitionAssignor(AbstractPartitionAssignor): - DEFAULT_GENERATION_ID: int + DEFAULT_GENERATION_ID: Final = -1 name: str version: int - member_assignment: Incomplete - generation = DEFAULT_GENERATION_ID # pyrefly: ignore [unknown-name] - @classmethod - def assign(cls, cluster, members): ... - @classmethod - def parse_member_metadata(cls, metadata): ... - @classmethod - def metadata(cls, topics): ... - @classmethod - def on_assignment(cls, assignment) -> None: ... + member_assignment: Incomplete | None + generation: int + def __init__(self) -> None: ... + def assign(self, cluster, members) -> dict[Incomplete, ConsumerProtocolAssignment]: ... @classmethod - def on_generation_assignment(cls, generation) -> None: ... + def parse_member_metadata(cls, metadata) -> StickyAssignorMemberMetadataV1: ... + def metadata(self, topics) -> ConsumerProtocolSubscription: ... + def on_assignment(self, assignment, generation) -> None: ... diff --git a/stubs/kafka-python/kafka/coordinator/assignors/sticky/user_data.pyi b/stubs/kafka-python/kafka/coordinator/assignors/sticky/user_data.pyi new file mode 100644 index 000000000000..041f58055293 --- /dev/null +++ b/stubs/kafka-python/kafka/coordinator/assignors/sticky/user_data.pyi @@ -0,0 +1,6 @@ +from kafka.protocol.api_data import ApiData + +class StickyAssignorUserData(ApiData): + def __init__(self, *args, **kw) -> None: ... + # TODO: Reflect TopicPartition, generation, previous_assignment attributes + def __getattr__(self, name: str): ... # incomplete class diff --git a/stubs/kafka-python/kafka/coordinator/base.pyi b/stubs/kafka-python/kafka/coordinator/base.pyi index ae911d976734..7290b0084190 100644 --- a/stubs/kafka-python/kafka/coordinator/base.pyi +++ b/stubs/kafka-python/kafka/coordinator/base.pyi @@ -1,17 +1,10 @@ import abc -import threading from _typeshed import Incomplete -from typing import ClassVar +from typing import ClassVar, Final +from typing_extensions import deprecated from kafka import errors as Errors - -log: Incomplete -heartbeat_log: Incomplete - -class MemberState: - UNJOINED: str - REBALANCING: str - STABLE: str +from kafka.structs import ConsumerGroupMetadata class Generation: NO_GENERATION: ClassVar[Generation] @@ -19,11 +12,11 @@ class Generation: member_id: Incomplete protocol: Incomplete def __init__(self, generation_id, member_id, protocol) -> None: ... - def has_member_id(self): ... - def __eq__(self, other): ... + def has_member_id(self) -> bool: ... + def is_lost(self) -> bool: ... + def __eq__(self, other) -> bool: ... -class UnjoinedGroupException(Errors.KafkaError): - retriable: bool +class UnjoinedGroupException(Errors.KafkaError): ... class BaseCoordinator(metaclass=abc.ABCMeta): DEFAULT_CONFIG: Incomplete @@ -32,8 +25,8 @@ class BaseCoordinator(metaclass=abc.ABCMeta): rejoin_needed: bool rejoining: bool state: Incomplete - join_future: Incomplete coordinator_id: Incomplete + DEFAULT_SESSION_TIMEOUT_MS_PRE_KIP_735: Final = 30000 def __init__(self, client, **configs) -> None: ... @property def group_id(self): ... @@ -45,24 +38,28 @@ class BaseCoordinator(metaclass=abc.ABCMeta): def group_protocols(self): ... def coordinator_unknown(self): ... def coordinator(self): ... - def connected(self): ... - def ensure_coordinator_ready(self, timeout_ms=None): ... + def stable(self) -> bool: ... + def ensure_coordinator_ready(self, timeout_ms=None) -> bool: ... + async def ensure_coordinator_ready_async(self, timeout_ms=None) -> bool: ... def lookup_coordinator(self): ... def need_rejoin(self): ... def poll_heartbeat(self) -> None: ... def time_to_next_heartbeat(self): ... - def ensure_active_group(self, timeout_ms=None): ... - def join_group(self, timeout_ms=None): ... + def ensure_active_group(self, timeout_ms=None) -> bool: ... + async def ensure_active_group_async(self, timeout_ms=None) -> bool: ... + async def join_group_async(self, timeout_ms=None) -> bool: ... def coordinator_dead(self, error) -> None: ... def generation_if_stable(self): ... + def group_metadata(self) -> ConsumerGroupMetadata: ... + @deprecated("Deprecated. Use `coordinator.generation_if_stable()` instead.") def generation(self): ... def rebalance_in_progress(self): ... def reset_generation(self, member_id="") -> None: ... def request_rejoin(self) -> None: ... - def __del__(self) -> None: ... def close(self, timeout_ms=None) -> None: ... def is_dynamic_member(self): ... - def maybe_leave_group(self, timeout_ms=None) -> None: ... + def maybe_leave_group(self, reason=None, timeout_ms=None) -> None: ... + async def maybe_leave_group_async(self, reason=None, timeout_ms=None) -> None: ... class GroupCoordinatorMetrics: heartbeat: Incomplete @@ -72,15 +69,3 @@ class GroupCoordinatorMetrics: join_latency: Incomplete sync_latency: Incomplete def __init__(self, heartbeat, metrics, prefix, tags=None) -> None: ... - -class HeartbeatThread(threading.Thread): - name: Incomplete - coordinator: Incomplete - enabled: bool - closed: bool - failed: Incomplete - def __init__(self, coordinator) -> None: ... - def enable(self) -> None: ... - def disable(self) -> None: ... - def close(self, timeout_ms=None) -> None: ... - def run(self) -> None: ... diff --git a/stubs/kafka-python/kafka/coordinator/consumer.pyi b/stubs/kafka-python/kafka/coordinator/consumer.pyi index 159cbc4a2916..afb7537724b3 100644 --- a/stubs/kafka-python/kafka/coordinator/consumer.pyi +++ b/stubs/kafka-python/kafka/coordinator/consumer.pyi @@ -2,23 +2,22 @@ from _typeshed import Incomplete from kafka.coordinator.base import BaseCoordinator -log: Incomplete - class ConsumerCoordinator(BaseCoordinator): - DEFAULT_CONFIG: Incomplete - config: Incomplete + DEFAULT_CONFIG: dict[str, Incomplete] + config: dict[str, Incomplete] auto_commit_interval: Incomplete next_auto_commit_deadline: Incomplete completed_offset_commits: Incomplete def __init__(self, client, subscription, **configs) -> None: ... - def __del__(self) -> None: ... - def protocol_type(self): ... - def group_protocols(self): ... - def poll(self, timeout_ms=None): ... + def protocol_type(self) -> str: ... + def group_protocols(self) -> list[tuple[Incomplete, Incomplete]]: ... + def poll(self, timeout_ms=None) -> bool: ... def time_to_next_poll(self): ... - def need_rejoin(self): ... + def need_rejoin(self) -> bool: ... def refresh_committed_offsets_if_needed(self, timeout_ms=None): ... + async def refresh_committed_offsets_if_needed_async(self, timeout_ms=None) -> bool: ... def fetch_committed_offsets(self, partitions, timeout_ms=None): ... + async def fetch_committed_offsets_async(self, partitions, timeout_ms=None): ... def close(self, autocommit: bool = True, timeout_ms=None) -> None: ... # type: ignore[override] def commit_offsets_async(self, offsets, callback=None): ... def commit_offsets_sync(self, offsets, timeout_ms=None): ... diff --git a/stubs/kafka-python/kafka/coordinator/heartbeat.pyi b/stubs/kafka-python/kafka/coordinator/heartbeat.pyi index 2fb958a5c868..87bb2db6ff5d 100644 --- a/stubs/kafka-python/kafka/coordinator/heartbeat.pyi +++ b/stubs/kafka-python/kafka/coordinator/heartbeat.pyi @@ -1,15 +1,13 @@ from _typeshed import Incomplete -log: Incomplete - class Heartbeat: - DEFAULT_CONFIG: Incomplete - config: Incomplete - last_send: Incomplete - last_receive: Incomplete - last_poll: Incomplete - last_reset: Incomplete - heartbeat_failed: Incomplete + DEFAULT_CONFIG: dict[str, Incomplete] + config: dict[str, Incomplete] + last_send: float + last_receive: float + last_poll: float + last_reset: float + heartbeat_failed: bool | None def __init__(self, **configs) -> None: ... def poll(self) -> None: ... def sent_heartbeat(self) -> None: ... diff --git a/stubs/kafka-python/kafka/coordinator/subscription.pyi b/stubs/kafka-python/kafka/coordinator/subscription.pyi index b04a77efda82..8fc9b3fdb31d 100644 --- a/stubs/kafka-python/kafka/coordinator/subscription.pyi +++ b/stubs/kafka-python/kafka/coordinator/subscription.pyi @@ -1,4 +1,5 @@ class Subscription: + __slots__ = ("_metadata", "_group_instance_id") def __init__(self, metadata, group_instance_id) -> None: ... @property def version(self): ... diff --git a/stubs/kafka-python/kafka/errors.pyi b/stubs/kafka-python/kafka/errors.pyi index 079bf3ebd5e4..9d5f0604eda8 100644 --- a/stubs/kafka-python/kafka/errors.pyi +++ b/stubs/kafka-python/kafka/errors.pyi @@ -1,60 +1,46 @@ from _typeshed import Incomplete -class KafkaError(RuntimeError): +class KafkaError(Exception): retriable: bool invalid_metadata: bool def __eq__(self, other): ... -class Cancelled(KafkaError): +class RetriableError(KafkaError): retriable: bool +class InvalidMetadataError(RetriableError): + invalid_metadata: bool + +class Cancelled(RetriableError): ... + class CommitFailedError(KafkaError): def __init__(self, *args) -> None: ... class IllegalArgumentError(KafkaError): ... class IllegalStateError(KafkaError): ... -class IncompatibleBrokerVersion(KafkaError): ... class KafkaConfigurationError(KafkaError): ... - -class KafkaConnectionError(KafkaError): - retriable: bool - invalid_metadata: bool - -class KafkaProtocolError(KafkaError): - retriable: bool - -class CorrelationIdError(KafkaProtocolError): - retriable: bool - +class KafkaConnectionError(InvalidMetadataError): ... +class KafkaProtocolError(KafkaError): ... +class CorrelationIdError(RetriableError, KafkaProtocolError): ... class InvalidReceiveError(KafkaProtocolError): ... - -class KafkaTimeoutError(KafkaError): - retriable: bool - -class MetadataEmptyBrokerList(KafkaError): - retriable: bool - -class NoBrokersAvailable(KafkaError): - retriable: bool - invalid_metadata: bool - +class KafkaTimeoutError(KafkaError): ... +class MetadataEmptyBrokerList(KafkaError): ... class NoOffsetForPartitionError(KafkaError): ... -class NodeNotReadyError(KafkaError): - retriable: bool +class LogTruncationError(KafkaError): + divergent_offsets: Incomplete + def __init__(self, divergent_offsets, *args): ... +class NodeNotReadyError(RetriableError): ... +class UnknownBrokerIdError(KafkaError): ... class QuotaViolationError(KafkaError): ... - -class StaleMetadata(KafkaError): - retriable: bool - invalid_metadata: bool - -class TooManyInFlightRequests(KafkaError): - retriable: bool - +class StaleMetadata(InvalidMetadataError): ... +class TooManyInFlightRequests(RetriableError): ... class UnrecognizedBrokerVersion(KafkaError): ... class UnsupportedCodecError(KafkaError): ... -class TransactionAbortedError(KafkaError): ... + +class TransactionAbortedError(KafkaError): + message: str class BrokerResponseError(KafkaError): errno: Incomplete @@ -85,49 +71,40 @@ class CorruptRecordError(BrokerResponseError): CorruptRecordException = CorruptRecordError -class UnknownTopicOrPartitionError(BrokerResponseError): +class UnknownTopicOrPartitionError(InvalidMetadataError, BrokerResponseError): errno: int message: str description: str - retriable: bool - invalid_metadata: bool class InvalidFetchRequestError(BrokerResponseError): errno: int message: str description: str -class LeaderNotAvailableError(BrokerResponseError): +class LeaderNotAvailableError(InvalidMetadataError, BrokerResponseError): errno: int message: str description: str - retriable: bool - invalid_metadata: bool -class NotLeaderForPartitionError(BrokerResponseError): +class NotLeaderForPartitionError(InvalidMetadataError, BrokerResponseError): errno: int message: str description: str - retriable: bool - invalid_metadata: bool -class RequestTimedOutError(BrokerResponseError): +class RequestTimedOutError(RetriableError, BrokerResponseError): errno: int message: str description: str - retriable: bool class BrokerNotAvailableError(BrokerResponseError): errno: int message: str description: str -class ReplicaNotAvailableError(BrokerResponseError): +class ReplicaNotAvailableError(InvalidMetadataError, BrokerResponseError): errno: int message: str description: str - retriable: bool - invalid_metadata: bool class MessageSizeTooLargeError(BrokerResponseError): errno: int @@ -144,29 +121,24 @@ class OffsetMetadataTooLargeError(BrokerResponseError): message: str description: str -class NetworkExceptionError(BrokerResponseError): +class NetworkExceptionError(InvalidMetadataError, BrokerResponseError): errno: int message: str - retriable: bool - invalid_metadata: bool -class CoordinatorLoadInProgressError(BrokerResponseError): +class CoordinatorLoadInProgressError(RetriableError, BrokerResponseError): errno: int message: str description: str - retriable: bool -class CoordinatorNotAvailableError(BrokerResponseError): +class CoordinatorNotAvailableError(RetriableError, BrokerResponseError): errno: int message: str description: str - retriable: bool -class NotCoordinatorError(BrokerResponseError): +class NotCoordinatorError(RetriableError, BrokerResponseError): errno: int message: str description: str - retriable: bool class InvalidTopicError(BrokerResponseError): errno: int @@ -178,17 +150,15 @@ class RecordListTooLargeError(BrokerResponseError): message: str description: str -class NotEnoughReplicasError(BrokerResponseError): +class NotEnoughReplicasError(RetriableError, BrokerResponseError): errno: int message: str description: str - retriable: bool -class NotEnoughReplicasAfterAppendError(BrokerResponseError): +class NotEnoughReplicasAfterAppendError(RetriableError, BrokerResponseError): errno: int message: str description: str - retriable: bool class InvalidRequiredAcksError(BrokerResponseError): errno: int @@ -265,6 +235,8 @@ class UnsupportedVersionError(BrokerResponseError): message: str description: str +class IncompatibleBrokerVersion(UnsupportedVersionError): ... + class TopicAlreadyExistsError(BrokerResponseError): errno: int message: str @@ -290,11 +262,10 @@ class InvalidConfigurationError(BrokerResponseError): message: str description: str -class NotControllerError(BrokerResponseError): +class NotControllerError(RetriableError, BrokerResponseError): errno: int message: str description: str - retriable: bool class InvalidRequestError(BrokerResponseError): errno: int @@ -310,514 +281,421 @@ class PolicyViolationError(BrokerResponseError): errno: int message: str description: str - retriable: bool class OutOfOrderSequenceNumberError(BrokerResponseError): errno: int message: str description: str - retriable: bool class DuplicateSequenceNumberError(BrokerResponseError): errno: int message: str description: str - retriable: bool class InvalidProducerEpochError(BrokerResponseError): errno: int message: str description: str - retriable: bool class InvalidTxnStateError(BrokerResponseError): errno: int message: str description: str - retriable: bool class InvalidProducerIdMappingError(BrokerResponseError): errno: int message: str description: str - retriable: bool class InvalidTransactionTimeoutError(BrokerResponseError): errno: int message: str description: str - retriable: bool -class ConcurrentTransactionsError(BrokerResponseError): +class ConcurrentTransactionsError(RetriableError, BrokerResponseError): errno: int message: str description: str - retriable: bool class TransactionCoordinatorFencedError(BrokerResponseError): errno: int message: str description: str - retriable: bool class TransactionalIdAuthorizationFailedError(AuthorizationError): errno: int message: str description: str - retriable: bool class SecurityDisabledError(BrokerResponseError): errno: int message: str description: str - retriable: bool class OperationNotAttemptedError(BrokerResponseError): errno: int message: str description: str - retriable: bool class KafkaStorageError(BrokerResponseError): errno: int message: str description: str - retriable: bool - invalid_metadata: bool class LogDirNotFoundError(BrokerResponseError): errno: int message: str description: str - retriable: bool class SaslAuthenticationFailedError(BrokerResponseError): errno: int message: str description: str - retriable: bool class UnknownProducerIdError(BrokerResponseError): errno: int message: str description: str - retriable: bool class ReassignmentInProgressError(BrokerResponseError): errno: int message: str description: str - retriable: bool class DelegationTokenAuthDisabledError(BrokerResponseError): errno: int message: str description: str - retriable: bool class DelegationTokenNotFoundError(BrokerResponseError): errno: int message: str description: str - retriable: bool class DelegationTokenOwnerMismatchError(BrokerResponseError): errno: int message: str description: str - retriable: bool class DelegationTokenRequestNotAllowedError(BrokerResponseError): errno: int message: str description: str - retriable: bool class DelegationTokenAuthorizationFailedError(AuthorizationError): errno: int message: str description: str - retriable: bool class DelegationTokenExpiredError(BrokerResponseError): errno: int message: str description: str - retriable: bool class InvalidPrincipalTypeError(BrokerResponseError): errno: int message: str description: str - retriable: bool class NonEmptyGroupError(BrokerResponseError): errno: int message: str description: str - retriable: bool class GroupIdNotFoundError(BrokerResponseError): errno: int message: str description: str - retriable: bool -class FetchSessionIdNotFoundError(BrokerResponseError): +class FetchSessionIdNotFoundError(RetriableError, BrokerResponseError): errno: int message: str description: str - retriable: bool -class InvalidFetchSessionEpochError(BrokerResponseError): +class InvalidFetchSessionEpochError(RetriableError, BrokerResponseError): errno: int message: str description: str - retriable: bool -class ListenerNotFoundError(BrokerResponseError): +class ListenerNotFoundError(InvalidMetadataError, BrokerResponseError): errno: int message: str description: str - retriable: bool - invalid_metadata: bool class TopicDeletionDisabledError(BrokerResponseError): errno: int message: str description: str - retriable: bool -class FencedLeaderEpochError(BrokerResponseError): +class FencedLeaderEpochError(InvalidMetadataError, BrokerResponseError): errno: int message: str description: str - retriable: bool - invalid_metadata: bool -class UnknownLeaderEpochError(BrokerResponseError): +class UnknownLeaderEpochError(InvalidMetadataError, BrokerResponseError): errno: int message: str description: str - retriable: bool - invalid_metadata: bool class UnsupportedCompressionTypeError(BrokerResponseError): errno: int message: str description: str - retriable: bool class StaleBrokerEpochError(BrokerResponseError): errno: int message: str description: str - retriable: bool -class OffsetNotAvailableError(BrokerResponseError): +class OffsetNotAvailableError(RetriableError, BrokerResponseError): errno: int message: str description: str - retriable: bool class MemberIdRequiredError(BrokerResponseError): errno: int message: str description: str - retriable: bool -class PreferredLeaderNotAvailableError(BrokerResponseError): +class PreferredLeaderNotAvailableError(InvalidMetadataError, BrokerResponseError): errno: int message: str description: str - retriable: bool - invalid_metadata: bool class GroupMaxSizeReachedError(BrokerResponseError): errno: int message: str description: str - retriable: bool class FencedInstanceIdError(BrokerResponseError): errno: int message: str description: str - retriable: bool -class EligibleLeadersNotAvailableError(BrokerResponseError): +class EligibleLeadersNotAvailableError(InvalidMetadataError, BrokerResponseError): errno: int message: str description: str - retriable: bool - invalid_metadata: bool -class ElectionNotNeededError(BrokerResponseError): +class ElectionNotNeededError(InvalidMetadataError, BrokerResponseError): errno: int message: str description: str - retriable: bool - invalid_metadata: bool class NoReassignmentInProgressError(BrokerResponseError): errno: int message: str description: str - retriable: bool class GroupSubscribedToTopicError(BrokerResponseError): errno: int message: str description: str - retriable: bool class InvalidRecordError(BrokerResponseError): errno: int message: str description: str - retriable: bool -class UnstableOffsetCommitError(BrokerResponseError): +class UnstableOffsetCommitError(RetriableError, BrokerResponseError): errno: int message: str description: str - retriable: bool -class ThrottlingQuotaExceededError(BrokerResponseError): +class ThrottlingQuotaExceededError(RetriableError, BrokerResponseError): errno: int message: str description: str - retriable: bool class ProducerFencedError(BrokerResponseError): errno: int message: str description: str - retriable: bool class ResourceNotFoundError(BrokerResponseError): errno: int message: str description: str - retriable: bool class DuplicateResourceError(BrokerResponseError): errno: int message: str description: str - retriable: bool class UnacceptableCredentialError(BrokerResponseError): errno: int message: str description: str - retriable: bool class InconsistentVoterSetError(BrokerResponseError): errno: int message: str description: str - retriable: bool class InvalidUpdateVersionError(BrokerResponseError): errno: int message: str description: str - retriable: bool class FeatureUpdateFailedError(BrokerResponseError): errno: int message: str description: str - retriable: bool class PrincipalDeserializationFailureError(BrokerResponseError): errno: int message: str description: str - retriable: bool class SnapshotNotFoundError(BrokerResponseError): errno: int message: str description: str - retriable: bool class PositionOutOfRangeError(BrokerResponseError): errno: int message: str description: str - retriable: bool -class UnknownTopicIdError(BrokerResponseError): +class UnknownTopicIdError(InvalidMetadataError, BrokerResponseError): errno: int message: str description: str - retriable: bool - invalid_metadata: bool class DuplicateBrokerRegistrationError(BrokerResponseError): errno: int message: str description: str - retriable: bool class BrokerIdNotRegisteredError(BrokerResponseError): errno: int message: str description: str - retriable: bool -class InconsistentTopicIdError(BrokerResponseError): +class InconsistentTopicIdError(InvalidMetadataError, BrokerResponseError): errno: int message: str description: str - retriable: bool - invalid_metadata: bool class InconsistentClusterIdError(BrokerResponseError): errno: int message: str description: str - retriable: bool class TransactionalIdNotFoundError(BrokerResponseError): errno: int message: str description: str - retriable: bool -class FetchSessionTopicIdError(BrokerResponseError): +class FetchSessionTopicIdError(RetriableError, BrokerResponseError): errno: int message: str description: str - retriable: bool class IneligibleReplicaError(BrokerResponseError): errno: int message: str description: str - retriable: bool class NewLeaderElectedError(BrokerResponseError): errno: int message: str description: str - retriable: bool class OffsetMovedToTieredStorageError(BrokerResponseError): errno: int message: str description: str - retriable: bool class FencedMemberEpochError(BrokerResponseError): errno: int message: str description: str - retriable: bool class UnreleasedInstanceIdError(BrokerResponseError): errno: int message: str description: str - retriable: bool class UnsupportedAssignorError(BrokerResponseError): errno: int message: str description: str - retriable: bool class StaleMemberEpochError(BrokerResponseError): errno: int message: str description: str - retriable: bool class MismatchedEndpointTypeError(BrokerResponseError): errno: int message: str description: str - retriable: bool class UnsupportedEndpointTypeError(BrokerResponseError): errno: int message: str description: str - retriable: bool class UnknownControllerIdError(BrokerResponseError): errno: int message: str description: str - retriable: bool class UnknownSubscriptionIdError(BrokerResponseError): errno: int message: str description: str - retriable: bool class TelemetryTooLargeError(BrokerResponseError): errno: int message: str description: str - retriable: bool class InvalidRegistrationError(BrokerResponseError): errno: int message: str description: str - retriable: bool class TransactionAbortableError(BrokerResponseError): errno: int message: str description: str - retriable: bool class InvalidRecordStateError(BrokerResponseError): errno: int message: str description: str - retriable: bool -class ShareSessionNotFoundError(BrokerResponseError): +class ShareSessionNotFoundError(RetriableError, BrokerResponseError): errno: int message: str description: str - retriable: bool -class InvalidShareSessionEpochError(BrokerResponseError): +class InvalidShareSessionEpochError(RetriableError, BrokerResponseError): errno: int message: str description: str - retriable: bool class FencedStateEpochError(BrokerResponseError): errno: int message: str description: str - retriable: bool class InvalidVoterKeyError(BrokerResponseError): errno: int message: str description: str - retriable: bool class DuplicateVoterError(BrokerResponseError): errno: int message: str description: str - retriable: bool class VoterNotFoundError(BrokerResponseError): errno: int message: str description: str - retriable: bool kafka_errors: Incomplete diff --git a/stubs/kafka-python/kafka/future.pyi b/stubs/kafka-python/kafka/future.pyi index 04b26e768662..42ea198f2582 100644 --- a/stubs/kafka-python/kafka/future.pyi +++ b/stubs/kafka-python/kafka/future.pyi @@ -1,19 +1,21 @@ from _typeshed import Incomplete - -log: Incomplete +from collections.abc import Generator +from typing_extensions import Self class Future: + __slots__ = ("is_done", "value", "exception", "_callbacks", "_errbacks", "_lock") error_on_callbacks: bool is_done: bool value: Incomplete exception: Incomplete def __init__(self) -> None: ... - def succeeded(self): ... - def failed(self): ... - def retriable(self): ... - def success(self, value): ... - def failure(self, e): ... - def add_callback(self, f, *args, **kwargs): ... - def add_errback(self, f, *args, **kwargs): ... - def add_both(self, f, *args, **kwargs): ... - def chain(self, future): ... + def succeeded(self) -> bool: ... + def failed(self) -> bool: ... + def retriable(self) -> bool: ... + def success(self, value) -> Self: ... + def failure(self, e) -> Self: ... + def add_callback(self, f, *args, **kwargs) -> Self: ... + def add_errback(self, f, *args, **kwargs) -> Self: ... + def add_both(self, f, *args, **kwargs) -> Self: ... + def chain(self, future) -> Self: ... + def __await__(self) -> Generator[Self]: ... diff --git a/stubs/kafka-python/kafka/metrics/compound_stat.pyi b/stubs/kafka-python/kafka/metrics/compound_stat.pyi index 6f41b10ef0fa..66ad951e5bb2 100644 --- a/stubs/kafka-python/kafka/metrics/compound_stat.pyi +++ b/stubs/kafka-python/kafka/metrics/compound_stat.pyi @@ -3,9 +3,11 @@ import abc from kafka.metrics.stat import AbstractStat class AbstractCompoundStat(AbstractStat, metaclass=abc.ABCMeta): - def stats(self) -> None: ... + @abc.abstractmethod + def stats(self): ... class NamedMeasurable: + __slots__ = ("_name", "_stat") def __init__(self, metric_name, measurable_stat) -> None: ... @property def name(self): ... diff --git a/stubs/kafka-python/kafka/metrics/dict_reporter.pyi b/stubs/kafka-python/kafka/metrics/dict_reporter.pyi index c48a7d9acd80..45ca2b302d44 100644 --- a/stubs/kafka-python/kafka/metrics/dict_reporter.pyi +++ b/stubs/kafka-python/kafka/metrics/dict_reporter.pyi @@ -1,15 +1,11 @@ -from _typeshed import Incomplete - from kafka.metrics.metrics_reporter import AbstractMetricsReporter -logger: Incomplete - class DictReporter(AbstractMetricsReporter): def __init__(self, prefix: str = "") -> None: ... def snapshot(self): ... def init(self, metrics) -> None: ... def metric_change(self, metric) -> None: ... def metric_removal(self, metric): ... - def get_category(self, metric): ... + def get_category(self, metric) -> str: ... def configure(self, configs) -> None: ... def close(self) -> None: ... diff --git a/stubs/kafka-python/kafka/metrics/kafka_metric.pyi b/stubs/kafka-python/kafka/metrics/kafka_metric.pyi index 856210a6d56b..471e2b36721a 100644 --- a/stubs/kafka-python/kafka/metrics/kafka_metric.pyi +++ b/stubs/kafka-python/kafka/metrics/kafka_metric.pyi @@ -1,4 +1,5 @@ class KafkaMetric: + __slots__ = ("_metric_name", "_measurable", "_config") def __init__(self, metric_name, measurable, config) -> None: ... @property def metric_name(self): ... diff --git a/stubs/kafka-python/kafka/metrics/metric_config.pyi b/stubs/kafka-python/kafka/metrics/metric_config.pyi index fc630189a272..da5d6f475216 100644 --- a/stubs/kafka-python/kafka/metrics/metric_config.pyi +++ b/stubs/kafka-python/kafka/metrics/metric_config.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete class MetricConfig: + __slots__ = ("quota", "_samples", "event_window", "time_window_ms", "tags") quota: Incomplete event_window: Incomplete time_window_ms: Incomplete diff --git a/stubs/kafka-python/kafka/metrics/metric_name.pyi b/stubs/kafka-python/kafka/metrics/metric_name.pyi index 44a770132927..61d2b007278b 100644 --- a/stubs/kafka-python/kafka/metrics/metric_name.pyi +++ b/stubs/kafka-python/kafka/metrics/metric_name.pyi @@ -1,4 +1,5 @@ class MetricName: + __slots__ = ("_name", "_group", "_description", "_tags", "_hash") def __init__(self, name, group, description=None, tags=None) -> None: ... @property def name(self): ... diff --git a/stubs/kafka-python/kafka/metrics/metrics.pyi b/stubs/kafka-python/kafka/metrics/metrics.pyi index 31db3617f08d..90361cd1d02c 100644 --- a/stubs/kafka-python/kafka/metrics/metrics.pyi +++ b/stubs/kafka-python/kafka/metrics/metrics.pyi @@ -1,7 +1,3 @@ -from _typeshed import Incomplete - -logger: Incomplete - class Metrics: def __init__(self, default_config=None, reporters=None, enable_expiration: bool = False) -> None: ... @property diff --git a/stubs/kafka-python/kafka/metrics/quota.pyi b/stubs/kafka-python/kafka/metrics/quota.pyi index 3290e80589fc..a812b66fd6f5 100644 --- a/stubs/kafka-python/kafka/metrics/quota.pyi +++ b/stubs/kafka-python/kafka/metrics/quota.pyi @@ -1,4 +1,5 @@ class Quota: + __slots__ = ("_bound", "_upper") def __init__(self, bound, is_upper) -> None: ... @staticmethod def upper_bound(upper_bound): ... diff --git a/stubs/kafka-python/kafka/metrics/stats/avg.pyi b/stubs/kafka-python/kafka/metrics/stats/avg.pyi index 0c00ef442744..e500971a4601 100644 --- a/stubs/kafka-python/kafka/metrics/stats/avg.pyi +++ b/stubs/kafka-python/kafka/metrics/stats/avg.pyi @@ -1,6 +1,7 @@ from kafka.metrics.stats.sampled_stat import AbstractSampledStat class Avg(AbstractSampledStat): + __slots__ = ("_initial_value", "_samples", "_current") def __init__(self) -> None: ... def update(self, sample, config, value, now) -> None: ... def combine(self, samples, config, now): ... diff --git a/stubs/kafka-python/kafka/metrics/stats/count.pyi b/stubs/kafka-python/kafka/metrics/stats/count.pyi index b13c9930b06a..9f305e3a81e0 100644 --- a/stubs/kafka-python/kafka/metrics/stats/count.pyi +++ b/stubs/kafka-python/kafka/metrics/stats/count.pyi @@ -1,6 +1,7 @@ from kafka.metrics.stats.sampled_stat import AbstractSampledStat class Count(AbstractSampledStat): + __slots__ = ("_initial_value", "_samples", "_current") def __init__(self) -> None: ... def update(self, sample, config, value, now) -> None: ... def combine(self, samples, config, now): ... diff --git a/stubs/kafka-python/kafka/metrics/stats/histogram.pyi b/stubs/kafka-python/kafka/metrics/stats/histogram.pyi index 74a77e0ff50c..b5b013fa8c8e 100644 --- a/stubs/kafka-python/kafka/metrics/stats/histogram.pyi +++ b/stubs/kafka-python/kafka/metrics/stats/histogram.pyi @@ -1,4 +1,5 @@ class Histogram: + __slots__ = ("_hist", "_count", "_bin_scheme") def __init__(self, bin_scheme) -> None: ... def record(self, value) -> None: ... def value(self, quantile): ... @@ -7,6 +8,7 @@ class Histogram: def clear(self) -> None: ... class ConstantBinScheme: + __slots__ = ("_min", "_max", "_bins", "_bucket_width") def __init__(self, bins, min_val, max_val) -> None: ... @property def bins(self): ... @@ -14,6 +16,7 @@ class Histogram: def to_bin(self, x): ... class LinearBinScheme: + __slots__ = ("_bins", "_max", "_scale") def __init__(self, num_bins, max_val) -> None: ... @property def bins(self): ... diff --git a/stubs/kafka-python/kafka/metrics/stats/max_stat.pyi b/stubs/kafka-python/kafka/metrics/stats/max_stat.pyi index 705b766b23a6..72f018c796f3 100644 --- a/stubs/kafka-python/kafka/metrics/stats/max_stat.pyi +++ b/stubs/kafka-python/kafka/metrics/stats/max_stat.pyi @@ -1,6 +1,7 @@ from kafka.metrics.stats.sampled_stat import AbstractSampledStat class Max(AbstractSampledStat): + __slots__ = ("_initial_value", "_samples", "_current") def __init__(self) -> None: ... def update(self, sample, config, value, now) -> None: ... def combine(self, samples, config, now): ... diff --git a/stubs/kafka-python/kafka/metrics/stats/min_stat.pyi b/stubs/kafka-python/kafka/metrics/stats/min_stat.pyi index cc5e3fbaf763..d3d895e3bbc6 100644 --- a/stubs/kafka-python/kafka/metrics/stats/min_stat.pyi +++ b/stubs/kafka-python/kafka/metrics/stats/min_stat.pyi @@ -1,6 +1,7 @@ from kafka.metrics.stats.sampled_stat import AbstractSampledStat class Min(AbstractSampledStat): + __slots__ = ("_initial_value", "_samples", "_current") def __init__(self) -> None: ... def update(self, sample, config, value, now) -> None: ... def combine(self, samples, config, now): ... diff --git a/stubs/kafka-python/kafka/metrics/stats/percentile.pyi b/stubs/kafka-python/kafka/metrics/stats/percentile.pyi index a27b11c05a7b..bec615ced91f 100644 --- a/stubs/kafka-python/kafka/metrics/stats/percentile.pyi +++ b/stubs/kafka-python/kafka/metrics/stats/percentile.pyi @@ -1,4 +1,5 @@ class Percentile: + __slots__ = ("_metric_name", "_percentile") def __init__(self, metric_name, percentile) -> None: ... @property def name(self): ... diff --git a/stubs/kafka-python/kafka/metrics/stats/percentiles.pyi b/stubs/kafka-python/kafka/metrics/stats/percentiles.pyi index 8f7bbe0effcd..5f40f4193eb3 100644 --- a/stubs/kafka-python/kafka/metrics/stats/percentiles.pyi +++ b/stubs/kafka-python/kafka/metrics/stats/percentiles.pyi @@ -8,7 +8,7 @@ class BucketSizing: LINEAR: int class Percentiles(AbstractSampledStat, AbstractCompoundStat): - bin_scheme: Incomplete + __slots__ = ("_initial_value", "_samples", "_current", "_percentiles", "_buckets", "_bin_scheme") def __init__(self, size_in_bytes, bucketing, max_val, min_val: float = 0.0, percentiles=None) -> None: ... def stats(self): ... def value(self, config, now, quantile): ... diff --git a/stubs/kafka-python/kafka/metrics/stats/rate.pyi b/stubs/kafka-python/kafka/metrics/stats/rate.pyi index d5199a72807b..22c4c09cd0ef 100644 --- a/stubs/kafka-python/kafka/metrics/stats/rate.pyi +++ b/stubs/kafka-python/kafka/metrics/stats/rate.pyi @@ -15,6 +15,7 @@ class TimeUnit: def get_name(time_unit): ... class Rate(AbstractMeasurableStat): + __slots__ = ("_stat", "_unit") def __init__(self, time_unit=3, sampled_stat=None) -> None: ... def unit_name(self): ... def record(self, config, value, time_ms) -> None: ... @@ -23,6 +24,7 @@ class Rate(AbstractMeasurableStat): def convert(self, time_ms): ... class SampledTotal(AbstractSampledStat): + __slots__ = ("_initial_value", "_samples", "_current") def __init__(self, initial_value=None) -> None: ... def update(self, sample, config, value, time_ms) -> None: ... def combine(self, samples, config, now): ... diff --git a/stubs/kafka-python/kafka/metrics/stats/sampled_stat.pyi b/stubs/kafka-python/kafka/metrics/stats/sampled_stat.pyi index c589cd800c80..f063cc9cff09 100644 --- a/stubs/kafka-python/kafka/metrics/stats/sampled_stat.pyi +++ b/stubs/kafka-python/kafka/metrics/stats/sampled_stat.pyi @@ -4,6 +4,7 @@ from _typeshed import Incomplete from kafka.metrics.measurable_stat import AbstractMeasurableStat class AbstractSampledStat(AbstractMeasurableStat, metaclass=abc.ABCMeta): + __slots__ = ("_initial_value", "_samples", "_current") def __init__(self, initial_value) -> None: ... @abc.abstractmethod def update(self, sample, config, value, time_ms): ... diff --git a/stubs/kafka-python/kafka/metrics/stats/sensor.pyi b/stubs/kafka-python/kafka/metrics/stats/sensor.pyi index f302ed0944be..af3baa05db05 100644 --- a/stubs/kafka-python/kafka/metrics/stats/sensor.pyi +++ b/stubs/kafka-python/kafka/metrics/stats/sensor.pyi @@ -1,4 +1,15 @@ class Sensor: + __slots__ = ( + "_lock", + "_registry", + "_name", + "_parents", + "_metrics", + "_stats", + "_config", + "_inactive_sensor_expiration_time_ms", + "_last_record_time", + ) def __init__(self, registry, name, parents, config, inactive_sensor_expiration_time_seconds) -> None: ... @property def name(self): ... diff --git a/stubs/kafka-python/kafka/metrics/stats/total.pyi b/stubs/kafka-python/kafka/metrics/stats/total.pyi index 2a33feb1b02b..bd52102f6cfb 100644 --- a/stubs/kafka-python/kafka/metrics/stats/total.pyi +++ b/stubs/kafka-python/kafka/metrics/stats/total.pyi @@ -1,6 +1,7 @@ from kafka.metrics.measurable_stat import AbstractMeasurableStat class Total(AbstractMeasurableStat): + __slots__ = ("_total",) def __init__(self, value: float = 0.0) -> None: ... def record(self, config, value, now) -> None: ... def measure(self, config, now): ... diff --git a/stubs/kafka-python/kafka/net/__init__.pyi b/stubs/kafka-python/kafka/net/__init__.pyi new file mode 100644 index 000000000000..1a7f3a813291 --- /dev/null +++ b/stubs/kafka-python/kafka/net/__init__.pyi @@ -0,0 +1,26 @@ +from .compat import KafkaNetClient as KafkaNetClient +from .connection import KafkaConnection as KafkaConnection +from .http_connect import HttpConnectProxy as HttpConnectProxy +from .inet import KafkaNetSocket as KafkaNetSocket, create_connection as create_connection +from .manager import KafkaConnectionManager as KafkaConnectionManager +from .metrics import KafkaConnectionMetrics as KafkaConnectionMetrics, KafkaManagerMetrics as KafkaManagerMetrics +from .selector import NetworkSelector as NetworkSelector +from .socks5 import Socks5Proxy as Socks5Proxy +from .transport import KafkaSSLTransport as KafkaSSLTransport, KafkaTCPTransport as KafkaTCPTransport +from .wakeup_notifier import WakeupNotifier as WakeupNotifier + +__all__ = [ + "KafkaConnection", + "create_connection", + "KafkaNetSocket", + "KafkaConnectionManager", + "KafkaConnectionMetrics", + "KafkaManagerMetrics", + "NetworkSelector", + "HttpConnectProxy", + "Socks5Proxy", + "KafkaTCPTransport", + "KafkaSSLTransport", + "WakeupNotifier", + "KafkaNetClient", +] diff --git a/stubs/kafka-python/kafka/net/compat.pyi b/stubs/kafka-python/kafka/net/compat.pyi new file mode 100644 index 000000000000..4998b20c5eb4 --- /dev/null +++ b/stubs/kafka-python/kafka/net/compat.pyi @@ -0,0 +1,24 @@ +class KafkaNetClient: + def __init__(self, net=None, manager=None, **configs) -> None: ... + @property + def cluster(self): ... + def connected(self, node_id) -> bool: ... + def is_disconnected(self, node_id) -> bool: ... + def is_ready(self, node_id) -> bool: ... + def ready(self, node_id, **kwargs) -> bool: ... + def maybe_connect(self, node_id, **kwargs) -> None: ... + def await_ready(self, node_id, timeout_ms=30000): ... + def in_flight_request_count(self, node_id=None) -> int: ... + def throttle_delay(self, node_id) -> int: ... + def bootstrap_connected(self) -> bool: ... + def get_broker_version(self, timeout_ms=None): ... + def check_version(self, node_id=None, timeout_ms=10000): ... + def send(self, node_id, request, **kwargs): ... + def send_and_receive(self, node_id, request, timeout_ms=30000): ... + def poll(self, timeout_ms=None, future=None): ... + def close(self, node_id=None) -> None: ... + def least_loaded_node(self, bootstrap_fallback: bool = False): ... + def least_loaded_node_refresh_ms(self, bootstrap_fallback: bool = False): ... + def connection_delay(self, node_id): ... + def wakeup(self) -> None: ... + def api_version(self, operation, max_version=None): ... diff --git a/stubs/kafka-python/kafka/net/connection.pyi b/stubs/kafka-python/kafka/net/connection.pyi new file mode 100644 index 000000000000..0112c13275ed --- /dev/null +++ b/stubs/kafka-python/kafka/net/connection.pyi @@ -0,0 +1,57 @@ +from _typeshed import Incomplete +from collections import deque +from collections.abc import Generator +from typing_extensions import Self + +from kafka.future import Future + +class KafkaConnection: + DEFAULT_CONFIG: dict[str, Incomplete] + config: dict[str, Incomplete] + node_id: Incomplete + net: Incomplete + transport: Incomplete | None + parser: Incomplete | None + paused: set[Incomplete] + connected: bool + initializing: bool + in_flight_requests: deque[tuple[Incomplete, ...]] + broker_version_data: Incomplete + def __init__(self, net, node_id=None, broker_version_data=None, **configs) -> None: ... + @property + def broker_version(self): ... + @property + def closed(self) -> bool: ... + @property + def init_future(self) -> Future: ... + def __await__(self) -> Generator[Future, Incomplete, Self]: ... + @property + def close_future(self) -> Future: ... + def send_request(self, request, request_timeout_ms=None) -> Future: ... + def send_buffered(self) -> None: ... + def data_received(self, data) -> None: ... + def eof_received(self): ... + def connection_lost(self, exc) -> None: ... + def fail_in_flight_requests(self, error) -> None: ... + def connection_made(self, transport) -> None: ... + def pause(self, v) -> None: ... + def unpause(self, v) -> None: ... + def pause_writing(self) -> None: ... + def resume_writing(self) -> None: ... + def close(self, error=None) -> None: ... + async def initialize(self, timeout_at: float | None = None) -> None: ... + @property + def sasl_enabled(self) -> bool: ... + +class SaslReauthenticator: + session_lifetime_ms: Incomplete + authenticated_at: float | None + def __init__(self, conn) -> None: ... + @property + def is_reauthenticating(self) -> bool: ... + @property + def task(self): ... + def session_updated(self, session_lifetime_ms) -> None: ... + def schedule(self) -> None: ... + def cancel(self) -> None: ... + def on_response_processed(self) -> None: ... diff --git a/stubs/kafka-python/kafka/net/http_connect.pyi b/stubs/kafka-python/kafka/net/http_connect.pyi new file mode 100644 index 000000000000..976db341ffcd --- /dev/null +++ b/stubs/kafka-python/kafka/net/http_connect.pyi @@ -0,0 +1,10 @@ +import socket as _socket + +from kafka.net.inet import KafkaNetSocket + +class HttpConnectProxy(KafkaNetSocket): + SCHEMES: tuple[str, ...] + def __init__(self, proxy_url) -> None: ... # pyright: ignore[reportInconsistentConstructor] + def dns_lookup(self, host, port, proxy: bool = False): ... + def socket(self, family=..., sock_type=..., proto=...) -> _socket.socket: ... + def connect_ex(self, sock, addr) -> int: ... diff --git a/stubs/kafka-python/kafka/net/inet.pyi b/stubs/kafka-python/kafka/net/inet.pyi new file mode 100644 index 000000000000..2241554661a2 --- /dev/null +++ b/stubs/kafka-python/kafka/net/inet.pyi @@ -0,0 +1,16 @@ +import socket as _socket +from typing_extensions import Self + +async def create_connection(net, host, port, socket_options=(), proxy_url=None, timeout_at=None): ... + +class KafkaNetSocket: + @classmethod + def register_class(cls, klass) -> None: ... + def __init_subclass__(cls, **kw) -> None: ... + def __new__(cls, proxy_url=None) -> Self: ... + def __init__(self, proxy_url=None) -> None: ... + def dns_lookup(self, host, port, raise_error: bool = False): ... + def socket(self, family=..., sock_type=..., proto=...) -> _socket.socket: ... + async def connect(self, net, addrinfo, socket_options=(), timeout_at=None): ... + async def sock_connect(self, net, sock, sockaddr, timeout_at=None): ... + def connect_ex(self, sock, sockaddr): ... diff --git a/stubs/kafka-python/kafka/net/manager.pyi b/stubs/kafka-python/kafka/net/manager.pyi new file mode 100644 index 000000000000..e72d0e139f44 --- /dev/null +++ b/stubs/kafka-python/kafka/net/manager.pyi @@ -0,0 +1,44 @@ +from _typeshed import Incomplete + +from kafka.cluster import ClusterMetadata +from kafka.future import Future +from kafka.protocol.broker_version_data import BrokerVersionData + +class KafkaConnectionManager: + DEFAULT_CONFIG: dict[str, Incomplete] + config: dict[str, Incomplete] + cluster: ClusterMetadata + broker_version_data: BrokerVersionData | None + closed: bool + def __init__(self, net, **configs) -> None: ... + @property + def broker_version(self): ... + def least_used_connections(self) -> list[Incomplete]: ... + def bootstrap_async(self, timeout_ms=None, refresh: bool = True): ... + def bootstrap(self, timeout_ms=None, refresh: bool = True) -> None: ... + @property + def bootstrapped(self) -> bool: ... + def close_idle_connections(self) -> None: ... + @property + def ssl_enabled(self) -> bool: ... + def get_connection( + self, + node_id, + timeout_ms=None, + pop_on_close: bool = True, + refresh_metadata_on_err: bool = True, + reset_backoff_on_connect: bool = True, + ): ... + def send(self, request, node_id=None, request_timeout_ms=None): ... + def least_loaded_node(self): ... + def reset_backoff(self, node_id) -> None: ... + def jitter_pct(self) -> float: ... + def update_backoff(self, node_id): ... + def connection_delay(self, node_id) -> int: ... + def socket_connection_setup_timeout_ms(self, node_id): ... + def auth_failure(self, node_id): ... + def maybe_raise_auth_failure(self, node_id) -> None: ... + def close(self, node_id=None, timeout_ms=None) -> None: ... + async def wait_for(self, future, timeout_ms): ... + def call_soon(self, coro, *args) -> Future: ... + def run(self, coro, *args): ... diff --git a/stubs/kafka-python/kafka/net/metrics.pyi b/stubs/kafka-python/kafka/net/metrics.pyi new file mode 100644 index 000000000000..a314a9f2c0e8 --- /dev/null +++ b/stubs/kafka-python/kafka/net/metrics.pyi @@ -0,0 +1,15 @@ +from _typeshed import Incomplete + +class KafkaManagerMetrics: + metrics: Incomplete + connection_closed: Incomplete + connection_created: Incomplete + def __init__(self, metrics, metric_group_prefix: str, conns) -> None: ... + +class KafkaConnectionMetrics: + metrics: Incomplete + bytes_sent: Incomplete + bytes_received: Incomplete + request_time: Incomplete + throttle_time: Incomplete + def __init__(self, metrics, metric_group_prefix: str, node_id) -> None: ... diff --git a/stubs/kafka-python/kafka/sasl/__init__.pyi b/stubs/kafka-python/kafka/net/sasl/__init__.pyi similarity index 100% rename from stubs/kafka-python/kafka/sasl/__init__.pyi rename to stubs/kafka-python/kafka/net/sasl/__init__.pyi diff --git a/stubs/kafka-python/kafka/sasl/abc.pyi b/stubs/kafka-python/kafka/net/sasl/abc.pyi similarity index 100% rename from stubs/kafka-python/kafka/sasl/abc.pyi rename to stubs/kafka-python/kafka/net/sasl/abc.pyi diff --git a/stubs/kafka-python/kafka/sasl/gssapi.pyi b/stubs/kafka-python/kafka/net/sasl/gssapi.pyi similarity index 91% rename from stubs/kafka-python/kafka/sasl/gssapi.pyi rename to stubs/kafka-python/kafka/net/sasl/gssapi.pyi index 2bbe75ee3526..cb3140c760b9 100644 --- a/stubs/kafka-python/kafka/sasl/gssapi.pyi +++ b/stubs/kafka-python/kafka/net/sasl/gssapi.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from kafka.sasl.abc import SaslMechanism +from .abc import SaslMechanism class SaslMechanismGSSAPI(SaslMechanism): SASL_QOP_AUTH: int diff --git a/stubs/kafka-python/kafka/sasl/msk.pyi b/stubs/kafka-python/kafka/net/sasl/msk.pyi similarity index 93% rename from stubs/kafka-python/kafka/sasl/msk.pyi rename to stubs/kafka-python/kafka/net/sasl/msk.pyi index 3c3efed6fcc1..272d60726c2b 100644 --- a/stubs/kafka-python/kafka/sasl/msk.pyi +++ b/stubs/kafka-python/kafka/net/sasl/msk.pyi @@ -1,8 +1,6 @@ from _typeshed import Incomplete -from kafka.sasl.abc import SaslMechanism - -log: Incomplete +from .abc import SaslMechanism class SaslMechanismAwsMskIam(SaslMechanism): host: Incomplete diff --git a/stubs/kafka-python/kafka/sasl/oauth.pyi b/stubs/kafka-python/kafka/net/sasl/oauth.pyi similarity index 77% rename from stubs/kafka-python/kafka/sasl/oauth.pyi rename to stubs/kafka-python/kafka/net/sasl/oauth.pyi index 089ad778c4f4..47876d066958 100644 --- a/stubs/kafka-python/kafka/sasl/oauth.pyi +++ b/stubs/kafka-python/kafka/net/sasl/oauth.pyi @@ -1,9 +1,7 @@ import abc from _typeshed import Incomplete -from kafka.sasl.abc import SaslMechanism - -log: Incomplete +from .abc import SaslMechanism class SaslMechanismOAuth(SaslMechanism): token_provider: Incomplete @@ -14,9 +12,7 @@ class SaslMechanismOAuth(SaslMechanism): def is_authenticated(self): ... def auth_details(self): ... -ABC: Incomplete - -class AbstractTokenProvider(ABC, metaclass=abc.ABCMeta): +class AbstractTokenProvider(abc.ABC, metaclass=abc.ABCMeta): def __init__(self, **config) -> None: ... @abc.abstractmethod def token(self): ... diff --git a/stubs/kafka-python/kafka/sasl/plain.pyi b/stubs/kafka-python/kafka/net/sasl/plain.pyi similarity index 85% rename from stubs/kafka-python/kafka/sasl/plain.pyi rename to stubs/kafka-python/kafka/net/sasl/plain.pyi index be3f7961ad39..ef14330ae527 100644 --- a/stubs/kafka-python/kafka/sasl/plain.pyi +++ b/stubs/kafka-python/kafka/net/sasl/plain.pyi @@ -1,8 +1,6 @@ from _typeshed import Incomplete -from kafka.sasl.abc import SaslMechanism - -log: Incomplete +from .abc import SaslMechanism class SaslMechanismPlain(SaslMechanism): username: Incomplete diff --git a/stubs/kafka-python/kafka/sasl/scram.pyi b/stubs/kafka-python/kafka/net/sasl/scram.pyi similarity index 92% rename from stubs/kafka-python/kafka/sasl/scram.pyi rename to stubs/kafka-python/kafka/net/sasl/scram.pyi index 928d1efb094f..6803c6c15b63 100644 --- a/stubs/kafka-python/kafka/sasl/scram.pyi +++ b/stubs/kafka-python/kafka/net/sasl/scram.pyi @@ -1,10 +1,8 @@ from _typeshed import Incomplete -from kafka.sasl.abc import SaslMechanism +from .abc import SaslMechanism -log: Incomplete - -def xor_bytes(left, right): ... +def xor_bytes(left, right) -> bytes: ... class SaslMechanismScram(SaslMechanism): username: Incomplete diff --git a/stubs/kafka-python/kafka/sasl/sspi.pyi b/stubs/kafka-python/kafka/net/sasl/sspi.pyi similarity index 87% rename from stubs/kafka-python/kafka/sasl/sspi.pyi rename to stubs/kafka-python/kafka/net/sasl/sspi.pyi index 600c382b4094..7e7f456f39e5 100644 --- a/stubs/kafka-python/kafka/sasl/sspi.pyi +++ b/stubs/kafka-python/kafka/net/sasl/sspi.pyi @@ -1,8 +1,6 @@ from _typeshed import Incomplete -from kafka.sasl.abc import SaslMechanism - -log: Incomplete +from .abc import SaslMechanism class SaslMechanismSSPI(SaslMechanism): SASL_QOP_AUTH: int diff --git a/stubs/kafka-python/kafka/net/selector.pyi b/stubs/kafka-python/kafka/net/selector.pyi new file mode 100644 index 000000000000..6342c2ecebf2 --- /dev/null +++ b/stubs/kafka-python/kafka/net/selector.pyi @@ -0,0 +1,73 @@ +import enum +from _typeshed import Incomplete +from collections.abc import Generator +from typing import Final +from typing_extensions import Self + +from kafka.future import Future + +MAX_TIMEOUT: Final = 2147483 + +def yield_callback(callback): ... + +class KernelEvent: + method: str + args: tuple[Incomplete, ...] + def __init__(self, method: str, *args) -> None: ... + def __await__(self) -> Generator[Self]: ... + +class TaskState(enum.Enum): + CREATED = "created" + SCHEDULED = "scheduled" + UNSCHEDULED = "unscheduled" + READY = "ready" + RUNNING = "running" + WAIT_IO = "wait_io" + WAIT_FUTURE = "wait_future" + DONE = "done" + CANCELLED = "cancelled" + +class Task: + scheduled_at: Incomplete | None + state: Incomplete + def __init__(self, coro) -> None: ... + def __lt__(self, other) -> bool: ... + def __call__(self, arg=None): ... + def push_stack(self, coro) -> None: ... + def inject_exc(self, exc) -> None: ... + def close(self) -> None: ... + @property + def is_done(self) -> bool: ... + @property + def result(self): ... + @property + def exception(self): ... + +class NetworkSelector: + DEFAULT_CONFIG: dict[str, Incomplete] + config: dict[str, Incomplete] + def __init__(self, **configs) -> None: ... + def run_forever(self) -> None: ... + def start(self) -> None: ... + def stop(self, timeout_ms=None) -> None: ... + def run(self, coro, *args): ... + def drain(self, scheduled: bool = False) -> None: ... + def call_at(self, when, task) -> Task: ... + def call_later(self, delay, task) -> Task: ... + def call_soon(self, task) -> Task: ... + def call_soon_threadsafe(self, callback) -> Task: ... + def call_soon_with_future(self, coro, *args) -> Future: ... + def cancel(self, task) -> None: ... + def reschedule(self, when, task): ... + def sleep(self, delay) -> KernelEvent: ... + def wait_write(self, fileobj, timeout_at=None) -> KernelEvent: ... + def wait_read(self, fileobj, timeout_at=None) -> KernelEvent: ... + def register_event(self, fileobj, event, task) -> None: ... + def unregister_event(self, fileobj, event) -> None: ... + def add_reader(self, fileobj, task) -> None: ... + def remove_reader(self, fileobj) -> None: ... + def add_writer(self, fileobj, task) -> None: ... + def remove_writer(self, fileobj) -> None: ... + def poll(self, timeout_ms=None, future=None) -> None: ... + def wakeup(self) -> None: ... + def close(self) -> None: ... diff --git a/stubs/kafka-python/kafka/net/socks5.pyi b/stubs/kafka-python/kafka/net/socks5.pyi new file mode 100644 index 000000000000..52c11a38ba3c --- /dev/null +++ b/stubs/kafka-python/kafka/net/socks5.pyi @@ -0,0 +1,22 @@ +import socket as _socket +from typing import Final + +from kafka.net.inet import KafkaNetSocket + +class ProxyConnectionStates: + DISCONNECTED: Final = "" + CONNECTING: Final = "" + NEGOTIATE_PROPOSE: Final = "" + NEGOTIATING: Final = "" + AUTHENTICATING: Final = "" + REQUEST_SUBMIT: Final = "" + REQUESTING: Final = "" + READ_ADDRESS: Final = "" + COMPLETE: Final = "" + +class Socks5Proxy(KafkaNetSocket): + SCHEMES: tuple[str, ...] + def __init__(self, proxy_url: str) -> None: ... # pyright: ignore[reportInconsistentConstructor] + def dns_lookup(self, host, port, proxy: bool = False): ... + def socket(self, family=..., sock_type=..., proto=...) -> _socket.socket: ... + def connect_ex(self, sock, addr) -> int: ... diff --git a/stubs/kafka-python/kafka/net/transport.pyi b/stubs/kafka-python/kafka/net/transport.pyi new file mode 100644 index 000000000000..acfb577e6fa4 --- /dev/null +++ b/stubs/kafka-python/kafka/net/transport.pyi @@ -0,0 +1,43 @@ +import socket +from _typeshed import Incomplete + +class KafkaTCPTransport: + host: Incomplete | None + last_write: float + last_read: float + def __init__(self, net, sock, host=None) -> None: ... + @property + def last_activity(self) -> float: ... + def is_closing(self) -> bool: ... + def close(self) -> None: ... + def set_protocol(self, protocol) -> None: ... + def get_protocol(self): ... + def is_reading(self) -> bool: ... + def pause_reading(self) -> None: ... + def resume_reading(self) -> None: ... + def set_write_buffer_limits(self, high=None, low=None): ... + def get_write_buffer_size(self): ... + def get_write_buffer_limits(self): ... + def write(self, data) -> None: ... + def writelines(self, list_of_data) -> None: ... + def write_eof(self) -> None: ... + def can_write_eof(self): ... + def abort(self, error=None) -> None: ... + def abortConnection(self) -> None: ... + def getHost(self) -> socket._RetAddress: ... + def getPeer(self) -> socket._RetAddress: ... + def getTcpKeepAlive(self) -> int: ... + def getTcpNoDelay(self) -> int: ... + def loseWriteConnection(self) -> None: ... + def setTcpKeepAlive(self, enabled) -> None: ... + def setTcpNoDelay(self, enabled) -> None: ... + def loseConnection(self) -> None: ... + def writeSequence(self, data) -> None: ... + async def handshake(self) -> None: ... + def host_port(self) -> str: ... + +class KafkaSSLTransport(KafkaTCPTransport): + DEFAULT_CONFIG: dict[str, Incomplete] + ssl_config: dict[str, Incomplete] + def __init__(self, net, sock, host=None, **configs) -> None: ... + async def handshake(self) -> None: ... diff --git a/stubs/kafka-python/kafka/net/wakeup_notifier.pyi b/stubs/kafka-python/kafka/net/wakeup_notifier.pyi new file mode 100644 index 000000000000..92177c18484f --- /dev/null +++ b/stubs/kafka-python/kafka/net/wakeup_notifier.pyi @@ -0,0 +1,4 @@ +class WakeupNotifier: + def __init__(self, net) -> None: ... + async def __call__(self, timeout_secs=None) -> None: ... + def notify(self) -> None: ... diff --git a/stubs/kafka-python/kafka/partitioner/__init__.pyi b/stubs/kafka-python/kafka/partitioner/__init__.pyi index 93b321c722a6..841530ee0fa1 100644 --- a/stubs/kafka-python/kafka/partitioner/__init__.pyi +++ b/stubs/kafka-python/kafka/partitioner/__init__.pyi @@ -1,3 +1,5 @@ -from kafka.partitioner.default import DefaultPartitioner as DefaultPartitioner, murmur2 as murmur2 +from .abc import Partitioner as Partitioner +from .default import DefaultPartitioner as DefaultPartitioner, murmur2 as murmur2 +from .sticky import StickyPartitioner as StickyPartitioner -__all__ = ["DefaultPartitioner", "murmur2"] +__all__ = ["Partitioner", "DefaultPartitioner", "StickyPartitioner", "murmur2"] diff --git a/stubs/kafka-python/kafka/partitioner/abc.pyi b/stubs/kafka-python/kafka/partitioner/abc.pyi new file mode 100644 index 000000000000..28ff08312585 --- /dev/null +++ b/stubs/kafka-python/kafka/partitioner/abc.pyi @@ -0,0 +1,9 @@ +import abc + +from kafka.cluster import ClusterMetadata + +class Partitioner(abc.ABC): + @abc.abstractmethod + def partition( + self, topic: str, key, serialized_key: bytes, value, serialized_value: bytes, cluster: ClusterMetadata + ) -> int: ... diff --git a/stubs/kafka-python/kafka/partitioner/default.pyi b/stubs/kafka-python/kafka/partitioner/default.pyi index 6800f5b03315..e7e1bac1cdb9 100644 --- a/stubs/kafka-python/kafka/partitioner/default.pyi +++ b/stubs/kafka-python/kafka/partitioner/default.pyi @@ -1,5 +1,6 @@ -class DefaultPartitioner: - @classmethod - def __call__(cls, key, all_partitions, available): ... +from .abc import Partitioner -def murmur2(data): ... +class DefaultPartitioner(Partitioner): + def partition(self, topic, key, serialized_key, value, serialized_value, cluster) -> int: ... + +def murmur2(data: bytes) -> int: ... diff --git a/stubs/kafka-python/kafka/partitioner/sticky.pyi b/stubs/kafka-python/kafka/partitioner/sticky.pyi new file mode 100644 index 000000000000..3658eeb8b6f9 --- /dev/null +++ b/stubs/kafka-python/kafka/partitioner/sticky.pyi @@ -0,0 +1,6 @@ +from .default import DefaultPartitioner + +class StickyPartitioner(DefaultPartitioner): + def __init__(self) -> None: ... + def partition(self, topic, key, serialized_key, value, serialized_value, cluster): ... + def on_new_batch(self, topic, cluster, prev_partition) -> None: ... diff --git a/stubs/kafka-python/kafka/producer/future.pyi b/stubs/kafka-python/kafka/producer/future.pyi index ad0fa3962f16..70c40099b453 100644 --- a/stubs/kafka-python/kafka/producer/future.pyi +++ b/stubs/kafka-python/kafka/producer/future.pyi @@ -5,6 +5,7 @@ from kafka.future import Future from kafka.structs import TopicPartition class FutureProduceResult(Future): + __slots__ = ("topic_partition", "_latch") topic_partition: TopicPartition def __init__(self, topic_partition: TopicPartition) -> None: ... def success(self, value): ... @@ -12,6 +13,7 @@ class FutureProduceResult(Future): def wait(self, timeout=None): ... class FutureRecordMetadata(Future): + __slots__ = ("_produce_future", "args") args: Incomplete def __init__( self, @@ -23,6 +25,7 @@ class FutureRecordMetadata(Future): serialized_value_size, serialized_header_size, ) -> None: ... + def rebind(self, new_produce_future, new_batch_index) -> None: ... def get(self, timeout=None): ... class RecordMetadata(NamedTuple): @@ -31,7 +34,7 @@ class RecordMetadata(NamedTuple): topic_partition: TopicPartition offset: int timestamp: int - checksum: int | None + checksum: int | None # Deprecated field serialized_key_size: int serialized_value_size: int serialized_header_size: int diff --git a/stubs/kafka-python/kafka/producer/kafka.pyi b/stubs/kafka-python/kafka/producer/kafka.pyi index c00758c2f684..1084cd1f926e 100644 --- a/stubs/kafka-python/kafka/producer/kafka.pyi +++ b/stubs/kafka-python/kafka/producer/kafka.pyi @@ -2,90 +2,89 @@ import selectors import ssl from _typeshed import Incomplete from collections.abc import Callable, Mapping, Sequence -from typing import Literal, TypeAlias, TypedDict, type_check_only -from typing_extensions import Unpack +from types import TracebackType +from typing import Literal, TypeAlias +from typing_extensions import Self from kafka.producer.future import FutureRecordMetadata +from kafka.producer.record_accumulator import AtomicInteger from kafka.serializer.abstract import Serializer -from kafka.structs import OffsetAndMetadata, TopicPartition +from kafka.structs import ConsumerGroupMetadata, OffsetAndMetadata, TopicPartition -_ApiVersion: TypeAlias = tuple[int, ...] -_BootstrapServers: TypeAlias = str | Sequence[str] -_KafkaClientFactory: TypeAlias = Callable[..., object] _Partitioner: TypeAlias = Callable[[bytes | None, Sequence[int], Sequence[int]], int] _ProducerSerializer: TypeAlias = Serializer | Callable[[object], bytes] -_SaslMechanism: TypeAlias = Literal["PLAIN", "GSSAPI", "OAUTHBEARER", "SCRAM-SHA-256", "SCRAM-SHA-512"] -_SecurityProtocol: TypeAlias = Literal["PLAINTEXT", "SSL", "SASL_PLAINTEXT", "SASL_SSL"] -_SocketOption: TypeAlias = tuple[int, int, int] -@type_check_only -class _KafkaProducerConfig(TypedDict, total=False): - bootstrap_servers: _BootstrapServers - client_id: str | None - key_serializer: _ProducerSerializer | None - value_serializer: _ProducerSerializer | None - enable_idempotence: bool - transactional_id: str | None - transaction_timeout_ms: int - delivery_timeout_ms: float - acks: int | Literal["all"] - bootstrap_topics_filter: set[str] - compression_type: Literal["gzip", "snappy", "lz4", "zstd"] | None - retries: int | float - batch_size: int - linger_ms: int - partitioner: _Partitioner - connections_max_idle_ms: int - max_block_ms: int - max_request_size: int - allow_auto_create_topics: bool - metadata_max_age_ms: int - retry_backoff_ms: int - request_timeout_ms: int - receive_buffer_bytes: int | None - send_buffer_bytes: int | None - socket_options: Sequence[_SocketOption] - sock_chunk_bytes: int - sock_chunk_buffer_count: int - reconnect_backoff_ms: int - reconnect_backoff_max_ms: int - max_in_flight_requests_per_connection: int - security_protocol: _SecurityProtocol - ssl_context: ssl.SSLContext | None - ssl_check_hostname: bool - ssl_cafile: str | None - ssl_certfile: str | None - ssl_keyfile: str | None - ssl_crlfile: str | None - ssl_password: str | None - ssl_ciphers: str | None - api_version: _ApiVersion | None - api_version_auto_timeout_ms: int - metric_reporters: Sequence[type[object]] - metrics_enabled: bool - metrics_num_samples: int - metrics_sample_window_ms: int - selector: type[selectors.BaseSelector] - sasl_mechanism: _SaslMechanism | None - sasl_plain_username: str | None - sasl_plain_password: str | None - sasl_kerberos_name: object | None - sasl_kerberos_service_name: str - sasl_kerberos_domain_name: str | None - sasl_oauth_token_provider: object | None - socks5_proxy: str | None - kafka_client: _KafkaClientFactory - -log: Incomplete -PRODUCER_CLIENT_ID_SEQUENCE: Incomplete +PRODUCER_CLIENT_ID_SEQUENCE: AtomicInteger class KafkaProducer: - DEFAULT_CONFIG: Incomplete - DEPRECATED_CONFIGS: Incomplete - config: Incomplete - def __init__(self, **configs: Unpack[_KafkaProducerConfig]) -> None: ... - def bootstrap_connected(self): ... + DEFAULT_CONFIG: dict[str, Incomplete] + DEPRECATED_CONFIGS: tuple[str, ...] + config: dict[str, Incomplete] + def __init__( + self, + *, + bootstrap_servers: str | Sequence[str] = "localhost", + client_id: str | None = None, + key_serializer: _ProducerSerializer | None = None, + value_serializer: _ProducerSerializer | None = None, + enable_idempotence: bool = True, + transactional_id: str | None = None, + transaction_timeout_ms: int = 60000, + delivery_timeout_ms: float = 120000, + acks: int | Literal["all"] = -1, + compression_type: Literal["gzip", "snappy", "lz4", "zstd"] | None = None, + retries: int | float = ..., + batch_size: int = 16384, + linger_ms: int = 0, + partitioner: _Partitioner = ..., + connections_max_idle_ms: int = 540000, + max_block_ms: int = 60000, + max_request_size: int = 1048576, + allow_auto_create_topics: bool = True, + metadata_max_age_ms: int = 300000, + client_dns_lookup: str = "use_all_dns_ips", + retry_backoff_ms: int = 100, + request_timeout_ms: int = 30000, + receive_message_max_bytes: int = 100_000_000, + receive_buffer_bytes: int | None = None, + send_buffer_bytes: int | None = None, + socket_options: Sequence[tuple[int, int, int]] = ..., + reconnect_backoff_ms: int = 50, + reconnect_backoff_max_ms: int = 30000, + max_in_flight_requests_per_connection: int = 5, + security_protocol: Literal["PLAINTEXT", "SSL", "SASL_PLAINTEXT", "SASL_SSL"] = "PLAINTEXT", + ssl_context: ssl.SSLContext | None = None, + ssl_check_hostname: bool = True, + ssl_cafile: str | None = None, + ssl_certfile: str | None = None, + ssl_keyfile: str | None = None, + ssl_crlfile: str | None = None, + ssl_password: str | None = None, + ssl_ciphers: str | None = None, + api_version: tuple[int, ...] | None = None, + bootstrap_timeout_ms: int = 30000, + metric_reporters: Sequence[type[object]] = [], + metrics_enabled: bool = True, + metrics_num_samples: int = 2, + metrics_sample_window_ms: int = 30000, + selector: type[selectors.BaseSelector] = selectors.DefaultSelector, + sasl_mechanism: Literal["PLAIN", "GSSAPI", "OAUTHBEARER", "SCRAM-SHA-256", "SCRAM-SHA-512"] | None = None, + sasl_plain_username: str | None = None, + sasl_plain_password: str | None = None, + sasl_kerberos_name: object | None = None, + sasl_kerberos_service_name: str = "kafka", + sasl_kerberos_domain_name: str | None = None, + sasl_oauth_token_provider: object | None = None, + proxy_url: str | None = None, + socks5_proxy: str | None = None, + kafka_client: Callable[..., object] = ..., + ) -> None: ... + def bootstrap_connected(self) -> bool: ... def __del__(self) -> None: ... + def __enter__(self) -> Self: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> None: ... def close(self, timeout: float | None = None, null_logger: bool = False) -> None: ... def partitions_for(self, topic: str) -> set[int]: ... @classmethod @@ -93,7 +92,7 @@ class KafkaProducer: def init_transactions(self) -> None: ... def begin_transaction(self) -> None: ... def send_offsets_to_transaction( - self, offsets: Mapping[TopicPartition, OffsetAndMetadata], consumer_group_id: str + self, offsets: Mapping[TopicPartition, OffsetAndMetadata], group_metadata: str | ConsumerGroupMetadata ) -> None: ... def commit_transaction(self) -> None: ... def abort_transaction(self) -> None: ... diff --git a/stubs/kafka-python/kafka/producer/producer_batch.pyi b/stubs/kafka-python/kafka/producer/producer_batch.pyi index 6b94289a53dd..dc6d522e3028 100644 --- a/stubs/kafka-python/kafka/producer/producer_batch.pyi +++ b/stubs/kafka-python/kafka/producer/producer_batch.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete from enum import IntEnum -log: Incomplete +from kafka.producer.future import FutureProduceResult class FinalState(IntEnum): ABORTED = 0 @@ -10,15 +10,15 @@ class FinalState(IntEnum): class ProducerBatch: max_record_size: int - created: Incomplete - drained: Incomplete + created: float + drained: Incomplete | None attempts: int - last_attempt: Incomplete - last_append: Incomplete + last_attempt: float + last_append: float records: Incomplete topic_partition: Incomplete - produce_future: Incomplete - def __init__(self, tp, records, now=None) -> None: ... + produce_future: FutureProduceResult + def __init__(self, tp, records, now: float | None = None) -> None: ... @property def final_state(self): ... @property @@ -28,15 +28,17 @@ class ProducerBatch: @property def producer_epoch(self): ... @property - def has_sequence(self): ... + def base_sequence(self): ... + @property + def has_sequence(self) -> bool: ... def try_append(self, timestamp_ms, key, value, headers, now=None): ... - def abort(self, exception): ... - def complete(self, base_offset, log_append_time): ... - def complete_exceptionally(self, top_level_exception, record_exceptions_fn): ... - def done(self, base_offset=None, timestamp_ms=None, top_level_exception=None, record_exceptions_fn=None): ... - def has_reached_delivery_timeout(self, delivery_timeout_ms, now=None): ... - def in_retry(self): ... + def abort(self, exception) -> None: ... + def complete(self, base_offset, log_append_time) -> bool: ... + def complete_exceptionally(self, top_level_exception, record_exceptions_fn) -> bool: ... + def done(self, base_offset=None, timestamp_ms=None, top_level_exception=None, record_exceptions_fn=None) -> bool: ... + def has_reached_delivery_timeout(self, delivery_timeout_ms, now=None) -> bool: ... + def in_retry(self) -> bool: ... def retry(self, now=None) -> None: ... @property - def is_done(self): ... - def __lt__(self, other): ... + def is_done(self) -> bool: ... + def __lt__(self, other) -> bool: ... diff --git a/stubs/kafka-python/kafka/producer/record_accumulator.pyi b/stubs/kafka-python/kafka/producer/record_accumulator.pyi index cb36265f18d5..23b060c00a16 100644 --- a/stubs/kafka-python/kafka/producer/record_accumulator.pyi +++ b/stubs/kafka-python/kafka/producer/record_accumulator.pyi @@ -1,7 +1,5 @@ from _typeshed import Incomplete -log: Incomplete - class AtomicInteger: def __init__(self, val: int = 0) -> None: ... def increment(self): ... @@ -9,30 +7,32 @@ class AtomicInteger: def get(self): ... class RecordAccumulator: - DEFAULT_CONFIG: Incomplete - config: Incomplete - muted: Incomplete + DEFAULT_CONFIG: dict[str, Incomplete] + config: dict[str, Incomplete] + muted: set[Incomplete] def __init__(self, **configs) -> None: ... @property def delivery_timeout_ms(self): ... @property - def next_expiry_time_ms(self): ... - def append(self, tp, timestamp_ms, key, value, headers, now=None): ... + def next_expiry_time_ms(self) -> float: ... + def append(self, tp, timestamp_ms, key, value, headers, now: float | None = None, abort_on_new_batch: bool = False): ... def reset_next_batch_expiry_time(self) -> None: ... def maybe_update_next_batch_expiry_time(self, batch) -> None: ... - def expired_batches(self, now=None): ... + def expired_batches(self, now=None) -> list[Incomplete]: ... + def split_and_reenqueue(self, batch, now: float | None = None) -> int: ... def reenqueue(self, batch, now=None) -> None: ... - def ready(self, cluster, now=None): ... - def has_undrained(self): ... - def drain_batches_for_one_node(self, cluster, node_id, max_size, now=None): ... - def drain(self, cluster, nodes, max_size, now=None): ... + def ready(self, cluster, now: float | None = None): ... + def has_undrained(self) -> bool: ... + def drain_batches_for_one_node(self, cluster, node_id, max_size, now: float | None = None) -> list[Incomplete]: ... + def drain(self, cluster, nodes, max_size, now: float | None = None): ... def deallocate(self, batch) -> None: ... - def flush_in_progress(self): ... + def flush_in_progress(self) -> bool: ... def begin_flush(self) -> None: ... def await_flush_completion(self, timeout=None) -> None: ... @property - def has_incomplete(self): ... + def has_incomplete(self) -> bool: ... def abort_incomplete_batches(self) -> None: ... + def abort_batches(self, error) -> None: ... def abort_undrained_batches(self, error) -> None: ... def close(self) -> None: ... @@ -40,6 +40,6 @@ class IncompleteProducerBatches: def __init__(self) -> None: ... def add(self, batch) -> None: ... def remove(self, batch) -> None: ... - def all(self): ... + def all(self) -> list[Incomplete]: ... def __bool__(self) -> bool: ... __nonzero__ = __bool__ diff --git a/stubs/kafka-python/kafka/producer/sender.pyi b/stubs/kafka-python/kafka/producer/sender.pyi index abbb22aac1d7..b50b36d34b16 100644 --- a/stubs/kafka-python/kafka/producer/sender.pyi +++ b/stubs/kafka-python/kafka/producer/sender.pyi @@ -1,22 +1,9 @@ import threading from _typeshed import Incomplete -from typing import NamedTuple - -log: Incomplete - -class PartitionResponse(NamedTuple): - error: Incomplete = ... - base_offset: Incomplete = ... - last_offset: Incomplete = ... - log_append_time: Incomplete = ... - log_start_offset: Incomplete = ... - record_errors: Incomplete = ... - error_message: Incomplete = ... - current_leader: Incomplete = ... class Sender(threading.Thread): - DEFAULT_CONFIG: Incomplete - config: Incomplete + DEFAULT_CONFIG: dict[str, Incomplete] + config: dict[str, Incomplete] name: Incomplete def __init__(self, client, metadata, accumulator, **configs) -> None: ... def run(self) -> None: ... @@ -41,7 +28,7 @@ class SenderMetrics: def add_metric( self, metric_name, measurable, group_name: str = "producer-metrics", description=None, tags=None, sensor_name=None ) -> None: ... - def maybe_register_topic_metrics(self, topic): ... + def maybe_register_topic_metrics(self, topic) -> None: ... def update_produce_request_metrics(self, batches_map) -> None: ... def record_retries(self, topic, count) -> None: ... def record_errors(self, topic, count) -> None: ... diff --git a/stubs/kafka-python/kafka/producer/transaction_manager.pyi b/stubs/kafka-python/kafka/producer/transaction_manager.pyi index 7e6f3e0374f0..5a478e3ad144 100644 --- a/stubs/kafka-python/kafka/producer/transaction_manager.pyi +++ b/stubs/kafka-python/kafka/producer/transaction_manager.pyi @@ -1,13 +1,17 @@ import abc from _typeshed import Incomplete from enum import IntEnum +from typing import Final, Literal -log: Incomplete -NO_PRODUCER_ID: int -NO_PRODUCER_EPOCH: int -NO_SEQUENCE: int +from kafka.protocol.producer import InitProducerIdRequest +from kafka.structs import ConsumerGroupMetadata + +NO_PRODUCER_ID: Final = -1 +NO_PRODUCER_EPOCH: Final = -1 +NO_SEQUENCE: Final = -1 class ProducerIdAndEpoch: + __slots__ = ("producer_id", "epoch") producer_id: Incomplete epoch: Incomplete def __init__(self, producer_id, epoch) -> None: ... @@ -25,6 +29,7 @@ class TransactionState(IntEnum): ABORTING_TRANSACTION = 5 ABORTABLE_ERROR = 6 FATAL_ERROR = 7 + BUMPING_PRODUCER_EPOCH = 8 @classmethod def is_transition_valid(cls, source, target): ... @@ -50,30 +55,44 @@ class TransactionManager: metadata=None, ) -> None: ... def initialize_transactions(self): ... + def init_producer_id(self) -> None: ... def begin_transaction(self) -> None: ... def begin_commit(self): ... def begin_abort(self): ... - def send_offsets_to_transaction(self, offsets, consumer_group_id): ... + def send_offsets_to_transaction(self, offsets, group_metadata: str | ConsumerGroupMetadata): ... def maybe_add_partition_to_transaction(self, topic_partition) -> None: ... def is_send_to_partition_allowed(self, tp): ... - def has_producer_id(self, producer_id=None): ... - def is_transactional(self): ... - def has_partitions_to_add(self): ... - def is_completing(self): ... + def has_producer_id(self, producer_id=None) -> bool: ... + def is_transactional(self) -> bool: ... + def has_partitions_to_add(self) -> bool: ... + def is_completing(self) -> bool: ... @property def last_error(self): ... - def has_error(self): ... - def is_aborting(self): ... + def has_error(self) -> bool: ... + def is_bumping_epoch(self) -> bool: ... + ERROR_CLASS_RETRIABLE: Final = "RETRIABLE" + ERROR_CLASS_ABORTABLE: Final = "ABORTABLE" + ERROR_CLASS_FATAL: Final = "FATAL" + ERROR_CLASS_NEEDS_EPOCH_BUMP: Final = "NEEDS_EPOCH_BUMP" + ERROR_CLASS_NEEDS_PRODUCER_ID_RESET: Final = "NEEDS_PRODUCER_ID_RESET" + def classify_batch_error( + self, error, batch, log_start_offset=-1 + ) -> Literal["FATAL", "RETRIABLE", "NEEDS_EPOCH_BUMP", "NEEDS_PRODUCER_ID_RESET", "ABORTABLE"]: ... + def is_aborting(self) -> bool: ... def transition_to_abortable_error(self, exc) -> None: ... def transition_to_fatal_error(self, exc) -> None: ... - def is_partition_added(self, partition): ... - def is_partition_pending_add(self, partition): ... - def has_producer_id_and_epoch(self, producer_id, producer_epoch): ... + def is_partition_added(self, partition) -> bool: ... + def is_partition_pending_add(self, partition) -> bool: ... + def has_producer_id_and_epoch(self, producer_id, producer_epoch) -> bool: ... def set_producer_id_and_epoch(self, producer_id_and_epoch) -> None: ... def reset_producer_id(self) -> None: ... + def bump_producer_id_and_epoch(self) -> None: ... def sequence_number(self, tp): ... def increment_sequence_number(self, tp, increment) -> None: ... + def set_sequence_number(self, tp, sequence) -> None: ... def reset_sequence_for_partition(self, tp) -> None: ... + def update_last_acked_offset(self, tp, base_offset, record_count) -> None: ... + def last_acked_offset(self, tp): ... def next_request_handler(self, has_incomplete_batches): ... def retry(self, request) -> None: ... def authentication_failed(self, exc) -> None: ... @@ -131,10 +150,12 @@ class TxnRequestHandler(metaclass=abc.ABCMeta): def priority(self): ... class InitProducerIdHandler(TxnRequestHandler): - request: Incomplete - def __init__(self, transaction_manager, transaction_timeout_ms) -> None: ... + request: InitProducerIdRequest + def __init__(self, transaction_manager, transaction_timeout_ms, is_epoch_bump: bool = False) -> None: ... @property def priority(self): ... + @property + def coordinator_type(self): ... def handle_response(self, response) -> None: ... class AddPartitionsToTxnHandler(TxnRequestHandler): @@ -165,19 +186,21 @@ class EndTxnHandler(TxnRequestHandler): def handle_response(self, response) -> None: ... class AddOffsetsToTxnHandler(TxnRequestHandler): + group_metadata: Incomplete consumer_group_id: Incomplete offsets: Incomplete request: Incomplete - def __init__(self, transaction_manager, consumer_group_id, offsets) -> None: ... + def __init__(self, transaction_manager, group_metadata, offsets) -> None: ... @property def priority(self): ... def handle_response(self, response) -> None: ... class TxnOffsetCommitHandler(TxnRequestHandler): + group_metadata: Incomplete consumer_group_id: Incomplete offsets: Incomplete request: Incomplete - def __init__(self, transaction_manager, consumer_group_id, offsets, result) -> None: ... + def __init__(self, transaction_manager, group_metadata, offsets, result) -> None: ... @property def priority(self): ... @property diff --git a/stubs/kafka-python/kafka/protocol/__init__.pyi b/stubs/kafka-python/kafka/protocol/__init__.pyi index da1238775e56..e69de29bb2d1 100644 --- a/stubs/kafka-python/kafka/protocol/__init__.pyi +++ b/stubs/kafka-python/kafka/protocol/__init__.pyi @@ -1,3 +0,0 @@ -from _typeshed import Incomplete - -API_KEYS: Incomplete diff --git a/stubs/kafka-python/kafka/protocol/admin/__init__.pyi b/stubs/kafka-python/kafka/protocol/admin/__init__.pyi new file mode 100644 index 000000000000..9e292518cbbc --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/admin/__init__.pyi @@ -0,0 +1,76 @@ +from .acl import * +from .client_quotas import * +from .cluster import * +from .configs import * +from .groups import * +from .topics import * +from .transactions import * +from .users import * + +__all__ = [ + "CreateAclsRequest", + "CreateAclsResponse", + "DeleteAclsRequest", + "DeleteAclsResponse", + "DescribeAclsRequest", + "DescribeAclsResponse", + "ACLResourceType", + "ACLOperation", + "ACLPermissionType", + "ACLResourcePatternType", + "AlterClientQuotasRequest", + "AlterClientQuotasResponse", + "DescribeClientQuotasRequest", + "DescribeClientQuotasResponse", + "DescribeClusterRequest", + "DescribeClusterResponse", + "DescribeLogDirsRequest", + "DescribeLogDirsResponse", + "AlterReplicaLogDirsRequest", + "AlterReplicaLogDirsResponse", + "DescribeQuorumRequest", + "DescribeQuorumResponse", + "UpdateFeaturesRequest", + "UpdateFeaturesResponse", + "AlterConfigsRequest", + "AlterConfigsResponse", + "DescribeConfigsRequest", + "DescribeConfigsResponse", + "IncrementalAlterConfigsRequest", + "IncrementalAlterConfigsResponse", + "ListConfigResourcesRequest", + "ListConfigResourcesResponse", + "DescribeGroupsRequest", + "DescribeGroupsResponse", + "ListGroupsRequest", + "ListGroupsResponse", + "DeleteGroupsRequest", + "DeleteGroupsResponse", + "CreateTopicsRequest", + "CreateTopicsResponse", + "DeleteTopicsRequest", + "DeleteTopicsResponse", + "CreatePartitionsRequest", + "CreatePartitionsResponse", + "AlterPartitionReassignmentsRequest", + "AlterPartitionReassignmentsResponse", + "ListPartitionReassignmentsRequest", + "ListPartitionReassignmentsResponse", + "DescribeTopicPartitionsRequest", + "DescribeTopicPartitionsResponse", + "DeleteRecordsRequest", + "DeleteRecordsResponse", + "ElectLeadersRequest", + "ElectLeadersResponse", + "ElectionType", + "ListTransactionsRequest", + "ListTransactionsResponse", + "DescribeTransactionsRequest", + "DescribeTransactionsResponse", + "DescribeProducersRequest", + "DescribeProducersResponse", + "AlterUserScramCredentialsRequest", + "AlterUserScramCredentialsResponse", + "DescribeUserScramCredentialsRequest", + "DescribeUserScramCredentialsResponse", +] diff --git a/stubs/kafka-python/kafka/protocol/admin/acl.pyi b/stubs/kafka-python/kafka/protocol/admin/acl.pyi new file mode 100644 index 000000000000..a29c2ea590e9 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/admin/acl.pyi @@ -0,0 +1,362 @@ +from _typeshed import Incomplete +from enum import IntEnum + +from kafka.protocol.api_message import ApiMessage +from kafka.protocol.data_container import DataContainer + +class CreateAclsRequest(ApiMessage): + class AclCreation(DataContainer): + resource_type: int + resource_name: str + resource_pattern_type: int + principal: str + host: str + operation: int + permission_type: int + def __init__( + self, + *args, + resource_type: int = ..., + resource_name: str = ..., + resource_pattern_type: int = ..., + principal: str = ..., + host: str = ..., + operation: int = ..., + permission_type: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + creations: list[AclCreation] + def __init__(self, *args, creations: list[AclCreation] = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class CreateAclsResponse(ApiMessage): + class AclCreationResult(DataContainer): + error_code: int + error_message: str | None + def __init__( + self, *args, error_code: int = ..., error_message: str | None = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + results: list[AclCreationResult] + def __init__( + self, *args, throttle_time_ms: int = ..., results: list[AclCreationResult] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DeleteAclsRequest(ApiMessage): + class DeleteAclsFilter(DataContainer): + resource_type_filter: int + resource_name_filter: str | None + pattern_type_filter: int + principal_filter: str | None + host_filter: str | None + operation: int + permission_type: int + def __init__( + self, + *args, + resource_type_filter: int = ..., + resource_name_filter: str | None = ..., + pattern_type_filter: int = ..., + principal_filter: str | None = ..., + host_filter: str | None = ..., + operation: int = ..., + permission_type: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + filters: list[DeleteAclsFilter] + def __init__(self, *args, filters: list[DeleteAclsFilter] = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DeleteAclsResponse(ApiMessage): + class DeleteAclsFilterResult(DataContainer): + class DeleteAclsMatchingAcl(DataContainer): + error_code: int + error_message: str | None + resource_type: int + resource_name: str + pattern_type: int + principal: str + host: str + operation: int + permission_type: int + def __init__( + self, + *args, + error_code: int = ..., + error_message: str | None = ..., + resource_type: int = ..., + resource_name: str = ..., + pattern_type: int = ..., + principal: str = ..., + host: str = ..., + operation: int = ..., + permission_type: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + error_code: int + error_message: str | None + matching_acls: list[DeleteAclsMatchingAcl] + def __init__( + self, + *args, + error_code: int = ..., + error_message: str | None = ..., + matching_acls: list[DeleteAclsMatchingAcl] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + filter_results: list[DeleteAclsFilterResult] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + filter_results: list[DeleteAclsFilterResult] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DescribeAclsRequest(ApiMessage): + resource_type_filter: int + resource_name_filter: str | None + pattern_type_filter: int + principal_filter: str | None + host_filter: str | None + operation: int + permission_type: int + def __init__( + self, + *args, + resource_type_filter: int = ..., + resource_name_filter: str | None = ..., + pattern_type_filter: int = ..., + principal_filter: str | None = ..., + host_filter: str | None = ..., + operation: int = ..., + permission_type: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DescribeAclsResponse(ApiMessage): + class DescribeAclsResource(DataContainer): + class AclDescription(DataContainer): + principal: str + host: str + operation: int + permission_type: int + def __init__( + self, + *args, + principal: str = ..., + host: str = ..., + operation: int = ..., + permission_type: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + resource_type: int + resource_name: str + pattern_type: int + acls: list[AclDescription] + def __init__( + self, + *args, + resource_type: int = ..., + resource_name: str = ..., + pattern_type: int = ..., + acls: list[AclDescription] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + error_code: int + error_message: str | None + resources: list[DescribeAclsResource] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + error_code: int = ..., + error_message: str | None = ..., + resources: list[DescribeAclsResource] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class ACLResourceType(IntEnum): + UNKNOWN = 0 + ANY = 1 + TOPIC = 2 + GROUP = 3 + CLUSTER = 4 + TRANSACTIONAL_ID = 5 + DELEGATION_TOKEN = 6 + +class ACLOperation(IntEnum): + UNKNOWN = 0 + ANY = 1 + ALL = 2 + READ = 3 + WRITE = 4 + CREATE = 5 + DELETE = 6 + ALTER = 7 + DESCRIBE = 8 + CLUSTER_ACTION = 9 + DESCRIBE_CONFIGS = 10 + ALTER_CONFIGS = 11 + IDEMPOTENT_WRITE = 12 + CREATE_TOKENS = 13 + DESCRIBE_TOKENS = 14 + +class ACLPermissionType(IntEnum): + UNKNOWN = 0 + ANY = 1 + DENY = 2 + ALLOW = 3 + +class ACLResourcePatternType(IntEnum): + UNKNOWN = 0 + ANY = 1 + MATCH = 2 + LITERAL = 3 + PREFIXED = 4 + +__all__ = [ + "CreateAclsRequest", + "CreateAclsResponse", + "DeleteAclsRequest", + "DeleteAclsResponse", + "DescribeAclsRequest", + "DescribeAclsResponse", + "ACLResourceType", + "ACLOperation", + "ACLPermissionType", + "ACLResourcePatternType", +] diff --git a/stubs/kafka-python/kafka/protocol/admin/client_quotas.pyi b/stubs/kafka-python/kafka/protocol/admin/client_quotas.pyi new file mode 100644 index 000000000000..1580153547ee --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/admin/client_quotas.pyi @@ -0,0 +1,210 @@ +from _typeshed import Incomplete + +from kafka.protocol.api_message import ApiMessage +from kafka.protocol.data_container import DataContainer + +class AlterClientQuotasRequest(ApiMessage): + class EntryData(DataContainer): + class EntityData(DataContainer): + entity_type: str + entity_name: str | None + def __init__( + self, *args, entity_type: str = ..., entity_name: str | None = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class OpData(DataContainer): + key: str + value: float + remove: bool + def __init__( + self, *args, key: str = ..., value: float = ..., remove: bool = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + entity: list[EntityData] + ops: list[OpData] + def __init__( + self, *args, entity: list[EntityData] = ..., ops: list[OpData] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + entries: list[EntryData] + validate_only: bool + def __init__( + self, *args, entries: list[EntryData] = ..., validate_only: bool = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class AlterClientQuotasResponse(ApiMessage): + class EntryData(DataContainer): + class EntityData(DataContainer): + entity_type: str + entity_name: str | None + def __init__( + self, *args, entity_type: str = ..., entity_name: str | None = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + error_code: int + error_message: str | None + entity: list[EntityData] + def __init__( + self, + *args, + error_code: int = ..., + error_message: str | None = ..., + entity: list[EntityData] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + entries: list[EntryData] + def __init__( + self, *args, throttle_time_ms: int = ..., entries: list[EntryData] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DescribeClientQuotasRequest(ApiMessage): + class ComponentData(DataContainer): + entity_type: str + match_type: int + match: str | None + def __init__( + self, + *args, + entity_type: str = ..., + match_type: int = ..., + match: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + components: list[ComponentData] + strict: bool + def __init__( + self, *args, components: list[ComponentData] = ..., strict: bool = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DescribeClientQuotasResponse(ApiMessage): + class EntryData(DataContainer): + class EntityData(DataContainer): + entity_type: str + entity_name: str | None + def __init__( + self, *args, entity_type: str = ..., entity_name: str | None = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class ValueData(DataContainer): + key: str + value: float + def __init__(self, *args, key: str = ..., value: float = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + entity: list[EntityData] + values: list[ValueData] + def __init__( + self, *args, entity: list[EntityData] = ..., values: list[ValueData] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + error_code: int + error_message: str | None + entries: list[EntryData] | None + def __init__( + self, + *args, + throttle_time_ms: int = ..., + error_code: int = ..., + error_message: str | None = ..., + entries: list[EntryData] | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +__all__ = ["AlterClientQuotasRequest", "AlterClientQuotasResponse", "DescribeClientQuotasRequest", "DescribeClientQuotasResponse"] diff --git a/stubs/kafka-python/kafka/protocol/admin/cluster.pyi b/stubs/kafka-python/kafka/protocol/admin/cluster.pyi new file mode 100644 index 000000000000..af25aae69210 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/admin/cluster.pyi @@ -0,0 +1,569 @@ +import uuid +from _typeshed import Incomplete + +from kafka.protocol.api_message import ApiMessage +from kafka.protocol.data_container import DataContainer + +class DescribeClusterRequest(ApiMessage): + include_cluster_authorized_operations: bool + endpoint_type: int + include_fenced_brokers: bool + def __init__( + self, + *args, + include_cluster_authorized_operations: bool = ..., + endpoint_type: int = ..., + include_fenced_brokers: bool = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DescribeClusterResponse(ApiMessage): + class DescribeClusterBroker(DataContainer): + broker_id: int + host: str + port: int + rack: str | None + is_fenced: bool + def __init__( + self, + *args, + broker_id: int = ..., + host: str = ..., + port: int = ..., + rack: str | None = ..., + is_fenced: bool = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + error_code: int + error_message: str | None + endpoint_type: int + cluster_id: str + controller_id: int + brokers: list[DescribeClusterBroker] + authorized_operations: set[int] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + error_code: int = ..., + error_message: str | None = ..., + endpoint_type: int = ..., + cluster_id: str = ..., + controller_id: int = ..., + brokers: list[DescribeClusterBroker] = ..., + authorized_operations: set[int] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + @classmethod + def json_patch(cls, json): ... + +class DescribeLogDirsRequest(ApiMessage): + class DescribableLogDirTopic(DataContainer): + topic: str + partitions: list[int] + def __init__( + self, *args, topic: str = ..., partitions: list[int] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + topics: list[DescribableLogDirTopic] | None + def __init__( + self, *args, topics: list[DescribableLogDirTopic] | None = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DescribeLogDirsResponse(ApiMessage): + class DescribeLogDirsResult(DataContainer): + class DescribeLogDirsTopic(DataContainer): + class DescribeLogDirsPartition(DataContainer): + partition_index: int + partition_size: int + offset_lag: int + is_future_key: bool + def __init__( + self, + *args, + partition_index: int = ..., + partition_size: int = ..., + offset_lag: int = ..., + is_future_key: bool = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + partitions: list[DescribeLogDirsPartition] + def __init__( + self, + *args, + name: str = ..., + partitions: list[DescribeLogDirsPartition] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + error_code: int + log_dir: str + topics: list[DescribeLogDirsTopic] + total_bytes: int + usable_bytes: int + is_cordoned: bool + def __init__( + self, + *args, + error_code: int = ..., + log_dir: str = ..., + topics: list[DescribeLogDirsTopic] = ..., + total_bytes: int = ..., + usable_bytes: int = ..., + is_cordoned: bool = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + error_code: int + results: list[DescribeLogDirsResult] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + error_code: int = ..., + results: list[DescribeLogDirsResult] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class AlterReplicaLogDirsRequest(ApiMessage): + class AlterReplicaLogDir(DataContainer): + class AlterReplicaLogDirTopic(DataContainer): + name: str + partitions: list[int] + def __init__( + self, *args, name: str = ..., partitions: list[int] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + path: str + topics: list[AlterReplicaLogDirTopic] + def __init__( + self, *args, path: str = ..., topics: list[AlterReplicaLogDirTopic] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + dirs: list[AlterReplicaLogDir] + def __init__(self, *args, dirs: list[AlterReplicaLogDir] = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class AlterReplicaLogDirsResponse(ApiMessage): + class AlterReplicaLogDirTopicResult(DataContainer): + class AlterReplicaLogDirPartitionResult(DataContainer): + partition_index: int + error_code: int + def __init__( + self, *args, partition_index: int = ..., error_code: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + topic_name: str + partitions: list[AlterReplicaLogDirPartitionResult] + def __init__( + self, + *args, + topic_name: str = ..., + partitions: list[AlterReplicaLogDirPartitionResult] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + results: list[AlterReplicaLogDirTopicResult] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + results: list[AlterReplicaLogDirTopicResult] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DescribeQuorumRequest(ApiMessage): + class TopicData(DataContainer): + class PartitionData(DataContainer): + partition_index: int + def __init__(self, *args, partition_index: int = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + topic_name: str + partitions: list[PartitionData] + def __init__( + self, *args, topic_name: str = ..., partitions: list[PartitionData] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + topics: list[TopicData] + def __init__(self, *args, topics: list[TopicData] = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DescribeQuorumResponse(ApiMessage): + class TopicData(DataContainer): + class PartitionData(DataContainer): + class ReplicaState(DataContainer): + replica_id: int + replica_directory_id: uuid.UUID + log_end_offset: int + last_fetch_timestamp: int + last_caught_up_timestamp: int + def __init__( + self, + *args, + replica_id: int = ..., + replica_directory_id: uuid.UUID = ..., + log_end_offset: int = ..., + last_fetch_timestamp: int = ..., + last_caught_up_timestamp: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + partition_index: int + error_code: int + error_message: str | None + leader_id: int + leader_epoch: int + high_watermark: int + current_voters: list[ReplicaState] + observers: list[ReplicaState] + def __init__( + self, + *args, + partition_index: int = ..., + error_code: int = ..., + error_message: str | None = ..., + leader_id: int = ..., + leader_epoch: int = ..., + high_watermark: int = ..., + current_voters: list[ReplicaState] = ..., + observers: list[ReplicaState] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + topic_name: str + partitions: list[PartitionData] + def __init__( + self, *args, topic_name: str = ..., partitions: list[PartitionData] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class Node(DataContainer): + class Listener(DataContainer): + name: str + host: str + port: int + def __init__( + self, *args, name: str = ..., host: str = ..., port: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + node_id: int + listeners: list[Listener] + def __init__( + self, *args, node_id: int = ..., listeners: list[Listener] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + error_code: int + error_message: str | None + topics: list[TopicData] + nodes: list[Node] + def __init__( + self, + *args, + error_code: int = ..., + error_message: str | None = ..., + topics: list[TopicData] = ..., + nodes: list[Node] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class UpdateFeaturesRequest(ApiMessage): + class FeatureUpdateKey(DataContainer): + feature: str + max_version_level: int + allow_downgrade: bool + upgrade_type: int + def __init__( + self, + *args, + feature: str = ..., + max_version_level: int = ..., + allow_downgrade: bool = ..., + upgrade_type: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + timeout_ms: int + feature_updates: list[FeatureUpdateKey] + validate_only: bool + def __init__( + self, + *args, + timeout_ms: int = ..., + feature_updates: list[FeatureUpdateKey] = ..., + validate_only: bool = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class UpdateFeaturesResponse(ApiMessage): + class UpdatableFeatureResult(DataContainer): + feature: str + error_code: int + error_message: str | None + def __init__( + self, + *args, + feature: str = ..., + error_code: int = ..., + error_message: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + error_code: int + error_message: str | None + results: list[UpdatableFeatureResult] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + error_code: int = ..., + error_message: str | None = ..., + results: list[UpdatableFeatureResult] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +__all__ = [ + "DescribeClusterRequest", + "DescribeClusterResponse", + "DescribeLogDirsRequest", + "DescribeLogDirsResponse", + "AlterReplicaLogDirsRequest", + "AlterReplicaLogDirsResponse", + "DescribeQuorumRequest", + "DescribeQuorumResponse", + "UpdateFeaturesRequest", + "UpdateFeaturesResponse", +] diff --git a/stubs/kafka-python/kafka/protocol/admin/configs.pyi b/stubs/kafka-python/kafka/protocol/admin/configs.pyi new file mode 100644 index 000000000000..fe32bcb42d39 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/admin/configs.pyi @@ -0,0 +1,405 @@ +from _typeshed import Incomplete + +from kafka.protocol.api_message import ApiMessage +from kafka.protocol.data_container import DataContainer + +class AlterConfigsRequest(ApiMessage): + class AlterConfigsResource(DataContainer): + class AlterableConfig(DataContainer): + name: str + value: str | None + def __init__(self, *args, name: str = ..., value: str | None = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + resource_type: int + resource_name: str + configs: list[AlterableConfig] + def __init__( + self, + *args, + resource_type: int = ..., + resource_name: str = ..., + configs: list[AlterableConfig] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + resources: list[AlterConfigsResource] + validate_only: bool + def __init__( + self, *args, resources: list[AlterConfigsResource] = ..., validate_only: bool = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class AlterConfigsResponse(ApiMessage): + class AlterConfigsResourceResponse(DataContainer): + error_code: int + error_message: str | None + resource_type: int + resource_name: str + def __init__( + self, + *args, + error_code: int = ..., + error_message: str | None = ..., + resource_type: int = ..., + resource_name: str = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + responses: list[AlterConfigsResourceResponse] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + responses: list[AlterConfigsResourceResponse] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DescribeConfigsRequest(ApiMessage): + class DescribeConfigsResource(DataContainer): + resource_type: int + resource_name: str + configuration_keys: list[str] | None + def __init__( + self, + *args, + resource_type: int = ..., + resource_name: str = ..., + configuration_keys: list[str] | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + resources: list[DescribeConfigsResource] + include_synonyms: bool + include_documentation: bool + def __init__( + self, + *args, + resources: list[DescribeConfigsResource] = ..., + include_synonyms: bool = ..., + include_documentation: bool = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DescribeConfigsResponse(ApiMessage): + class DescribeConfigsResult(DataContainer): + class DescribeConfigsResourceResult(DataContainer): + class DescribeConfigsSynonym(DataContainer): + name: str + value: str | None + source: int + def __init__( + self, *args, name: str = ..., value: str | None = ..., source: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + value: str | None + read_only: bool + config_source: int + is_default: bool + is_sensitive: bool + synonyms: list[DescribeConfigsSynonym] + config_type: int + documentation: str | None + def __init__( + self, + *args, + name: str = ..., + value: str | None = ..., + read_only: bool = ..., + config_source: int = ..., + is_default: bool = ..., + is_sensitive: bool = ..., + synonyms: list[DescribeConfigsSynonym] = ..., + config_type: int = ..., + documentation: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + error_code: int + error_message: str | None + resource_type: int + resource_name: str + configs: list[DescribeConfigsResourceResult] + def __init__( + self, + *args, + error_code: int = ..., + error_message: str | None = ..., + resource_type: int = ..., + resource_name: str = ..., + configs: list[DescribeConfigsResourceResult] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + results: list[DescribeConfigsResult] + def __init__( + self, *args, throttle_time_ms: int = ..., results: list[DescribeConfigsResult] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class IncrementalAlterConfigsRequest(ApiMessage): + class AlterConfigsResource(DataContainer): + class AlterableConfig(DataContainer): + name: str + config_operation: int + value: str | None + def __init__( + self, + *args, + name: str = ..., + config_operation: int = ..., + value: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + resource_type: int + resource_name: str + configs: list[AlterableConfig] + def __init__( + self, + *args, + resource_type: int = ..., + resource_name: str = ..., + configs: list[AlterableConfig] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + resources: list[AlterConfigsResource] + validate_only: bool + def __init__( + self, *args, resources: list[AlterConfigsResource] = ..., validate_only: bool = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class IncrementalAlterConfigsResponse(ApiMessage): + class AlterConfigsResourceResponse(DataContainer): + error_code: int + error_message: str | None + resource_type: int + resource_name: str + def __init__( + self, + *args, + error_code: int = ..., + error_message: str | None = ..., + resource_type: int = ..., + resource_name: str = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + responses: list[AlterConfigsResourceResponse] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + responses: list[AlterConfigsResourceResponse] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class ListConfigResourcesRequest(ApiMessage): + resource_types: list[int] + def __init__(self, *args, resource_types: list[int] = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class ListConfigResourcesResponse(ApiMessage): + class ConfigResource(DataContainer): + resource_name: str + resource_type: int + def __init__( + self, *args, resource_name: str = ..., resource_type: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + error_code: int + config_resources: list[ConfigResource] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + error_code: int = ..., + config_resources: list[ConfigResource] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +__all__ = [ + "AlterConfigsRequest", + "AlterConfigsResponse", + "DescribeConfigsRequest", + "DescribeConfigsResponse", + "IncrementalAlterConfigsRequest", + "IncrementalAlterConfigsResponse", + "ListConfigResourcesRequest", + "ListConfigResourcesResponse", +] diff --git a/stubs/kafka-python/kafka/protocol/admin/groups.pyi b/stubs/kafka-python/kafka/protocol/admin/groups.pyi new file mode 100644 index 000000000000..7445f01664b3 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/admin/groups.pyi @@ -0,0 +1,235 @@ +from _typeshed import Incomplete + +from kafka.protocol.api_data import ApiData +from kafka.protocol.api_message import ApiMessage +from kafka.protocol.data_container import DataContainer + +class DescribeGroupsRequest(ApiMessage): + groups: list[str] + include_authorized_operations: bool + def __init__( + self, *args, groups: list[str] = ..., include_authorized_operations: bool = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DescribeGroupsResponse(ApiMessage): + class DescribedGroup(DataContainer): + class DescribedGroupMember(DataContainer): + member_id: str + group_instance_id: str | None + client_id: str + client_host: str + member_metadata: bytes | ApiData + member_assignment: bytes | ApiData + def __init__( + self, + *args, + member_id: str = ..., + group_instance_id: str | None = ..., + client_id: str = ..., + client_host: str = ..., + member_metadata: bytes | ApiData = ..., + member_assignment: bytes | ApiData = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + error_code: int + error_message: str | None + group_id: str + group_state: str + protocol_type: str + protocol_data: str + members: list[DescribedGroupMember] + authorized_operations: set[int] + def __init__( + self, + *args, + error_code: int = ..., + error_message: str | None = ..., + group_id: str = ..., + group_state: str = ..., + protocol_type: str = ..., + protocol_data: str = ..., + members: list[DescribedGroupMember] = ..., + authorized_operations: set[int] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + groups: list[DescribedGroup] + def __init__( + self, *args, throttle_time_ms: int = ..., groups: list[DescribedGroup] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + @classmethod + def json_patch(cls, json): ... + +class ListGroupsRequest(ApiMessage): + states_filter: list[str] + types_filter: list[str] + def __init__( + self, *args, states_filter: list[str] = ..., types_filter: list[str] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class ListGroupsResponse(ApiMessage): + class ListedGroup(DataContainer): + group_id: str + protocol_type: str + group_state: str + group_type: str + def __init__( + self, + *args, + group_id: str = ..., + protocol_type: str = ..., + group_state: str = ..., + group_type: str = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + error_code: int + groups: list[ListedGroup] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + error_code: int = ..., + groups: list[ListedGroup] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DeleteGroupsRequest(ApiMessage): + groups_names: list[str] + def __init__(self, *args, groups_names: list[str] = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DeleteGroupsResponse(ApiMessage): + class DeletableGroupResult(DataContainer): + group_id: str + error_code: int + def __init__(self, *args, group_id: str = ..., error_code: int = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + results: list[DeletableGroupResult] + def __init__( + self, *args, throttle_time_ms: int = ..., results: list[DeletableGroupResult] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +__all__ = [ + "DescribeGroupsRequest", + "DescribeGroupsResponse", + "ListGroupsRequest", + "ListGroupsResponse", + "DeleteGroupsRequest", + "DeleteGroupsResponse", +] diff --git a/stubs/kafka-python/kafka/protocol/admin/topics.pyi b/stubs/kafka-python/kafka/protocol/admin/topics.pyi new file mode 100644 index 000000000000..2d311854e3f7 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/admin/topics.pyi @@ -0,0 +1,916 @@ +import uuid +from _typeshed import Incomplete +from enum import IntEnum + +from kafka.protocol.api_message import ApiMessage +from kafka.protocol.data_container import DataContainer + +class CreateTopicsRequest(ApiMessage): + class CreatableTopic(DataContainer): + class CreatableReplicaAssignment(DataContainer): + partition_index: int + broker_ids: list[int] + def __init__( + self, *args, partition_index: int = ..., broker_ids: list[int] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class CreatableTopicConfig(DataContainer): + name: str + value: str | None + def __init__(self, *args, name: str = ..., value: str | None = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + num_partitions: int + replication_factor: int + assignments: list[CreatableReplicaAssignment] + configs: list[CreatableTopicConfig] + def __init__( + self, + *args, + name: str = ..., + num_partitions: int = ..., + replication_factor: int = ..., + assignments: list[CreatableReplicaAssignment] = ..., + configs: list[CreatableTopicConfig] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + topics: list[CreatableTopic] + timeout_ms: int + validate_only: bool + def __init__( + self, + *args, + topics: list[CreatableTopic] = ..., + timeout_ms: int = ..., + validate_only: bool = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class CreateTopicsResponse(ApiMessage): + class CreatableTopicResult(DataContainer): + class CreatableTopicConfigs(DataContainer): + name: str + value: str | None + read_only: bool + config_source: int + is_sensitive: bool + def __init__( + self, + *args, + name: str = ..., + value: str | None = ..., + read_only: bool = ..., + config_source: int = ..., + is_sensitive: bool = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + topic_id: uuid.UUID + error_code: int + error_message: str | None + topic_config_error_code: int + num_partitions: int + replication_factor: int + configs: list[CreatableTopicConfigs] | None + def __init__( + self, + *args, + name: str = ..., + topic_id: uuid.UUID = ..., + error_code: int = ..., + error_message: str | None = ..., + topic_config_error_code: int = ..., + num_partitions: int = ..., + replication_factor: int = ..., + configs: list[CreatableTopicConfigs] | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + topics: list[CreatableTopicResult] + def __init__( + self, *args, throttle_time_ms: int = ..., topics: list[CreatableTopicResult] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DeleteTopicsRequest(ApiMessage): + class DeleteTopicState(DataContainer): + name: str | None + topic_id: uuid.UUID + def __init__( + self, *args, name: str | None = ..., topic_id: uuid.UUID = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + topics: list[DeleteTopicState] + topic_names: list[str] + timeout_ms: int + def __init__( + self, + *args, + topics: list[DeleteTopicState] = ..., + topic_names: list[str] = ..., + timeout_ms: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + def encode(self, version=None, header=False, framed=False): ... + +class DeleteTopicsResponse(ApiMessage): + class DeletableTopicResult(DataContainer): + name: str | None + topic_id: uuid.UUID + error_code: int + error_message: str | None + def __init__( + self, + *args, + name: str | None = ..., + topic_id: uuid.UUID = ..., + error_code: int = ..., + error_message: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + responses: list[DeletableTopicResult] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + responses: list[DeletableTopicResult] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class CreatePartitionsRequest(ApiMessage): + class CreatePartitionsTopic(DataContainer): + class CreatePartitionsAssignment(DataContainer): + broker_ids: list[int] + def __init__(self, *args, broker_ids: list[int] = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + count: int + assignments: list[CreatePartitionsAssignment] | None + def __init__( + self, + *args, + name: str = ..., + count: int = ..., + assignments: list[CreatePartitionsAssignment] | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + topics: list[CreatePartitionsTopic] + timeout_ms: int + validate_only: bool + def __init__( + self, + *args, + topics: list[CreatePartitionsTopic] = ..., + timeout_ms: int = ..., + validate_only: bool = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class CreatePartitionsResponse(ApiMessage): + class CreatePartitionsTopicResult(DataContainer): + name: str + error_code: int + error_message: str | None + def __init__( + self, + *args, + name: str = ..., + error_code: int = ..., + error_message: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + results: list[CreatePartitionsTopicResult] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + results: list[CreatePartitionsTopicResult] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class AlterPartitionReassignmentsRequest(ApiMessage): + class ReassignableTopic(DataContainer): + class ReassignablePartition(DataContainer): + partition_index: int + replicas: list[int] | None + def __init__( + self, *args, partition_index: int = ..., replicas: list[int] | None = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + partitions: list[ReassignablePartition] + def __init__( + self, *args, name: str = ..., partitions: list[ReassignablePartition] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + timeout_ms: int + allow_replication_factor_change: bool + topics: list[ReassignableTopic] + def __init__( + self, + *args, + timeout_ms: int = ..., + allow_replication_factor_change: bool = ..., + topics: list[ReassignableTopic] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class AlterPartitionReassignmentsResponse(ApiMessage): + class ReassignableTopicResponse(DataContainer): + class ReassignablePartitionResponse(DataContainer): + partition_index: int + error_code: int + error_message: str | None + def __init__( + self, + *args, + partition_index: int = ..., + error_code: int = ..., + error_message: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + partitions: list[ReassignablePartitionResponse] + def __init__( + self, + *args, + name: str = ..., + partitions: list[ReassignablePartitionResponse] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + allow_replication_factor_change: bool + error_code: int + error_message: str | None + responses: list[ReassignableTopicResponse] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + allow_replication_factor_change: bool = ..., + error_code: int = ..., + error_message: str | None = ..., + responses: list[ReassignableTopicResponse] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class ListPartitionReassignmentsRequest(ApiMessage): + class ListPartitionReassignmentsTopics(DataContainer): + name: str + partition_indexes: list[int] + def __init__( + self, *args, name: str = ..., partition_indexes: list[int] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + timeout_ms: int + topics: list[ListPartitionReassignmentsTopics] | None + def __init__( + self, + *args, + timeout_ms: int = ..., + topics: list[ListPartitionReassignmentsTopics] | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class ListPartitionReassignmentsResponse(ApiMessage): + class OngoingTopicReassignment(DataContainer): + class OngoingPartitionReassignment(DataContainer): + partition_index: int + replicas: list[int] + adding_replicas: list[int] + removing_replicas: list[int] + def __init__( + self, + *args, + partition_index: int = ..., + replicas: list[int] = ..., + adding_replicas: list[int] = ..., + removing_replicas: list[int] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + partitions: list[OngoingPartitionReassignment] + def __init__( + self, + *args, + name: str = ..., + partitions: list[OngoingPartitionReassignment] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + error_code: int + error_message: str | None + topics: list[OngoingTopicReassignment] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + error_code: int = ..., + error_message: str | None = ..., + topics: list[OngoingTopicReassignment] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DescribeTopicPartitionsRequest(ApiMessage): + class TopicRequest(DataContainer): + name: str + def __init__(self, *args, name: str = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class Cursor(DataContainer): + topic_name: str + partition_index: int + def __init__( + self, *args, topic_name: str = ..., partition_index: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + topics: list[TopicRequest] + response_partition_limit: int + cursor: Cursor | None + def __init__( + self, + *args, + topics: list[TopicRequest] = ..., + response_partition_limit: int = ..., + cursor: Cursor | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DescribeTopicPartitionsResponse(ApiMessage): + class DescribeTopicPartitionsResponseTopic(DataContainer): + class DescribeTopicPartitionsResponsePartition(DataContainer): + error_code: int + partition_index: int + leader_id: int + leader_epoch: int + replica_nodes: list[int] + isr_nodes: list[int] + eligible_leader_replicas: list[int] | None + last_known_elr: list[int] | None + offline_replicas: list[int] + def __init__( + self, + *args, + error_code: int = ..., + partition_index: int = ..., + leader_id: int = ..., + leader_epoch: int = ..., + replica_nodes: list[int] = ..., + isr_nodes: list[int] = ..., + eligible_leader_replicas: list[int] | None = ..., + last_known_elr: list[int] | None = ..., + offline_replicas: list[int] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + error_code: int + name: str | None + topic_id: uuid.UUID + is_internal: bool + partitions: list[DescribeTopicPartitionsResponsePartition] + topic_authorized_operations: int + def __init__( + self, + *args, + error_code: int = ..., + name: str | None = ..., + topic_id: uuid.UUID = ..., + is_internal: bool = ..., + partitions: list[DescribeTopicPartitionsResponsePartition] = ..., + topic_authorized_operations: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class Cursor(DataContainer): + topic_name: str + partition_index: int + def __init__( + self, *args, topic_name: str = ..., partition_index: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + topics: list[DescribeTopicPartitionsResponseTopic] + next_cursor: Cursor | None + def __init__( + self, + *args, + throttle_time_ms: int = ..., + topics: list[DescribeTopicPartitionsResponseTopic] = ..., + next_cursor: Cursor | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DeleteRecordsRequest(ApiMessage): + class DeleteRecordsTopic(DataContainer): + class DeleteRecordsPartition(DataContainer): + partition_index: int + offset: int + def __init__( + self, *args, partition_index: int = ..., offset: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + partitions: list[DeleteRecordsPartition] + def __init__( + self, *args, name: str = ..., partitions: list[DeleteRecordsPartition] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + topics: list[DeleteRecordsTopic] + timeout_ms: int + def __init__( + self, *args, topics: list[DeleteRecordsTopic] = ..., timeout_ms: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DeleteRecordsResponse(ApiMessage): + class DeleteRecordsTopicResult(DataContainer): + class DeleteRecordsPartitionResult(DataContainer): + partition_index: int + low_watermark: int + error_code: int + def __init__( + self, + *args, + partition_index: int = ..., + low_watermark: int = ..., + error_code: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + partitions: list[DeleteRecordsPartitionResult] + def __init__( + self, + *args, + name: str = ..., + partitions: list[DeleteRecordsPartitionResult] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + topics: list[DeleteRecordsTopicResult] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + topics: list[DeleteRecordsTopicResult] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class ElectLeadersRequest(ApiMessage): + class TopicPartitions(DataContainer): + topic: str + partitions: list[int] + def __init__( + self, *args, topic: str = ..., partitions: list[int] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + election_type: int + topic_partitions: list[TopicPartitions] | None + timeout_ms: int + def __init__( + self, + *args, + election_type: int = ..., + topic_partitions: list[TopicPartitions] | None = ..., + timeout_ms: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class ElectLeadersResponse(ApiMessage): + class ReplicaElectionResult(DataContainer): + class PartitionResult(DataContainer): + partition_id: int + error_code: int + error_message: str | None + def __init__( + self, + *args, + partition_id: int = ..., + error_code: int = ..., + error_message: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + topic: str + partition_result: list[PartitionResult] + def __init__( + self, *args, topic: str = ..., partition_result: list[PartitionResult] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + error_code: int + replica_election_results: list[ReplicaElectionResult] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + error_code: int = ..., + replica_election_results: list[ReplicaElectionResult] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class ElectionType(IntEnum): + PREFERRED = 0 + UNCLEAN = 1 + +__all__ = [ + "CreateTopicsRequest", + "CreateTopicsResponse", + "DeleteTopicsRequest", + "DeleteTopicsResponse", + "CreatePartitionsRequest", + "CreatePartitionsResponse", + "AlterPartitionReassignmentsRequest", + "AlterPartitionReassignmentsResponse", + "ListPartitionReassignmentsRequest", + "ListPartitionReassignmentsResponse", + "DescribeTopicPartitionsRequest", + "DescribeTopicPartitionsResponse", + "DeleteRecordsRequest", + "DeleteRecordsResponse", + "ElectLeadersRequest", + "ElectLeadersResponse", + "ElectionType", +] diff --git a/stubs/kafka-python/kafka/protocol/admin/transactions.pyi b/stubs/kafka-python/kafka/protocol/admin/transactions.pyi new file mode 100644 index 000000000000..719151c07180 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/admin/transactions.pyi @@ -0,0 +1,284 @@ +from _typeshed import Incomplete + +from kafka.protocol.api_message import ApiMessage +from kafka.protocol.data_container import DataContainer + +class ListTransactionsRequest(ApiMessage): + state_filters: list[str] + producer_id_filters: list[int] + duration_filter: int + transactional_id_pattern: str | None + def __init__( + self, + *args, + state_filters: list[str] = ..., + producer_id_filters: list[int] = ..., + duration_filter: int = ..., + transactional_id_pattern: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class ListTransactionsResponse(ApiMessage): + class TransactionState(DataContainer): + transactional_id: str + producer_id: int + transaction_state: str + def __init__( + self, + *args, + transactional_id: str = ..., + producer_id: int = ..., + transaction_state: str = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + error_code: int + unknown_state_filters: list[str] + transaction_states: list[TransactionState] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + error_code: int = ..., + unknown_state_filters: list[str] = ..., + transaction_states: list[TransactionState] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DescribeTransactionsRequest(ApiMessage): + transactional_ids: list[str] + def __init__(self, *args, transactional_ids: list[str] = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DescribeTransactionsResponse(ApiMessage): + class TransactionState(DataContainer): + class TopicData(DataContainer): + topic: str + partitions: list[int] + def __init__( + self, *args, topic: str = ..., partitions: list[int] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + error_code: int + transactional_id: str + transaction_state: str + transaction_timeout_ms: int + transaction_start_time_ms: int + producer_id: int + producer_epoch: int + topics: list[TopicData] + def __init__( + self, + *args, + error_code: int = ..., + transactional_id: str = ..., + transaction_state: str = ..., + transaction_timeout_ms: int = ..., + transaction_start_time_ms: int = ..., + producer_id: int = ..., + producer_epoch: int = ..., + topics: list[TopicData] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + transaction_states: list[TransactionState] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + transaction_states: list[TransactionState] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DescribeProducersRequest(ApiMessage): + class TopicRequest(DataContainer): + name: str + partition_indexes: list[int] + def __init__( + self, *args, name: str = ..., partition_indexes: list[int] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + topics: list[TopicRequest] + def __init__(self, *args, topics: list[TopicRequest] = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DescribeProducersResponse(ApiMessage): + class TopicResponse(DataContainer): + class PartitionResponse(DataContainer): + class ProducerState(DataContainer): + producer_id: int + producer_epoch: int + last_sequence: int + last_timestamp: int + coordinator_epoch: int + current_txn_start_offset: int + def __init__( + self, + *args, + producer_id: int = ..., + producer_epoch: int = ..., + last_sequence: int = ..., + last_timestamp: int = ..., + coordinator_epoch: int = ..., + current_txn_start_offset: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + partition_index: int + error_code: int + error_message: str | None + active_producers: list[ProducerState] + def __init__( + self, + *args, + partition_index: int = ..., + error_code: int = ..., + error_message: str | None = ..., + active_producers: list[ProducerState] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + partitions: list[PartitionResponse] + def __init__( + self, *args, name: str = ..., partitions: list[PartitionResponse] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + topics: list[TopicResponse] + def __init__( + self, *args, throttle_time_ms: int = ..., topics: list[TopicResponse] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +__all__ = [ + "ListTransactionsRequest", + "ListTransactionsResponse", + "DescribeTransactionsRequest", + "DescribeTransactionsResponse", + "DescribeProducersRequest", + "DescribeProducersResponse", +] diff --git a/stubs/kafka-python/kafka/protocol/admin/users.pyi b/stubs/kafka-python/kafka/protocol/admin/users.pyi new file mode 100644 index 000000000000..63309692837e --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/admin/users.pyi @@ -0,0 +1,202 @@ +from _typeshed import Incomplete + +from kafka.protocol.api_data import ApiData +from kafka.protocol.api_message import ApiMessage +from kafka.protocol.data_container import DataContainer + +class AlterUserScramCredentialsRequest(ApiMessage): + class ScramCredentialDeletion(DataContainer): + name: str + mechanism: int + def __init__(self, *args, name: str = ..., mechanism: int = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class ScramCredentialUpsertion(DataContainer): + name: str + mechanism: int + iterations: int + salt: bytes | ApiData + salted_password: bytes | ApiData + def __init__( + self, + *args, + name: str = ..., + mechanism: int = ..., + iterations: int = ..., + salt: bytes | ApiData = ..., + salted_password: bytes | ApiData = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + deletions: list[ScramCredentialDeletion] + upsertions: list[ScramCredentialUpsertion] + def __init__( + self, + *args, + deletions: list[ScramCredentialDeletion] = ..., + upsertions: list[ScramCredentialUpsertion] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class AlterUserScramCredentialsResponse(ApiMessage): + class AlterUserScramCredentialsResult(DataContainer): + user: str + error_code: int + error_message: str | None + def __init__( + self, + *args, + user: str = ..., + error_code: int = ..., + error_message: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + results: list[AlterUserScramCredentialsResult] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + results: list[AlterUserScramCredentialsResult] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DescribeUserScramCredentialsRequest(ApiMessage): + class UserName(DataContainer): + name: str + def __init__(self, *args, name: str = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + users: list[UserName] | None + def __init__(self, *args, users: list[UserName] | None = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class DescribeUserScramCredentialsResponse(ApiMessage): + class DescribeUserScramCredentialsResult(DataContainer): + class CredentialInfo(DataContainer): + mechanism: int + iterations: int + def __init__( + self, *args, mechanism: int = ..., iterations: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + user: str + error_code: int + error_message: str | None + credential_infos: list[CredentialInfo] + def __init__( + self, + *args, + user: str = ..., + error_code: int = ..., + error_message: str | None = ..., + credential_infos: list[CredentialInfo] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + error_code: int + error_message: str | None + results: list[DescribeUserScramCredentialsResult] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + error_code: int = ..., + error_message: str | None = ..., + results: list[DescribeUserScramCredentialsResult] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +__all__ = [ + "AlterUserScramCredentialsRequest", + "AlterUserScramCredentialsResponse", + "DescribeUserScramCredentialsRequest", + "DescribeUserScramCredentialsResponse", +] diff --git a/stubs/kafka-python/kafka/protocol/api.pyi b/stubs/kafka-python/kafka/protocol/api.pyi deleted file mode 100644 index 72634ee5ee15..000000000000 --- a/stubs/kafka-python/kafka/protocol/api.pyi +++ /dev/null @@ -1,37 +0,0 @@ -import abc -from _typeshed import Incomplete - -from kafka.protocol.struct import Struct - -class RequestHeader(Struct): - SCHEMA: Incomplete - def __init__(self, request, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... - -class RequestHeaderV2(Struct): - SCHEMA: Incomplete - def __init__(self, request, correlation_id: int = 0, client_id: str = "kafka-python", tags=None) -> None: ... - -class ResponseHeader(Struct): - SCHEMA: Incomplete - -class ResponseHeaderV2(Struct): - SCHEMA: Incomplete - -class Request(Struct, metaclass=abc.ABCMeta): - FLEXIBLE_VERSION: bool - API_KEY: Incomplete - API_VERSION: Incomplete - SCHEMA: Incomplete - RESPONSE_TYPE: Incomplete - def expect_response(self): ... - def to_object(self): ... - def build_header(self, correlation_id, client_id): ... - -class Response(Struct, metaclass=abc.ABCMeta): - FLEXIBLE_VERSION: bool - API_KEY: Incomplete - API_VERSION: Incomplete - SCHEMA: Incomplete - def to_object(self): ... - @classmethod - def parse_header(cls, read_buffer): ... diff --git a/stubs/kafka-python/kafka/protocol/api_data.pyi b/stubs/kafka-python/kafka/protocol/api_data.pyi new file mode 100644 index 000000000000..b3606d6573cf --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/api_data.pyi @@ -0,0 +1,33 @@ +from kafka.util import classproperty + +from .data_container import DataContainer, SlotsBuilder + +class JsonSchemaData(SlotsBuilder): + def __new__(metacls, name, bases, attrs, **kw): ... + def __init__(cls, name, bases, attrs, **kw) -> None: ... + +class ApiData(DataContainer, metaclass=JsonSchemaData): + def __init_subclass__(cls, **kw) -> None: ... + def __init__(self, *args, **kwargs) -> None: ... + @classproperty + def name(cls): ... + @classproperty + def type(cls): ... + @classproperty + def json(cls): ... + @classproperty + def valid_versions(cls): ... + @classproperty + def min_version(cls): ... + @classproperty + def max_version(cls): ... + @classmethod + def flexible_version_q(cls, version): ... + @classproperty + def header_class(cls): ... + def encode_header(self, flexible: bool = False): ... + @classmethod + def parse_header(cls, data): ... + def encode(self, version=None, header: bool = True, framed: bool = False) -> bytes: ... + @classmethod + def decode(cls, data, version=None, header: bool = True, framed: bool = False): ... # type: ignore[override] diff --git a/stubs/kafka-python/kafka/protocol/api_header.pyi b/stubs/kafka-python/kafka/protocol/api_header.pyi new file mode 100644 index 000000000000..43156854fdbc --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/api_header.pyi @@ -0,0 +1,25 @@ +from .api_data import JsonSchemaData +from .data_container import DataContainer + +class ApiHeader(DataContainer, metaclass=JsonSchemaData): + __slots__ = () + def __init_subclass__(cls, **kw) -> None: ... + def encode(self, flexible: bool = False): ... + def encode_into(self, out, flexible: bool = False) -> None: ... + @classmethod + def decode(cls, data, flexible: bool = False): ... # type: ignore[override] + +class ResponseClassRegistry: + @classmethod + def register_response_class(cls, response_class) -> None: ... + @classmethod + def get_response_class(cls, request_header): ... + +class RequestHeader(ApiHeader): + def get_response_class(self): ... + # TODO: Reflect client_id, correlation_id, request_api_key, request_api_version attributes + def __getattr__(self, name: str): ... # incomplete class + +class ResponseHeader(ApiHeader): + # TODO: Reflect correlation_id attribute + def __getattr__(self, name: str): ... # incomplete class diff --git a/stubs/kafka-python/kafka/protocol/api_key.pyi b/stubs/kafka-python/kafka/protocol/api_key.pyi new file mode 100644 index 000000000000..fa8d789777ce --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/api_key.pyi @@ -0,0 +1,96 @@ +from enum import IntEnum + +class ApiKey(IntEnum): + Produce = 0 + Fetch = 1 + ListOffsets = 2 + Metadata = 3 + LeaderAndIsr = 4 + StopReplica = 5 + UpdateMetadata = 6 + ControlledShutdown = 7 + OffsetCommit = 8 + OffsetFetch = 9 + FindCoordinator = 10 + JoinGroup = 11 + Heartbeat = 12 + LeaveGroup = 13 + SyncGroup = 14 + DescribeGroups = 15 + ListGroups = 16 + SaslHandshake = 17 + ApiVersions = 18 + CreateTopics = 19 + DeleteTopics = 20 + DeleteRecords = 21 + InitProducerId = 22 + OffsetForLeaderEpoch = 23 + AddPartitionsToTxn = 24 + AddOffsetsToTxn = 25 + EndTxn = 26 + WriteTxnMarkers = 27 + TxnOffsetCommit = 28 + DescribeAcls = 29 + CreateAcls = 30 + DeleteAcls = 31 + DescribeConfigs = 32 + AlterConfigs = 33 + AlterReplicaLogDirs = 34 + DescribeLogDirs = 35 + SaslAuthenticate = 36 + CreatePartitions = 37 + CreateDelegationToken = 38 + RenewDelegationToken = 39 + ExpireDelegationToken = 40 + DescribeDelegationToken = 41 + DeleteGroups = 42 + ElectLeaders = 43 + IncrementalAlterConfigs = 44 + AlterPartitionReassignments = 45 + ListPartitionReassignments = 46 + OffsetDelete = 47 + DescribeClientQuotas = 48 + AlterClientQuotas = 49 + DescribeUserScramCredentials = 50 + AlterUserScramCredentials = 51 + Vote = 52 + BeginQuorumEpoch = 53 + EndQuorumEpoch = 54 + DescribeQuorum = 55 + AlterPartition = 56 + UpdateFeatures = 57 + Envelope = 58 + FetchSnapshot = 59 + DescribeCluster = 60 + DescribeProducers = 61 + BrokerRegistration = 62 + BrokerHeartbeat = 63 + UnregisterBroker = 64 + DescribeTransactions = 65 + ListTransactions = 66 + AllocateProducerIds = 67 + ConsumerGroupHeartbeat = 68 + ConsumerGroupDescribe = 69 + ControllerRegistration = 70 + GetTelemetrySubscriptions = 71 + PushTelemetry = 72 + AssignReplicasToDirs = 73 + ListConfigResources = 74 + DescribeTopicPartitions = 75 + ShareGroupHeartbeat = 76 + ShareGroupDescribe = 77 + ShareFetch = 78 + ShareAcknowledge = 79 + AddRaftVoter = 80 + RemoveRaftVoter = 81 + UpdateRaftVoter = 82 + InitializeShareGroupState = 83 + ReadShareGroupState = 84 + WriteShareGroupState = 85 + DeleteShareGroupState = 86 + ReadShareGroupStateSummary = 87 + StreamsGroupHeartbeat = 88 + StreamsGroupDescribe = 89 + DescribeShareGroupOffsets = 90 + AlterShareGroupOffsets = 91 + DeleteShareGroupOffsets = 92 diff --git a/stubs/kafka-python/kafka/protocol/api_message.pyi b/stubs/kafka-python/kafka/protocol/api_message.pyi new file mode 100644 index 000000000000..d5752eaccb31 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/api_message.pyi @@ -0,0 +1,60 @@ +from typing_extensions import Self + +from kafka.util import classproperty + +from .api_data import JsonSchemaData +from .data_container import DataContainer + +class VersionSubscriptable(type): + def __init__(cls, name, bases, attrs, **kw) -> None: ... + def __getitem__(cls, version): ... + def __len__(cls): ... + +class ApiMessageData(VersionSubscriptable, JsonSchemaData): + def __init__(cls, name, bases, attrs, **kw) -> None: ... + +class ApiMessage(DataContainer, metaclass=ApiMessageData): + __slots__ = ("_header", "_min_version", "_max_version") + def __init_subclass__(cls, **kw) -> None: ... + def __new__(cls, *args, **kwargs) -> Self: ... + def __init__(self, *args, **kwargs) -> None: ... + @classproperty + def name(cls): ... + @classproperty + def type(cls): ... + @classproperty + def API_KEY(cls): ... + @classproperty + def json(cls): ... + @classproperty + def valid_versions(cls): ... + @classproperty + def min_version(cls): ... + @classproperty + def max_version(cls): ... + @classmethod + def flexible_version_q(cls, version) -> bool: ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self): ... + + @property + def API_VERSION(self): ... + @API_VERSION.setter + def API_VERSION(self, version): ... + + @property + def header(self): ... + @classproperty + def header_class(cls): ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + def encode_header(self, flexible: bool = False): ... + def encode_header_into(self, out, flexible: bool = False) -> None: ... + @classmethod + def parse_header(cls, data, version=None): ... + @classmethod + def encode_into__optimized_context(cls, version=None): ... + def encode(self, version=None, header: bool = False, framed: bool = False): ... + @classmethod + def decode(cls, data, version=None, header: bool = False, framed: bool = False): ... # type: ignore[override] + def __eq__(self, other) -> bool: ... diff --git a/stubs/kafka-python/kafka/protocol/broker_api_versions.pyi b/stubs/kafka-python/kafka/protocol/broker_api_versions.pyi deleted file mode 100644 index 9a9a50c93d65..000000000000 --- a/stubs/kafka-python/kafka/protocol/broker_api_versions.pyi +++ /dev/null @@ -1,3 +0,0 @@ -from _typeshed import Incomplete - -BROKER_API_VERSIONS: Incomplete diff --git a/stubs/kafka-python/kafka/protocol/broker_version_data.pyi b/stubs/kafka-python/kafka/protocol/broker_version_data.pyi new file mode 100644 index 000000000000..4bb36e298cec --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/broker_version_data.pyi @@ -0,0 +1,20 @@ +from _typeshed import Incomplete + +class BrokerVersionData: + __slots__ = ("broker_version", "api_versions") + broker_version: Incomplete + api_versions: Incomplete + def __init__(self, broker_version=None, api_versions=None) -> None: ... + def api_version(self, operation, min_version: int = 0, max_version: int = ...) -> int: ... + @property + def broker_version_str(self) -> str: ... + def __eq__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... + def __le__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __ge__(self, other) -> bool: ... + +def infer_broker_version_from_api_versions(api_versions): ... + +VERSION_CHECKS: tuple[tuple[tuple[int, ...], Incomplete], ...] +BROKER_API_VERSIONS: dict[tuple[int, ...], dict[int, tuple[int, ...]]] diff --git a/stubs/kafka-python/kafka/protocol/consumer/__init__.pyi b/stubs/kafka-python/kafka/protocol/consumer/__init__.pyi new file mode 100644 index 000000000000..cb63f963b18c --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/consumer/__init__.pyi @@ -0,0 +1,37 @@ +from .fetch import * +from .group import * +from .metadata import * +from .offsets import * + +__all__ = [ + "FetchRequest", + "FetchResponse", + "DEFAULT_GENERATION_ID", + "UNKNOWN_MEMBER_ID", + "JoinGroupRequest", + "JoinGroupResponse", + "SyncGroupRequest", + "SyncGroupResponse", + "LeaveGroupRequest", + "LeaveGroupResponse", + "HeartbeatRequest", + "HeartbeatResponse", + "OffsetFetchRequest", + "OffsetFetchResponse", + "OffsetCommitRequest", + "OffsetCommitResponse", + "OffsetDeleteRequest", + "OffsetDeleteResponse", + "ConsumerProtocolSubscription", + "ConsumerProtocolAssignment", + "ConsumerProtocolType", + "UNKNOWN_OFFSET", + "OffsetResetStrategy", + "IsolationLevel", + "OffsetSpec", + "OffsetTimestamp", + "ListOffsetsRequest", + "ListOffsetsResponse", + "OffsetForLeaderEpochRequest", + "OffsetForLeaderEpochResponse", +] diff --git a/stubs/kafka-python/kafka/protocol/consumer/fetch.pyi b/stubs/kafka-python/kafka/protocol/consumer/fetch.pyi new file mode 100644 index 000000000000..888cbcb47355 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/consumer/fetch.pyi @@ -0,0 +1,272 @@ +import uuid +from _typeshed import Incomplete + +from kafka.protocol.api_data import ApiData +from kafka.protocol.api_message import ApiMessage +from kafka.protocol.data_container import DataContainer + +class FetchRequest(ApiMessage): + class ReplicaState(DataContainer): + replica_id: int + replica_epoch: int + def __init__( + self, *args, replica_id: int = ..., replica_epoch: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class FetchTopic(DataContainer): + class FetchPartition(DataContainer): + partition: int + current_leader_epoch: int + fetch_offset: int + last_fetched_epoch: int + log_start_offset: int + partition_max_bytes: int + replica_directory_id: uuid.UUID + high_watermark: int + def __init__( + self, + *args, + partition: int = ..., + current_leader_epoch: int = ..., + fetch_offset: int = ..., + last_fetched_epoch: int = ..., + log_start_offset: int = ..., + partition_max_bytes: int = ..., + replica_directory_id: uuid.UUID = ..., + high_watermark: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + topic: str + topic_id: uuid.UUID + partitions: list[FetchPartition] + def __init__( + self, + *args, + topic: str = ..., + topic_id: uuid.UUID = ..., + partitions: list[FetchPartition] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class ForgottenTopic(DataContainer): + topic: str + topic_id: uuid.UUID + partitions: list[int] + def __init__( + self, + *args, + topic: str = ..., + topic_id: uuid.UUID = ..., + partitions: list[int] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + cluster_id: str | None + replica_id: int + replica_state: ReplicaState + max_wait_ms: int + min_bytes: int + max_bytes: int + isolation_level: int + session_id: int + session_epoch: int + topics: list[FetchTopic] + forgotten_topics_data: list[ForgottenTopic] + rack_id: str + def __init__( + self, + *args, + cluster_id: str | None = ..., + replica_id: int = ..., + replica_state: ReplicaState = ..., + max_wait_ms: int = ..., + min_bytes: int = ..., + max_bytes: int = ..., + isolation_level: int = ..., + session_id: int = ..., + session_epoch: int = ..., + topics: list[FetchTopic] = ..., + forgotten_topics_data: list[ForgottenTopic] = ..., + rack_id: str = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + @classmethod + def min_version_for_isolation_level(cls, il): ... + +class FetchResponse(ApiMessage): + class FetchableTopicResponse(DataContainer): + class PartitionData(DataContainer): + class EpochEndOffset(DataContainer): + epoch: int + end_offset: int + def __init__( + self, *args, epoch: int = ..., end_offset: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class LeaderIdAndEpoch(DataContainer): + leader_id: int + leader_epoch: int + def __init__( + self, *args, leader_id: int = ..., leader_epoch: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class SnapshotId(DataContainer): + end_offset: int + epoch: int + def __init__( + self, *args, end_offset: int = ..., epoch: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class AbortedTransaction(DataContainer): + producer_id: int + first_offset: int + def __init__( + self, *args, producer_id: int = ..., first_offset: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + partition_index: int + error_code: int + high_watermark: int + last_stable_offset: int + log_start_offset: int + diverging_epoch: EpochEndOffset + current_leader: LeaderIdAndEpoch + snapshot_id: SnapshotId + aborted_transactions: list[AbortedTransaction] | None + preferred_read_replica: int + records: bytes | ApiData | None + def __init__( + self, + *args, + partition_index: int = ..., + error_code: int = ..., + high_watermark: int = ..., + last_stable_offset: int = ..., + log_start_offset: int = ..., + diverging_epoch: EpochEndOffset = ..., + current_leader: LeaderIdAndEpoch = ..., + snapshot_id: SnapshotId = ..., + aborted_transactions: list[AbortedTransaction] | None = ..., + preferred_read_replica: int = ..., + records: bytes | ApiData | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + topic: str + topic_id: uuid.UUID + partitions: list[PartitionData] + def __init__( + self, + *args, + topic: str = ..., + topic_id: uuid.UUID = ..., + partitions: list[PartitionData] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class NodeEndpoint(DataContainer): + node_id: int + host: str + port: int + rack: str | None + def __init__( + self, + *args, + node_id: int = ..., + host: str = ..., + port: int = ..., + rack: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + error_code: int + session_id: int + responses: list[FetchableTopicResponse] + node_endpoints: list[NodeEndpoint] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + error_code: int = ..., + session_id: int = ..., + responses: list[FetchableTopicResponse] = ..., + node_endpoints: list[NodeEndpoint] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +__all__ = ["FetchRequest", "FetchResponse"] diff --git a/stubs/kafka-python/kafka/protocol/consumer/group.pyi b/stubs/kafka-python/kafka/protocol/consumer/group.pyi new file mode 100644 index 000000000000..afba3210444c --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/consumer/group.pyi @@ -0,0 +1,799 @@ +import uuid +from _typeshed import Incomplete +from typing import Final + +from kafka.protocol.api_data import ApiData +from kafka.protocol.api_message import ApiMessage +from kafka.protocol.data_container import DataContainer + +DEFAULT_GENERATION_ID: Final = -1 +UNKNOWN_MEMBER_ID: Final = "" + +class JoinGroupRequest(ApiMessage): + class JoinGroupRequestProtocol(DataContainer): + name: str + metadata: bytes | ApiData + def __init__( + self, *args, name: str = ..., metadata: bytes | ApiData = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + group_id: str + session_timeout_ms: int + rebalance_timeout_ms: int + member_id: str + group_instance_id: str | None + protocol_type: str + protocols: list[JoinGroupRequestProtocol] + reason: str | None + def __init__( + self, + *args, + group_id: str = ..., + session_timeout_ms: int = ..., + rebalance_timeout_ms: int = ..., + member_id: str = ..., + group_instance_id: str | None = ..., + protocol_type: str = ..., + protocols: list[JoinGroupRequestProtocol] = ..., + reason: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class JoinGroupResponse(ApiMessage): + class JoinGroupResponseMember(DataContainer): + member_id: str + group_instance_id: str | None + metadata: bytes | ApiData + def __init__( + self, + *args, + member_id: str = ..., + group_instance_id: str | None = ..., + metadata: bytes | ApiData = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + error_code: int + generation_id: int + protocol_type: str | None + protocol_name: str | None + leader: str + skip_assignment: bool + member_id: str + members: list[JoinGroupResponseMember] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + error_code: int = ..., + generation_id: int = ..., + protocol_type: str | None = ..., + protocol_name: str | None = ..., + leader: str = ..., + skip_assignment: bool = ..., + member_id: str = ..., + members: list[JoinGroupResponseMember] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class SyncGroupRequest(ApiMessage): + class SyncGroupRequestAssignment(DataContainer): + member_id: str + assignment: bytes | ApiData + def __init__( + self, *args, member_id: str = ..., assignment: bytes | ApiData = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + group_id: str + generation_id: int + member_id: str + group_instance_id: str | None + protocol_type: str | None + protocol_name: str | None + assignments: list[SyncGroupRequestAssignment] + def __init__( + self, + *args, + group_id: str = ..., + generation_id: int = ..., + member_id: str = ..., + group_instance_id: str | None = ..., + protocol_type: str | None = ..., + protocol_name: str | None = ..., + assignments: list[SyncGroupRequestAssignment] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class SyncGroupResponse(ApiMessage): + throttle_time_ms: int + error_code: int + protocol_type: str | None + protocol_name: str | None + assignment: bytes | ApiData + def __init__( + self, + *args, + throttle_time_ms: int = ..., + error_code: int = ..., + protocol_type: str | None = ..., + protocol_name: str | None = ..., + assignment: bytes | ApiData = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class LeaveGroupRequest(ApiMessage): + class MemberIdentity(DataContainer): + member_id: str + group_instance_id: str | None + reason: str | None + def __init__( + self, + *args, + member_id: str = ..., + group_instance_id: str | None = ..., + reason: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + group_id: str + member_id: str + members: list[MemberIdentity] + def __init__( + self, + *args, + group_id: str = ..., + member_id: str = ..., + members: list[MemberIdentity] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class LeaveGroupResponse(ApiMessage): + class MemberResponse(DataContainer): + member_id: str + group_instance_id: str | None + error_code: int + def __init__( + self, + *args, + member_id: str = ..., + group_instance_id: str | None = ..., + error_code: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + error_code: int + members: list[MemberResponse] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + error_code: int = ..., + members: list[MemberResponse] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class HeartbeatRequest(ApiMessage): + group_id: str + generation_id: int + member_id: str + group_instance_id: str | None + def __init__( + self, + *args, + group_id: str = ..., + generation_id: int = ..., + member_id: str = ..., + group_instance_id: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class HeartbeatResponse(ApiMessage): + throttle_time_ms: int + error_code: int + def __init__( + self, *args, throttle_time_ms: int = ..., error_code: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class OffsetFetchRequest(ApiMessage): + class OffsetFetchRequestTopic(DataContainer): + name: str + partition_indexes: list[int] + def __init__( + self, *args, name: str = ..., partition_indexes: list[int] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class OffsetFetchRequestGroup(DataContainer): + class OffsetFetchRequestTopics(DataContainer): + name: str + topic_id: uuid.UUID + partition_indexes: list[int] + def __init__( + self, + *args, + name: str = ..., + topic_id: uuid.UUID = ..., + partition_indexes: list[int] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + group_id: str + member_id: str | None + member_epoch: int + topics: list[OffsetFetchRequestTopics] | None + def __init__( + self, + *args, + group_id: str = ..., + member_id: str | None = ..., + member_epoch: int = ..., + topics: list[OffsetFetchRequestTopics] | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + group_id: str + topics: list[OffsetFetchRequestTopic] | None + groups: list[OffsetFetchRequestGroup] + require_stable: bool + def __init__( + self, + *args, + group_id: str = ..., + topics: list[OffsetFetchRequestTopic] | None = ..., + groups: list[OffsetFetchRequestGroup] = ..., + require_stable: bool = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class OffsetFetchResponse(ApiMessage): + class OffsetFetchResponseTopic(DataContainer): + class OffsetFetchResponsePartition(DataContainer): + partition_index: int + committed_offset: int + committed_leader_epoch: int + metadata: str | None + error_code: int + def __init__( + self, + *args, + partition_index: int = ..., + committed_offset: int = ..., + committed_leader_epoch: int = ..., + metadata: str | None = ..., + error_code: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + partitions: list[OffsetFetchResponsePartition] + def __init__( + self, + *args, + name: str = ..., + partitions: list[OffsetFetchResponsePartition] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class OffsetFetchResponseGroup(DataContainer): + class OffsetFetchResponseTopics(DataContainer): + class OffsetFetchResponsePartitions(DataContainer): + partition_index: int + committed_offset: int + committed_leader_epoch: int + metadata: str | None + error_code: int + def __init__( + self, + *args, + partition_index: int = ..., + committed_offset: int = ..., + committed_leader_epoch: int = ..., + metadata: str | None = ..., + error_code: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + topic_id: uuid.UUID + partitions: list[OffsetFetchResponsePartitions] + def __init__( + self, + *args, + name: str = ..., + topic_id: uuid.UUID = ..., + partitions: list[OffsetFetchResponsePartitions] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + group_id: str + topics: list[OffsetFetchResponseTopics] + error_code: int + def __init__( + self, + *args, + group_id: str = ..., + topics: list[OffsetFetchResponseTopics] = ..., + error_code: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + topics: list[OffsetFetchResponseTopic] + error_code: int + groups: list[OffsetFetchResponseGroup] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + topics: list[OffsetFetchResponseTopic] = ..., + error_code: int = ..., + groups: list[OffsetFetchResponseGroup] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class OffsetCommitRequest(ApiMessage): + class OffsetCommitRequestTopic(DataContainer): + class OffsetCommitRequestPartition(DataContainer): + partition_index: int + committed_offset: int + committed_leader_epoch: int + commit_timestamp: int + committed_metadata: str | None + def __init__( + self, + *args, + partition_index: int = ..., + committed_offset: int = ..., + committed_leader_epoch: int = ..., + commit_timestamp: int = ..., + committed_metadata: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + topic_id: uuid.UUID + partitions: list[OffsetCommitRequestPartition] + def __init__( + self, + *args, + name: str = ..., + topic_id: uuid.UUID = ..., + partitions: list[OffsetCommitRequestPartition] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + group_id: str + generation_id_or_member_epoch: int + member_id: str + group_instance_id: str | None + retention_time_ms: int + topics: list[OffsetCommitRequestTopic] + def __init__( + self, + *args, + group_id: str = ..., + generation_id_or_member_epoch: int = ..., + member_id: str = ..., + group_instance_id: str | None = ..., + retention_time_ms: int = ..., + topics: list[OffsetCommitRequestTopic] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class OffsetCommitResponse(ApiMessage): + class OffsetCommitResponseTopic(DataContainer): + class OffsetCommitResponsePartition(DataContainer): + partition_index: int + error_code: int + def __init__( + self, *args, partition_index: int = ..., error_code: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + topic_id: uuid.UUID + partitions: list[OffsetCommitResponsePartition] + def __init__( + self, + *args, + name: str = ..., + topic_id: uuid.UUID = ..., + partitions: list[OffsetCommitResponsePartition] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + topics: list[OffsetCommitResponseTopic] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + topics: list[OffsetCommitResponseTopic] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class OffsetDeleteRequest(ApiMessage): + class OffsetDeleteRequestTopic(DataContainer): + class OffsetDeleteRequestPartition(DataContainer): + partition_index: int + def __init__(self, *args, partition_index: int = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + partitions: list[OffsetDeleteRequestPartition] + def __init__( + self, + *args, + name: str = ..., + partitions: list[OffsetDeleteRequestPartition] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + group_id: str + topics: list[OffsetDeleteRequestTopic] + def __init__( + self, *args, group_id: str = ..., topics: list[OffsetDeleteRequestTopic] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class OffsetDeleteResponse(ApiMessage): + class OffsetDeleteResponseTopic(DataContainer): + class OffsetDeleteResponsePartition(DataContainer): + partition_index: int + error_code: int + def __init__( + self, *args, partition_index: int = ..., error_code: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + partitions: list[OffsetDeleteResponsePartition] + def __init__( + self, + *args, + name: str = ..., + partitions: list[OffsetDeleteResponsePartition] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + error_code: int + throttle_time_ms: int + topics: list[OffsetDeleteResponseTopic] + def __init__( + self, + *args, + error_code: int = ..., + throttle_time_ms: int = ..., + topics: list[OffsetDeleteResponseTopic] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +__all__ = [ + "DEFAULT_GENERATION_ID", + "UNKNOWN_MEMBER_ID", + "JoinGroupRequest", + "JoinGroupResponse", + "SyncGroupRequest", + "SyncGroupResponse", + "LeaveGroupRequest", + "LeaveGroupResponse", + "HeartbeatRequest", + "HeartbeatResponse", + "OffsetFetchRequest", + "OffsetFetchResponse", + "OffsetCommitRequest", + "OffsetCommitResponse", + "OffsetDeleteRequest", + "OffsetDeleteResponse", +] diff --git a/stubs/kafka-python/kafka/protocol/consumer/metadata.pyi b/stubs/kafka-python/kafka/protocol/consumer/metadata.pyi new file mode 100644 index 000000000000..15d899effc4b --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/consumer/metadata.pyi @@ -0,0 +1,82 @@ +from _typeshed import Incomplete +from typing import Final + +from kafka.protocol.api_data import ApiData +from kafka.protocol.data_container import DataContainer + +ConsumerProtocolType: Final = "consumer" + +class ConsumerProtocolSubscription(ApiData): + class TopicPartition(DataContainer): + topic: str + partitions: list[int] + def __init__( + self, *args, topic: str = ..., partitions: list[int] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + topics: list[str] + user_data: bytes | ApiData | None + owned_partitions: list[TopicPartition] + generation_id: int + rack_id: str | None + def __init__( + self, + *args, + topics: list[str] = ..., + user_data: bytes | ApiData | None = ..., + owned_partitions: list[TopicPartition] = ..., + generation_id: int = ..., + rack_id: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + valid_versions: tuple[int, int] + min_version: int + max_version: int + +class ConsumerProtocolAssignment(ApiData): + class TopicPartition(DataContainer): + topic: str + partitions: list[int] + def __init__( + self, *args, topic: str = ..., partitions: list[int] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + assigned_partitions: list[TopicPartition] + user_data: bytes | ApiData | None + def __init__( + self, + *args, + assigned_partitions: list[TopicPartition] = ..., + user_data: bytes | ApiData | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + valid_versions: tuple[int, int] + min_version: int + max_version: int + + @property + def assignment(self) -> list[TopicPartition]: ... + @assignment.setter + def assignment(self, value: list[TopicPartition]) -> None: ... + + def partitions(self) -> list[TopicPartition]: ... + +__all__ = ["ConsumerProtocolSubscription", "ConsumerProtocolAssignment", "ConsumerProtocolType"] diff --git a/stubs/kafka-python/kafka/protocol/consumer/offsets.pyi b/stubs/kafka-python/kafka/protocol/consumer/offsets.pyi new file mode 100644 index 000000000000..472c68ce8414 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/consumer/offsets.pyi @@ -0,0 +1,278 @@ +from _typeshed import Incomplete +from enum import IntEnum +from typing import Final + +from kafka.protocol.api_message import ApiMessage +from kafka.protocol.data_container import DataContainer +from kafka.util import EnumHelper + +UNKNOWN_OFFSET: Final = -1 + +class OffsetResetStrategy: + LATEST: Final = -1 + EARLIEST: Final = -2 + NONE: Final = 0 + +class IsolationLevel(EnumHelper, IntEnum): + READ_UNCOMMITTED = 0 + READ_COMMITTED = 1 + +class OffsetSpec(EnumHelper, IntEnum): + LATEST = -1 + EARLIEST = -2 + MAX_TIMESTAMP = -3 + EARLIEST_LOCAL = -4 + LATEST_TIERED = -5 + +class OffsetTimestamp(int): + __slots__ = () + +class ListOffsetsRequest(ApiMessage): + class ListOffsetsTopic(DataContainer): + class ListOffsetsPartition(DataContainer): + partition_index: int + current_leader_epoch: int + timestamp: int + max_num_offsets: int + def __init__( + self, + *args, + partition_index: int = ..., + current_leader_epoch: int = ..., + timestamp: int = ..., + max_num_offsets: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + partitions: list[ListOffsetsPartition] + def __init__( + self, *args, name: str = ..., partitions: list[ListOffsetsPartition] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + replica_id: int + isolation_level: int + topics: list[ListOffsetsTopic] + timeout_ms: int + def __init__( + self, + *args, + replica_id: int = ..., + isolation_level: int = ..., + topics: list[ListOffsetsTopic] = ..., + timeout_ms: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + @classmethod + def min_version_for_timestamp(cls, ts): ... + @classmethod + def min_version_for_isolation_level(cls, il): ... + +class ListOffsetsResponse(ApiMessage): + class ListOffsetsTopicResponse(DataContainer): + class ListOffsetsPartitionResponse(DataContainer): + partition_index: int + error_code: int + old_style_offsets: list[int] + timestamp: int + offset: int + leader_epoch: int + def __init__( + self, + *args, + partition_index: int = ..., + error_code: int = ..., + old_style_offsets: list[int] = ..., + timestamp: int = ..., + offset: int = ..., + leader_epoch: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + partitions: list[ListOffsetsPartitionResponse] + def __init__( + self, + *args, + name: str = ..., + partitions: list[ListOffsetsPartitionResponse] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + topics: list[ListOffsetsTopicResponse] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + topics: list[ListOffsetsTopicResponse] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class OffsetForLeaderEpochRequest(ApiMessage): + class OffsetForLeaderTopic(DataContainer): + class OffsetForLeaderPartition(DataContainer): + partition: int + current_leader_epoch: int + leader_epoch: int + def __init__( + self, + *args, + partition: int = ..., + current_leader_epoch: int = ..., + leader_epoch: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + topic: str + partitions: list[OffsetForLeaderPartition] + def __init__( + self, *args, topic: str = ..., partitions: list[OffsetForLeaderPartition] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + replica_id: int + topics: list[OffsetForLeaderTopic] + def __init__( + self, *args, replica_id: int = ..., topics: list[OffsetForLeaderTopic] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class OffsetForLeaderEpochResponse(ApiMessage): + class OffsetForLeaderTopicResult(DataContainer): + class EpochEndOffset(DataContainer): + error_code: int + partition: int + leader_epoch: int + end_offset: int + def __init__( + self, + *args, + error_code: int = ..., + partition: int = ..., + leader_epoch: int = ..., + end_offset: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + topic: str + partitions: list[EpochEndOffset] + def __init__( + self, *args, topic: str = ..., partitions: list[EpochEndOffset] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + topics: list[OffsetForLeaderTopicResult] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + topics: list[OffsetForLeaderTopicResult] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +__all__ = [ + "UNKNOWN_OFFSET", + "OffsetResetStrategy", + "IsolationLevel", + "OffsetSpec", + "OffsetTimestamp", + "ListOffsetsRequest", + "ListOffsetsResponse", + "OffsetForLeaderEpochRequest", + "OffsetForLeaderEpochResponse", +] diff --git a/stubs/kafka-python/kafka/protocol/data_container.pyi b/stubs/kafka-python/kafka/protocol/data_container.pyi new file mode 100644 index 000000000000..0abd4d7706d8 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/data_container.pyi @@ -0,0 +1,27 @@ +from _typeshed import Incomplete +from collections.abc import Iterator + +from kafka.util import classproperty + +class SlotsBuilder(type): + def __new__(metacls, name, bases, attrs, **kw): ... + +class DataContainer(metaclass=SlotsBuilder): + __slots__ = ("tags", "unknown_tags", "_version") + def __init_subclass__(cls, **kwargs) -> None: ... + tags: set[Incomplete] | None + unknown_tags: dict[str, Incomplete] | None + def __init__(self, *args, version=None, **field_vals) -> None: ... + def __getattr__(self, name): ... + @property + def version(self): ... + def encode(self, *args, **kwargs): ... + def encode_into(self, out, *args, **kwargs) -> None: ... + @classmethod + def decode(cls, data, **kwargs): ... + @classproperty + def fields(cls): ... + def __eq__(self, other) -> bool: ... + def __iter__(self) -> Iterator[Incomplete]: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + def __getitem__(self, key: int | slice): ... diff --git a/stubs/kafka-python/kafka/protocol/generate_stubs.pyi b/stubs/kafka-python/kafka/protocol/generate_stubs.pyi new file mode 100644 index 000000000000..367f85525b68 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/generate_stubs.pyi @@ -0,0 +1,12 @@ +from _typeshed import Incomplete +from types import ModuleType +from typing import Final + +SIMPLE_TYPE_MAP: Final[dict[str, str]] +MESSAGE_MODULES: Final[list[str]] + +def resolve_type(field: object) -> str: ... +def emit_class(cls: type, indent: int = 0, base_name: str | None = None) -> list[str]: ... +def discover_modules() -> dict[str, tuple[ModuleType, list[tuple[str, Incomplete]]]]: ... +def generate_module(mod, exports) -> str: ... +def generate_all(dry_run: bool = False, check: bool = False) -> bool: ... diff --git a/stubs/kafka-python/kafka/protocol/message.pyi b/stubs/kafka-python/kafka/protocol/message.pyi deleted file mode 100644 index 3e2a48204671..000000000000 --- a/stubs/kafka-python/kafka/protocol/message.pyi +++ /dev/null @@ -1,43 +0,0 @@ -from _typeshed import Incomplete - -from kafka.protocol.struct import Struct -from kafka.protocol.types import AbstractType - -class Message(Struct): - SCHEMAS: Incomplete - SCHEMA: Incomplete - CODEC_MASK: int - CODEC_GZIP: int - CODEC_SNAPPY: int - CODEC_LZ4: int - CODEC_ZSTD: int - TIMESTAMP_TYPE_MASK: int - HEADER_SIZE: int - timestamp: Incomplete - crc: Incomplete - magic: Incomplete - attributes: Incomplete - key: Incomplete - value: Incomplete - encode: Incomplete - def __init__(self, value, key=None, magic: int = 0, attributes: int = 0, crc: int = 0, timestamp=None) -> None: ... - @property - def timestamp_type(self): ... - @classmethod - def decode(cls, data): ... - def validate_crc(self): ... - def is_compressed(self): ... - def decompress(self): ... - def __hash__(self): ... - -class PartialMessage(bytes): ... - -class MessageSet(AbstractType): - ITEM: Incomplete - HEADER_SIZE: int - @classmethod - def encode(cls, items, prepend_size: bool = True): ... - @classmethod - def decode(cls, data, bytes_to_read=None): ... - @classmethod - def repr(cls, messages): ... diff --git a/stubs/kafka-python/kafka/protocol/metadata/__init__.pyi b/stubs/kafka-python/kafka/protocol/metadata/__init__.pyi new file mode 100644 index 000000000000..7a07a803c212 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/metadata/__init__.pyi @@ -0,0 +1,13 @@ +from .api_versions import * +from .find_coordinator import * +from .metadata import * + +__all__ = [ + "ApiVersionsRequest", + "ApiVersionsResponse", + "CoordinatorType", + "FindCoordinatorRequest", + "FindCoordinatorResponse", + "MetadataRequest", + "MetadataResponse", +] diff --git a/stubs/kafka-python/kafka/protocol/metadata/api_versions.pyi b/stubs/kafka-python/kafka/protocol/metadata/api_versions.pyi new file mode 100644 index 000000000000..febcbb43cbd5 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/metadata/api_versions.pyi @@ -0,0 +1,111 @@ +from _typeshed import Incomplete + +from kafka.protocol.api_message import ApiMessage +from kafka.protocol.data_container import DataContainer + +class ApiVersionsRequest(ApiMessage): + client_software_name: str + client_software_version: str + def __init__( + self, *args, client_software_name: str = ..., client_software_version: str = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class ApiVersionsResponse(ApiMessage): + class ApiVersion(DataContainer): + api_key: int + min_version: int + max_version: int + def __init__( + self, *args, api_key: int = ..., min_version: int = ..., max_version: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class SupportedFeatureKey(DataContainer): + name: str + min_version: int + max_version: int + def __init__( + self, *args, name: str = ..., min_version: int = ..., max_version: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class FinalizedFeatureKey(DataContainer): + name: str + max_version_level: int + min_version_level: int + def __init__( + self, + *args, + name: str = ..., + max_version_level: int = ..., + min_version_level: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + error_code: int + api_keys: list[ApiVersion] + throttle_time_ms: int + supported_features: list[SupportedFeatureKey] + finalized_features_epoch: int + finalized_features: list[FinalizedFeatureKey] + zk_migration_ready: bool + def __init__( + self, + *args, + error_code: int = ..., + api_keys: list[ApiVersion] = ..., + throttle_time_ms: int = ..., + supported_features: list[SupportedFeatureKey] = ..., + finalized_features_epoch: int = ..., + finalized_features: list[FinalizedFeatureKey] = ..., + zk_migration_ready: bool = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + @classmethod + def parse_header(cls, data, version=None): ... + def encode_header(self, flexible: bool = False): ... + @classmethod + def decode(cls, data, version=None, header: bool = False, framed: bool = False): ... # type: ignore[override] + +__all__ = ["ApiVersionsRequest", "ApiVersionsResponse"] diff --git a/stubs/kafka-python/kafka/protocol/metadata/find_coordinator.pyi b/stubs/kafka-python/kafka/protocol/metadata/find_coordinator.pyi new file mode 100644 index 000000000000..d1c9be13e5dc --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/metadata/find_coordinator.pyi @@ -0,0 +1,98 @@ +from _typeshed import Incomplete +from enum import IntEnum + +from kafka.protocol.api_message import ApiMessage +from kafka.protocol.data_container import DataContainer +from kafka.util import EnumHelper + +class CoordinatorType(EnumHelper, IntEnum): + GROUP = 0 + TRANSACTION = 1 + SHARE = 2 + +class FindCoordinatorRequest(ApiMessage): + key: str + key_type: int + coordinator_keys: list[str] + def __init__( + self, *args, key: str = ..., key_type: int = ..., coordinator_keys: list[str] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class FindCoordinatorResponse(ApiMessage): + class Coordinator(DataContainer): + key: str + node_id: int + host: str + port: int + error_code: int + error_message: str | None + def __init__( + self, + *args, + key: str = ..., + node_id: int = ..., + host: str = ..., + port: int = ..., + error_code: int = ..., + error_message: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + error_code: int + error_message: str | None + node_id: int + host: str + port: int + coordinators: list[Coordinator] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + error_code: int = ..., + error_message: str | None = ..., + node_id: int = ..., + host: str = ..., + port: int = ..., + coordinators: list[Coordinator] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +__all__ = ["CoordinatorType", "FindCoordinatorRequest", "FindCoordinatorResponse"] diff --git a/stubs/kafka-python/kafka/protocol/metadata/metadata.pyi b/stubs/kafka-python/kafka/protocol/metadata/metadata.pyi new file mode 100644 index 000000000000..372a7394f9b0 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/metadata/metadata.pyi @@ -0,0 +1,160 @@ +import uuid +from _typeshed import Incomplete + +from kafka.protocol.api_message import ApiMessage +from kafka.protocol.data_container import DataContainer + +class MetadataRequest(ApiMessage): + ALL_TOPICS: Incomplete | None + NO_TOPICS: list[Incomplete] + + class MetadataRequestTopic(DataContainer): + topic_id: uuid.UUID + name: str | None + def __init__( + self, *args, topic_id: uuid.UUID = ..., name: str | None = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + topics: list[MetadataRequestTopic] | None + allow_auto_topic_creation: bool + include_cluster_authorized_operations: bool + include_topic_authorized_operations: bool + def __init__( + self, + *args, + topics: list[MetadataRequestTopic] | None = ..., + allow_auto_topic_creation: bool = ..., + include_cluster_authorized_operations: bool = ..., + include_topic_authorized_operations: bool = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + def encode(self, version=None, header=False, framed=False): ... + +class MetadataResponse(ApiMessage): + class MetadataResponseBroker(DataContainer): + node_id: int + host: str + port: int + rack: str | None + def __init__( + self, + *args, + node_id: int = ..., + host: str = ..., + port: int = ..., + rack: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class MetadataResponseTopic(DataContainer): + class MetadataResponsePartition(DataContainer): + error_code: int + partition_index: int + leader_id: int + leader_epoch: int + replica_nodes: list[int] + isr_nodes: list[int] + offline_replicas: list[int] + def __init__( + self, + *args, + error_code: int = ..., + partition_index: int = ..., + leader_id: int = ..., + leader_epoch: int = ..., + replica_nodes: list[int] = ..., + isr_nodes: list[int] = ..., + offline_replicas: list[int] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + error_code: int + name: str | None + topic_id: uuid.UUID + is_internal: bool + partitions: list[MetadataResponsePartition] + authorized_operations: set[int] + def __init__( + self, + *args, + error_code: int = ..., + name: str | None = ..., + topic_id: uuid.UUID = ..., + is_internal: bool = ..., + partitions: list[MetadataResponsePartition] = ..., + authorized_operations: set[int] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + brokers: list[MetadataResponseBroker] + cluster_id: str | None + controller_id: int + topics: list[MetadataResponseTopic] + authorized_operations: set[int] + error_code: int + def __init__( + self, + *args, + throttle_time_ms: int = ..., + brokers: list[MetadataResponseBroker] = ..., + cluster_id: str | None = ..., + controller_id: int = ..., + topics: list[MetadataResponseTopic] = ..., + authorized_operations: set[int] = ..., + error_code: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + @classmethod + def json_patch(cls, json): ... + +__all__ = ["MetadataRequest", "MetadataResponse"] diff --git a/stubs/kafka-python/kafka/protocol/old/__init__.pyi b/stubs/kafka-python/kafka/protocol/old/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/stubs/kafka-python/kafka/protocol/abstract.pyi b/stubs/kafka-python/kafka/protocol/old/abstract.pyi similarity index 86% rename from stubs/kafka-python/kafka/protocol/abstract.pyi rename to stubs/kafka-python/kafka/protocol/old/abstract.pyi index 3229b5ccfa05..c3a45c08d62c 100644 --- a/stubs/kafka-python/kafka/protocol/abstract.pyi +++ b/stubs/kafka-python/kafka/protocol/old/abstract.pyi @@ -2,8 +2,10 @@ import abc from _typeshed import Incomplete class AbstractType(metaclass=abc.ABCMeta): + @classmethod @abc.abstractmethod def encode(cls, value): ... + @classmethod @abc.abstractmethod def decode(cls, data): ... repr: Incomplete diff --git a/stubs/kafka-python/kafka/protocol/add_offsets_to_txn.pyi b/stubs/kafka-python/kafka/protocol/old/add_offsets_to_txn.pyi similarity index 79% rename from stubs/kafka-python/kafka/protocol/add_offsets_to_txn.pyi rename to stubs/kafka-python/kafka/protocol/old/add_offsets_to_txn.pyi index 49066ce158a2..8f2c24de09a3 100644 --- a/stubs/kafka-python/kafka/protocol/add_offsets_to_txn.pyi +++ b/stubs/kafka-python/kafka/protocol/old/add_offsets_to_txn.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from kafka.protocol.api import Request, Response +from .api import Request, Response class AddOffsetsToTxnResponse_v0(Response): API_KEY: int @@ -20,19 +20,16 @@ class AddOffsetsToTxnResponse_v2(Response): class AddOffsetsToTxnRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = AddOffsetsToTxnResponse_v0 SCHEMA: Incomplete class AddOffsetsToTxnRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = AddOffsetsToTxnResponse_v1 SCHEMA: Incomplete class AddOffsetsToTxnRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = AddOffsetsToTxnResponse_v2 SCHEMA: Incomplete AddOffsetsToTxnRequest: Incomplete diff --git a/stubs/kafka-python/kafka/protocol/add_partitions_to_txn.pyi b/stubs/kafka-python/kafka/protocol/old/add_partitions_to_txn.pyi similarity index 73% rename from stubs/kafka-python/kafka/protocol/add_partitions_to_txn.pyi rename to stubs/kafka-python/kafka/protocol/old/add_partitions_to_txn.pyi index 4a1802ab6c28..455e50c13472 100644 --- a/stubs/kafka-python/kafka/protocol/add_partitions_to_txn.pyi +++ b/stubs/kafka-python/kafka/protocol/old/add_partitions_to_txn.pyi @@ -1,39 +1,45 @@ from _typeshed import Incomplete -from kafka.protocol.api import Request, Response +from .api import Request, Response class AddPartitionsToTxnResponse_v0(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class AddPartitionsToTxnResponse_v1(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class AddPartitionsToTxnResponse_v2(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class AddPartitionsToTxnRequest_v0(Request): API_KEY: int API_VERSION: int RESPONSE_TYPE = AddPartitionsToTxnResponse_v0 SCHEMA: Incomplete + ALIASES: dict[str, str] class AddPartitionsToTxnRequest_v1(Request): API_KEY: int API_VERSION: int RESPONSE_TYPE = AddPartitionsToTxnResponse_v1 SCHEMA: Incomplete + ALIASES: dict[str, str] class AddPartitionsToTxnRequest_v2(Request): API_KEY: int API_VERSION: int RESPONSE_TYPE = AddPartitionsToTxnResponse_v2 SCHEMA: Incomplete + ALIASES: dict[str, str] -AddPartitionsToTxnRequest: Incomplete -AddPartitionsToTxnResponse: Incomplete +AddPartitionsToTxnRequest: list[type[Incomplete]] +AddPartitionsToTxnResponse: list[type[Incomplete]] diff --git a/stubs/kafka-python/kafka/protocol/admin.pyi b/stubs/kafka-python/kafka/protocol/old/admin.pyi similarity index 79% rename from stubs/kafka-python/kafka/protocol/admin.pyi rename to stubs/kafka-python/kafka/protocol/old/admin.pyi index 7330c0ae74d1..d83f6efd6a50 100644 --- a/stubs/kafka-python/kafka/protocol/admin.pyi +++ b/stubs/kafka-python/kafka/protocol/old/admin.pyi @@ -1,51 +1,55 @@ from _typeshed import Incomplete from enum import IntEnum -from kafka.protocol.api import Request, Response +from .api import Request, Response class CreateTopicsResponse_v0(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class CreateTopicsResponse_v1(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class CreateTopicsResponse_v2(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class CreateTopicsResponse_v3(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class CreateTopicsRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = CreateTopicsResponse_v0 SCHEMA: Incomplete + ALIASES: dict[str, str] class CreateTopicsRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = CreateTopicsResponse_v1 SCHEMA: Incomplete + ALIASES: dict[str, str] class CreateTopicsRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = CreateTopicsResponse_v2 SCHEMA: Incomplete + ALIASES: dict[str, str] class CreateTopicsRequest_v3(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = CreateTopicsResponse_v3 SCHEMA: Incomplete + ALIASES: dict[str, str] CreateTopicsRequest: Incomplete CreateTopicsResponse: Incomplete @@ -54,45 +58,49 @@ class DeleteTopicsResponse_v0(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class DeleteTopicsResponse_v1(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class DeleteTopicsResponse_v2(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class DeleteTopicsResponse_v3(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class DeleteTopicsRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DeleteTopicsResponse_v0 SCHEMA: Incomplete + ALIASES: dict[str, str] class DeleteTopicsRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DeleteTopicsResponse_v1 SCHEMA: Incomplete + ALIASES: dict[str, str] class DeleteTopicsRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DeleteTopicsResponse_v2 SCHEMA: Incomplete + ALIASES: dict[str, str] class DeleteTopicsRequest_v3(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DeleteTopicsResponse_v3 SCHEMA: Incomplete + ALIASES: dict[str, str] DeleteTopicsRequest: Incomplete DeleteTopicsResponse: Incomplete @@ -105,7 +113,6 @@ class DeleteRecordsResponse_v0(Response): class DeleteRecordsRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DeleteRecordsResponse_v0 SCHEMA: Incomplete DeleteRecordsResponse: Incomplete @@ -129,19 +136,16 @@ class ListGroupsResponse_v2(Response): class ListGroupsRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = ListGroupsResponse_v0 SCHEMA: Incomplete class ListGroupsRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = ListGroupsResponse_v1 SCHEMA: Incomplete class ListGroupsRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = ListGroupsResponse_v2 SCHEMA: Incomplete ListGroupsRequest: Incomplete @@ -170,25 +174,21 @@ class DescribeGroupsResponse_v3(Response): class DescribeGroupsRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DescribeGroupsResponse_v0 SCHEMA: Incomplete class DescribeGroupsRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DescribeGroupsResponse_v1 SCHEMA: Incomplete class DescribeGroupsRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DescribeGroupsResponse_v2 SCHEMA: Incomplete class DescribeGroupsRequest_v3(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DescribeGroupsResponse_v3 SCHEMA: Incomplete DescribeGroupsRequest: Incomplete @@ -212,19 +212,18 @@ class DescribeAclsResponse_v2(Response): class DescribeAclsRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DescribeAclsResponse_v0 SCHEMA: Incomplete + ALIASES: dict[str, str] class DescribeAclsRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DescribeAclsResponse_v1 SCHEMA: Incomplete + ALIASES: dict[str, str] class DescribeAclsRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DescribeAclsResponse_v2 SCHEMA: Incomplete DescribeAclsRequest: Incomplete @@ -234,22 +233,22 @@ class CreateAclsResponse_v0(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class CreateAclsResponse_v1(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class CreateAclsRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = CreateAclsResponse_v0 SCHEMA: Incomplete class CreateAclsRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = CreateAclsResponse_v1 SCHEMA: Incomplete CreateAclsRequest: Incomplete @@ -259,22 +258,22 @@ class DeleteAclsResponse_v0(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class DeleteAclsResponse_v1(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class DeleteAclsRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DeleteAclsResponse_v0 SCHEMA: Incomplete class DeleteAclsRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DeleteAclsResponse_v1 SCHEMA: Incomplete DeleteAclsRequest: Incomplete @@ -284,22 +283,22 @@ class AlterConfigsResponse_v0(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class AlterConfigsResponse_v1(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class AlterConfigsRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = AlterConfigsResponse_v0 SCHEMA: Incomplete class AlterConfigsRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = AlterConfigsResponse_v1 SCHEMA: Incomplete AlterConfigsRequest: Incomplete @@ -309,33 +308,33 @@ class DescribeConfigsResponse_v0(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class DescribeConfigsResponse_v1(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class DescribeConfigsResponse_v2(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class DescribeConfigsRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DescribeConfigsResponse_v0 SCHEMA: Incomplete class DescribeConfigsRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DescribeConfigsResponse_v1 SCHEMA: Incomplete class DescribeConfigsRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DescribeConfigsResponse_v2 SCHEMA: Incomplete DescribeConfigsRequest: Incomplete @@ -345,62 +344,39 @@ class DescribeLogDirsResponse_v0(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class DescribeLogDirsRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DescribeLogDirsResponse_v0 SCHEMA: Incomplete DescribeLogDirsResponse: Incomplete DescribeLogDirsRequest: Incomplete -class SaslAuthenticateResponse_v0(Response): - API_KEY: int - API_VERSION: int - SCHEMA: Incomplete - -class SaslAuthenticateResponse_v1(Response): - API_KEY: int - API_VERSION: int - SCHEMA: Incomplete - -class SaslAuthenticateRequest_v0(Request): - API_KEY: int - API_VERSION: int - RESPONSE_TYPE = SaslAuthenticateResponse_v0 - SCHEMA: Incomplete - -class SaslAuthenticateRequest_v1(Request): - API_KEY: int - API_VERSION: int - RESPONSE_TYPE = SaslAuthenticateResponse_v1 - SCHEMA: Incomplete - -SaslAuthenticateRequest: Incomplete -SaslAuthenticateResponse: Incomplete - class CreatePartitionsResponse_v0(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class CreatePartitionsResponse_v1(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class CreatePartitionsRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = CreatePartitionsResponse_v0 SCHEMA: Incomplete + ALIASES: dict[str, str] class CreatePartitionsRequest_v1(Request): API_KEY: int API_VERSION: int SCHEMA: Incomplete - RESPONSE_TYPE = CreatePartitionsResponse_v1 + ALIASES: dict[str, str] CreatePartitionsRequest: Incomplete CreatePartitionsResponse: Incomplete @@ -418,13 +394,11 @@ class DeleteGroupsResponse_v1(Response): class DeleteGroupsRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DeleteGroupsResponse_v0 SCHEMA: Incomplete class DeleteGroupsRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DeleteGroupsResponse_v1 SCHEMA: Incomplete DeleteGroupsRequest: Incomplete @@ -438,7 +412,6 @@ class DescribeClientQuotasResponse_v0(Response): class DescribeClientQuotasRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = DescribeClientQuotasResponse_v0 SCHEMA: Incomplete DescribeClientQuotasRequest: Incomplete @@ -454,7 +427,6 @@ class AlterPartitionReassignmentsRequest_v0(Request): FLEXIBLE_VERSION: bool API_KEY: int API_VERSION: int - RESPONSE_TYPE = AlterPartitionReassignmentsResponse_v0 SCHEMA: Incomplete AlterPartitionReassignmentsRequest: Incomplete @@ -470,7 +442,6 @@ class ListPartitionReassignmentsRequest_v0(Request): FLEXIBLE_VERSION: bool API_KEY: int API_VERSION: int - RESPONSE_TYPE = ListPartitionReassignmentsResponse_v0 SCHEMA: Incomplete ListPartitionReassignmentsRequest: Incomplete @@ -480,23 +451,25 @@ class ElectLeadersResponse_v0(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class ElectLeadersRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = ElectLeadersResponse_v0 SCHEMA: Incomplete + ALIASES: dict[str, str] class ElectLeadersResponse_v1(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class ElectLeadersRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = ElectLeadersResponse_v1 SCHEMA: Incomplete + ALIASES: dict[str, str] class ElectionType(IntEnum): PREFERRED = 0 diff --git a/stubs/kafka-python/kafka/protocol/old/api.pyi b/stubs/kafka-python/kafka/protocol/old/api.pyi new file mode 100644 index 000000000000..c8732d81be39 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/old/api.pyi @@ -0,0 +1,66 @@ +import abc +from typing_extensions import Self + +from .struct import Struct +from .types import Schema + +class ResponseClassRegistry: + @classmethod + def register_response_class(cls, response_class) -> None: ... + @classmethod + def get_response_class(cls, header): ... + +class RequestHeader(ResponseClassRegistry, Struct): + SCHEMA: Schema + def get_response_class(self): ... # type: ignore[override] + +class RequestHeaderV2(ResponseClassRegistry, Struct): + SCHEMA: Schema + def get_response_class(self): ... # type: ignore[override] + +class ResponseHeader(Struct): + SCHEMA: Schema + +class ResponseHeaderV2(Struct): + SCHEMA: Schema + +class RequestResponse(Struct, metaclass=abc.ABCMeta): + def __init__(self, *args, **kwargs) -> None: ... + @property + @abc.abstractmethod + def API_KEY(self): ... + @property + @abc.abstractmethod + def API_VERSION(self): ... + def to_object(self): ... + @classmethod + @abc.abstractmethod + def is_request(cls): ... + @property + def header(self): ... + def with_header(self, correlation_id: int = 0, client_id="kafka-python") -> None: ... + def encode(self, header: bool = False, framed: bool = False) -> bytes: ... + @classmethod + @abc.abstractmethod + def header_class(cls): ... + @classmethod + def parse_header(cls, read_buffer): ... + @classmethod + def decode(cls, data, header: bool = False, framed: bool = False) -> Self: ... + def __eq__(self, other) -> bool: ... + +class Request(RequestResponse, metaclass=abc.ABCMeta): + FLEXIBLE_VERSION: bool + @classmethod + def is_request(cls): ... + def expect_response(self): ... + @classmethod + def header_class(cls): ... + +class Response(RequestResponse, metaclass=abc.ABCMeta): + FLEXIBLE_VERSION: bool + def __init_subclass__(cls, **kwargs) -> None: ... + @classmethod + def is_request(cls): ... + @classmethod + def header_class(cls): ... diff --git a/stubs/kafka-python/kafka/protocol/api_versions.pyi b/stubs/kafka-python/kafka/protocol/old/api_versions.pyi similarity index 81% rename from stubs/kafka-python/kafka/protocol/api_versions.pyi rename to stubs/kafka-python/kafka/protocol/old/api_versions.pyi index 2d1a480aba34..d71419ac2134 100644 --- a/stubs/kafka-python/kafka/protocol/api_versions.pyi +++ b/stubs/kafka-python/kafka/protocol/old/api_versions.pyi @@ -1,18 +1,20 @@ from _typeshed import Incomplete -from kafka.protocol.api import Request, Response +from .api import Request, Response class BaseApiVersionsResponse(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] @classmethod - def decode(cls, data): ... + def decode(cls, data, header: bool = False, framed: bool = False): ... class ApiVersionsResponse_v0(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class ApiVersionsResponse_v1(BaseApiVersionsResponse): API_KEY: int @@ -37,32 +39,27 @@ class ApiVersionsResponse_v4(BaseApiVersionsResponse): class ApiVersionsRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = ApiVersionsResponse_v0 SCHEMA: Incomplete class ApiVersionsRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = ApiVersionsResponse_v1 SCHEMA: Incomplete class ApiVersionsRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = ApiVersionsResponse_v2 SCHEMA: Incomplete class ApiVersionsRequest_v3(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = ApiVersionsResponse_v3 SCHEMA: Incomplete FLEXIBLE_VERSION: bool class ApiVersionsRequest_v4(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = ApiVersionsResponse_v4 SCHEMA: Incomplete FLEXIBLE_VERSION: bool diff --git a/stubs/kafka-python/kafka/protocol/commit.pyi b/stubs/kafka-python/kafka/protocol/old/commit.pyi similarity index 82% rename from stubs/kafka-python/kafka/protocol/commit.pyi rename to stubs/kafka-python/kafka/protocol/old/commit.pyi index 1d3c08d81410..f3bf34359f36 100644 --- a/stubs/kafka-python/kafka/protocol/commit.pyi +++ b/stubs/kafka-python/kafka/protocol/old/commit.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from kafka.protocol.api import Request, Response +from .api import Request, Response class OffsetCommitResponse_v0(Response): API_KEY: int @@ -45,53 +45,53 @@ class OffsetCommitResponse_v7(Response): class OffsetCommitRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = OffsetCommitResponse_v0 SCHEMA: Incomplete + ALIASES: dict[str, str] class OffsetCommitRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = OffsetCommitResponse_v1 SCHEMA: Incomplete + ALIASES: dict[str, str] class OffsetCommitRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = OffsetCommitResponse_v2 SCHEMA: Incomplete DEFAULT_RETENTION_TIME: int + ALIASES: dict[str, str] class OffsetCommitRequest_v3(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = OffsetCommitResponse_v3 SCHEMA: Incomplete DEFAULT_RETENTION_TIME: int + ALIASES: dict[str, str] class OffsetCommitRequest_v4(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = OffsetCommitResponse_v4 SCHEMA: Incomplete DEFAULT_RETENTION_TIME: int + ALIASES: dict[str, str] class OffsetCommitRequest_v5(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = OffsetCommitResponse_v5 SCHEMA: Incomplete + ALIASES: dict[str, str] class OffsetCommitRequest_v6(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = OffsetCommitResponse_v6 SCHEMA: Incomplete + ALIASES: dict[str, str] class OffsetCommitRequest_v7(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = OffsetCommitResponse_v7 SCHEMA: Incomplete + ALIASES: dict[str, str] OffsetCommitRequest: Incomplete OffsetCommitResponse: Incomplete @@ -129,38 +129,38 @@ class OffsetFetchResponse_v5(Response): class OffsetFetchRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = OffsetFetchResponse_v0 SCHEMA: Incomplete + ALIASES: dict[str, str] class OffsetFetchRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = OffsetFetchResponse_v1 SCHEMA: Incomplete + ALIASES: dict[str, str] class OffsetFetchRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = OffsetFetchResponse_v2 SCHEMA: Incomplete + ALIASES: dict[str, str] class OffsetFetchRequest_v3(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = OffsetFetchResponse_v3 SCHEMA: Incomplete + ALIASES: dict[str, str] class OffsetFetchRequest_v4(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = OffsetFetchResponse_v4 SCHEMA: Incomplete + ALIASES: dict[str, str] class OffsetFetchRequest_v5(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = OffsetFetchResponse_v5 SCHEMA: Incomplete + ALIASES: dict[str, str] OffsetFetchRequest: Incomplete OffsetFetchResponse: Incomplete diff --git a/stubs/kafka-python/kafka/coordinator/protocol.pyi b/stubs/kafka-python/kafka/protocol/old/consumer_protocol.pyi similarity index 90% rename from stubs/kafka-python/kafka/coordinator/protocol.pyi rename to stubs/kafka-python/kafka/protocol/old/consumer_protocol.pyi index c099575b5c88..f5b6721a0d45 100644 --- a/stubs/kafka-python/kafka/coordinator/protocol.pyi +++ b/stubs/kafka-python/kafka/protocol/old/consumer_protocol.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from kafka.protocol.struct import Struct +from .struct import Struct class ConsumerProtocolMemberMetadata_v0(Struct): SCHEMA: Incomplete diff --git a/stubs/kafka-python/kafka/protocol/end_txn.pyi b/stubs/kafka-python/kafka/protocol/old/end_txn.pyi similarity index 80% rename from stubs/kafka-python/kafka/protocol/end_txn.pyi rename to stubs/kafka-python/kafka/protocol/old/end_txn.pyi index 07ba52aa0f26..541f89bfb43e 100644 --- a/stubs/kafka-python/kafka/protocol/end_txn.pyi +++ b/stubs/kafka-python/kafka/protocol/old/end_txn.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from kafka.protocol.api import Request, Response +from .api import Request, Response class EndTxnResponse_v0(Response): API_KEY: int @@ -20,19 +20,16 @@ class EndTxnResponse_v2(Response): class EndTxnRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = EndTxnResponse_v0 SCHEMA: Incomplete class EndTxnRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = EndTxnResponse_v1 SCHEMA: Incomplete class EndTxnRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = EndTxnResponse_v2 SCHEMA: Incomplete EndTxnRequest: Incomplete diff --git a/stubs/kafka-python/kafka/protocol/fetch.pyi b/stubs/kafka-python/kafka/protocol/old/fetch.pyi similarity index 77% rename from stubs/kafka-python/kafka/protocol/fetch.pyi rename to stubs/kafka-python/kafka/protocol/old/fetch.pyi index e110f1557fcc..f5eed746b22d 100644 --- a/stubs/kafka-python/kafka/protocol/fetch.pyi +++ b/stubs/kafka-python/kafka/protocol/old/fetch.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete from typing import NamedTuple -from kafka.protocol.api import Request, Response +from .api import Request, Response class AbortedTransaction(NamedTuple): producer_id: Incomplete @@ -11,133 +11,145 @@ class FetchResponse_v0(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchResponse_v1(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchResponse_v2(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchResponse_v3(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchResponse_v4(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchResponse_v5(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchResponse_v6(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchResponse_v7(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchResponse_v8(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchResponse_v9(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchResponse_v10(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchResponse_v11(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = FetchResponse_v0 SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = FetchResponse_v1 SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = FetchResponse_v2 SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchRequest_v3(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = FetchResponse_v3 SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchRequest_v4(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = FetchResponse_v4 SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchRequest_v5(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = FetchResponse_v5 SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchRequest_v6(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = FetchResponse_v6 SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchRequest_v7(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = FetchResponse_v7 SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchRequest_v8(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = FetchResponse_v8 SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchRequest_v9(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = FetchResponse_v9 SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchRequest_v10(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = FetchResponse_v10 SCHEMA: Incomplete + ALIASES: dict[str, str] class FetchRequest_v11(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = FetchResponse_v11 SCHEMA: Incomplete + ALIASES: dict[str, str] FetchRequest: Incomplete FetchResponse: Incomplete diff --git a/stubs/kafka-python/kafka/protocol/find_coordinator.pyi b/stubs/kafka-python/kafka/protocol/old/find_coordinator.pyi similarity index 78% rename from stubs/kafka-python/kafka/protocol/find_coordinator.pyi rename to stubs/kafka-python/kafka/protocol/old/find_coordinator.pyi index bd121a8d50ab..8e46974cc93a 100644 --- a/stubs/kafka-python/kafka/protocol/find_coordinator.pyi +++ b/stubs/kafka-python/kafka/protocol/old/find_coordinator.pyi @@ -1,39 +1,42 @@ from _typeshed import Incomplete -from kafka.protocol.api import Request, Response +from .api import Request, Response class FindCoordinatorResponse_v0(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class FindCoordinatorResponse_v1(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class FindCoordinatorResponse_v2(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class FindCoordinatorRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = FindCoordinatorResponse_v0 SCHEMA: Incomplete + ALIASES: dict[str, str] class FindCoordinatorRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = FindCoordinatorResponse_v1 SCHEMA: Incomplete + ALIASES: dict[str, str] class FindCoordinatorRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = FindCoordinatorResponse_v2 SCHEMA: Incomplete + ALIASES: dict[str, str] FindCoordinatorRequest: Incomplete FindCoordinatorResponse: Incomplete diff --git a/stubs/kafka-python/kafka/protocol/group.pyi b/stubs/kafka-python/kafka/protocol/old/group.pyi similarity index 80% rename from stubs/kafka-python/kafka/protocol/group.pyi rename to stubs/kafka-python/kafka/protocol/old/group.pyi index 8cfd38e655a3..010931be6a9b 100644 --- a/stubs/kafka-python/kafka/protocol/group.pyi +++ b/stubs/kafka-python/kafka/protocol/old/group.pyi @@ -1,82 +1,88 @@ from _typeshed import Incomplete -from typing import NamedTuple +from typing import Final, NamedTuple -from kafka.protocol.api import Request, Response -from kafka.protocol.struct import Struct +from .api import Request, Response +from .struct import Struct -DEFAULT_GENERATION_ID: int -UNKNOWN_MEMBER_ID: str +DEFAULT_GENERATION_ID: Final = -1 +UNKNOWN_MEMBER_ID: Final = "" class GroupMember(NamedTuple): member_id: Incomplete = ... group_instance_id: Incomplete = ... - metadata_bytes: Incomplete = ... + metadata: Incomplete = ... class JoinGroupResponse_v0(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class JoinGroupResponse_v1(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class JoinGroupResponse_v2(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class JoinGroupResponse_v3(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class JoinGroupResponse_v4(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class JoinGroupResponse_v5(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class JoinGroupRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = JoinGroupResponse_v0 SCHEMA: Incomplete + ALIASES: dict[str, str] class JoinGroupRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = JoinGroupResponse_v1 SCHEMA: Incomplete + ALIASES: dict[str, str] class JoinGroupRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = JoinGroupResponse_v2 SCHEMA: Incomplete + ALIASES: dict[str, str] class JoinGroupRequest_v3(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = JoinGroupResponse_v3 SCHEMA: Incomplete + ALIASES: dict[str, str] class JoinGroupRequest_v4(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = JoinGroupResponse_v4 SCHEMA: Incomplete + ALIASES: dict[str, str] class JoinGroupRequest_v5(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = JoinGroupResponse_v5 SCHEMA: Incomplete + ALIASES: dict[str, str] JoinGroupRequest: Incomplete JoinGroupResponse: Incomplete @@ -88,45 +94,49 @@ class SyncGroupResponse_v0(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class SyncGroupResponse_v1(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class SyncGroupResponse_v2(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class SyncGroupResponse_v3(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class SyncGroupRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = SyncGroupResponse_v0 SCHEMA: Incomplete + ALIASES: dict[str, str] class SyncGroupRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = SyncGroupResponse_v1 SCHEMA: Incomplete + ALIASES: dict[str, str] class SyncGroupRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = SyncGroupResponse_v2 SCHEMA: Incomplete + ALIASES: dict[str, str] class SyncGroupRequest_v3(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = SyncGroupResponse_v3 SCHEMA: Incomplete + ALIASES: dict[str, str] SyncGroupRequest: Incomplete SyncGroupResponse: Incomplete @@ -157,26 +167,26 @@ class HeartbeatResponse_v3(Response): class HeartbeatRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = HeartbeatResponse_v0 SCHEMA: Incomplete + ALIASES: dict[str, str] class HeartbeatRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = HeartbeatResponse_v1 SCHEMA: Incomplete + ALIASES: dict[str, str] class HeartbeatRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = HeartbeatResponse_v2 SCHEMA: Incomplete + ALIASES: dict[str, str] class HeartbeatRequest_v3(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = HeartbeatResponse_v3 SCHEMA: Incomplete + ALIASES: dict[str, str] HeartbeatRequest: Incomplete HeartbeatResponse: Incomplete @@ -204,26 +214,26 @@ class LeaveGroupResponse_v3(Response): class LeaveGroupRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = LeaveGroupResponse_v0 SCHEMA: Incomplete + ALIASES: dict[str, str] class LeaveGroupRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = LeaveGroupResponse_v1 SCHEMA: Incomplete + ALIASES: dict[str, str] class LeaveGroupRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = LeaveGroupResponse_v2 SCHEMA: Incomplete + ALIASES: dict[str, str] class LeaveGroupRequest_v3(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = LeaveGroupResponse_v3 SCHEMA: Incomplete + ALIASES: dict[str, str] LeaveGroupRequest: Incomplete LeaveGroupResponse: Incomplete diff --git a/stubs/kafka-python/kafka/protocol/init_producer_id.pyi b/stubs/kafka-python/kafka/protocol/old/init_producer_id.pyi similarity index 78% rename from stubs/kafka-python/kafka/protocol/init_producer_id.pyi rename to stubs/kafka-python/kafka/protocol/old/init_producer_id.pyi index 0025ce3e33c7..39108d004f3a 100644 --- a/stubs/kafka-python/kafka/protocol/init_producer_id.pyi +++ b/stubs/kafka-python/kafka/protocol/old/init_producer_id.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from kafka.protocol.api import Request, Response +from .api import Request, Response class InitProducerIdResponse_v0(Response): API_KEY: int @@ -15,13 +15,11 @@ class InitProducerIdResponse_v1(Response): class InitProducerIdRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = InitProducerIdResponse_v0 SCHEMA: Incomplete class InitProducerIdRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = InitProducerIdResponse_v1 SCHEMA: Incomplete InitProducerIdRequest: Incomplete diff --git a/stubs/kafka-python/kafka/protocol/list_offsets.pyi b/stubs/kafka-python/kafka/protocol/old/list_offsets.pyi similarity index 82% rename from stubs/kafka-python/kafka/protocol/list_offsets.pyi rename to stubs/kafka-python/kafka/protocol/old/list_offsets.pyi index f8fe7767e0b3..78b6568bd9a8 100644 --- a/stubs/kafka-python/kafka/protocol/list_offsets.pyi +++ b/stubs/kafka-python/kafka/protocol/old/list_offsets.pyi @@ -1,8 +1,9 @@ from _typeshed import Incomplete +from typing import Final -from kafka.protocol.api import Request, Response +from .api import Request, Response -UNKNOWN_OFFSET: int +UNKNOWN_OFFSET: Final = -1 class OffsetResetStrategy: LATEST: int @@ -42,42 +43,36 @@ class ListOffsetsResponse_v5(Response): class ListOffsetsRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = ListOffsetsResponse_v0 SCHEMA: Incomplete DEFAULTS: Incomplete class ListOffsetsRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = ListOffsetsResponse_v1 SCHEMA: Incomplete DEFAULTS: Incomplete class ListOffsetsRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = ListOffsetsResponse_v2 SCHEMA: Incomplete DEFAULTS: Incomplete class ListOffsetsRequest_v3(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = ListOffsetsResponse_v3 SCHEMA: Incomplete DEFAULTS: Incomplete class ListOffsetsRequest_v4(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = ListOffsetsResponse_v4 SCHEMA: Incomplete DEFAULTS: Incomplete class ListOffsetsRequest_v5(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = ListOffsetsResponse_v5 SCHEMA: Incomplete DEFAULTS: Incomplete diff --git a/stubs/kafka-python/kafka/protocol/metadata.pyi b/stubs/kafka-python/kafka/protocol/old/metadata.pyi similarity index 85% rename from stubs/kafka-python/kafka/protocol/metadata.pyi rename to stubs/kafka-python/kafka/protocol/old/metadata.pyi index 429ef2d111d6..81d377e60348 100644 --- a/stubs/kafka-python/kafka/protocol/metadata.pyi +++ b/stubs/kafka-python/kafka/protocol/old/metadata.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from kafka.protocol.api import Request, Response +from .api import Request, Response class MetadataResponse_v0(Response): API_KEY: int @@ -50,7 +50,6 @@ class MetadataResponse_v8(Response): class MetadataRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = MetadataResponse_v0 SCHEMA: Incomplete ALL_TOPICS: Incomplete NO_TOPICS: Incomplete @@ -58,7 +57,6 @@ class MetadataRequest_v0(Request): class MetadataRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = MetadataResponse_v1 SCHEMA: Incomplete ALL_TOPICS: Incomplete NO_TOPICS: Incomplete @@ -66,7 +64,6 @@ class MetadataRequest_v1(Request): class MetadataRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = MetadataResponse_v2 SCHEMA: Incomplete ALL_TOPICS: Incomplete NO_TOPICS: Incomplete @@ -74,7 +71,6 @@ class MetadataRequest_v2(Request): class MetadataRequest_v3(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = MetadataResponse_v3 SCHEMA: Incomplete ALL_TOPICS: Incomplete NO_TOPICS: Incomplete @@ -82,7 +78,6 @@ class MetadataRequest_v3(Request): class MetadataRequest_v4(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = MetadataResponse_v4 SCHEMA: Incomplete ALL_TOPICS: Incomplete NO_TOPICS: Incomplete @@ -90,7 +85,6 @@ class MetadataRequest_v4(Request): class MetadataRequest_v5(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = MetadataResponse_v5 SCHEMA: Incomplete ALL_TOPICS: Incomplete NO_TOPICS: Incomplete @@ -98,7 +92,6 @@ class MetadataRequest_v5(Request): class MetadataRequest_v6(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = MetadataResponse_v6 SCHEMA: Incomplete ALL_TOPICS: Incomplete NO_TOPICS: Incomplete @@ -106,7 +99,6 @@ class MetadataRequest_v6(Request): class MetadataRequest_v7(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = MetadataResponse_v7 SCHEMA: Incomplete ALL_TOPICS: Incomplete NO_TOPICS: Incomplete @@ -114,7 +106,6 @@ class MetadataRequest_v7(Request): class MetadataRequest_v8(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = MetadataResponse_v8 SCHEMA: Incomplete ALL_TOPICS: Incomplete NO_TOPICS: Incomplete diff --git a/stubs/kafka-python/kafka/protocol/offset_for_leader_epoch.pyi b/stubs/kafka-python/kafka/protocol/old/offset_for_leader_epoch.pyi similarity index 79% rename from stubs/kafka-python/kafka/protocol/offset_for_leader_epoch.pyi rename to stubs/kafka-python/kafka/protocol/old/offset_for_leader_epoch.pyi index 2d0c5e9aee2f..410081d1edb1 100644 --- a/stubs/kafka-python/kafka/protocol/offset_for_leader_epoch.pyi +++ b/stubs/kafka-python/kafka/protocol/old/offset_for_leader_epoch.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from kafka.protocol.api import Request, Response +from .api import Request, Response class OffsetForLeaderEpochResponse_v0(Response): API_KEY: int @@ -30,31 +30,26 @@ class OffsetForLeaderEpochResponse_v4(Response): class OffsetForLeaderEpochRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = OffsetForLeaderEpochResponse_v0 SCHEMA: Incomplete class OffsetForLeaderEpochRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = OffsetForLeaderEpochResponse_v1 SCHEMA: Incomplete class OffsetForLeaderEpochRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = OffsetForLeaderEpochResponse_v2 SCHEMA: Incomplete class OffsetForLeaderEpochRequest_v3(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = OffsetForLeaderEpochResponse_v3 SCHEMA: Incomplete class OffsetForLeaderEpochRequest_v4(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = OffsetForLeaderEpochResponse_v4 SCHEMA: Incomplete OffsetForLeaderEpochRequest: Incomplete diff --git a/stubs/kafka-python/kafka/protocol/produce.pyi b/stubs/kafka-python/kafka/protocol/old/produce.pyi similarity index 78% rename from stubs/kafka-python/kafka/protocol/produce.pyi rename to stubs/kafka-python/kafka/protocol/old/produce.pyi index 7652fbf6be7c..351682500a67 100644 --- a/stubs/kafka-python/kafka/protocol/produce.pyi +++ b/stubs/kafka-python/kafka/protocol/old/produce.pyi @@ -2,52 +2,61 @@ import abc from _typeshed import Incomplete from typing import type_check_only -from kafka.protocol.api import Request, Response +from .api import Request, Response class ProduceResponse_v0(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class ProduceResponse_v1(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class ProduceResponse_v2(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class ProduceResponse_v3(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class ProduceResponse_v4(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class ProduceResponse_v5(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class ProduceResponse_v6(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class ProduceResponse_v7(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class ProduceResponse_v8(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] @type_check_only class _ProduceRequest(Request, metaclass=abc.ABCMeta): @@ -56,48 +65,48 @@ class _ProduceRequest(Request, metaclass=abc.ABCMeta): class ProduceRequest_v0(_ProduceRequest): API_VERSION: int - RESPONSE_TYPE = ProduceResponse_v0 SCHEMA: Incomplete + ALIASES: dict[str, str] class ProduceRequest_v1(_ProduceRequest): API_VERSION: int - RESPONSE_TYPE = ProduceResponse_v1 SCHEMA: Incomplete + ALIASES: dict[str, str] class ProduceRequest_v2(_ProduceRequest): API_VERSION: int - RESPONSE_TYPE = ProduceResponse_v2 SCHEMA: Incomplete + ALIASES: dict[str, str] class ProduceRequest_v3(_ProduceRequest): API_VERSION: int - RESPONSE_TYPE = ProduceResponse_v3 SCHEMA: Incomplete + ALIASES: dict[str, str] class ProduceRequest_v4(_ProduceRequest): API_VERSION: int - RESPONSE_TYPE = ProduceResponse_v4 SCHEMA: Incomplete + ALIASES: dict[str, str] class ProduceRequest_v5(_ProduceRequest): API_VERSION: int - RESPONSE_TYPE = ProduceResponse_v5 SCHEMA: Incomplete + ALIASES: dict[str, str] class ProduceRequest_v6(_ProduceRequest): API_VERSION: int - RESPONSE_TYPE = ProduceResponse_v6 SCHEMA: Incomplete + ALIASES: dict[str, str] class ProduceRequest_v7(_ProduceRequest): API_VERSION: int - RESPONSE_TYPE = ProduceResponse_v7 SCHEMA: Incomplete + ALIASES: dict[str, str] class ProduceRequest_v8(_ProduceRequest): API_VERSION: int - RESPONSE_TYPE = ProduceResponse_v8 SCHEMA: Incomplete + ALIASES: dict[str, str] ProduceRequest: list[type[_ProduceRequest]] ProduceResponse: Incomplete diff --git a/stubs/kafka-python/kafka/protocol/sasl_authenticate.pyi b/stubs/kafka-python/kafka/protocol/old/sasl_authenticate.pyi similarity index 78% rename from stubs/kafka-python/kafka/protocol/sasl_authenticate.pyi rename to stubs/kafka-python/kafka/protocol/old/sasl_authenticate.pyi index da9781407f5b..e49adbc9d788 100644 --- a/stubs/kafka-python/kafka/protocol/sasl_authenticate.pyi +++ b/stubs/kafka-python/kafka/protocol/old/sasl_authenticate.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from kafka.protocol.api import Request, Response +from .api import Request, Response class SaslAuthenticateResponse_v0(Response): API_KEY: int @@ -15,13 +15,11 @@ class SaslAuthenticateResponse_v1(Response): class SaslAuthenticateRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = SaslAuthenticateResponse_v0 SCHEMA: Incomplete class SaslAuthenticateRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = SaslAuthenticateResponse_v1 SCHEMA: Incomplete SaslAuthenticateRequest: Incomplete diff --git a/stubs/kafka-python/kafka/protocol/sasl_handshake.pyi b/stubs/kafka-python/kafka/protocol/old/sasl_handshake.pyi similarity index 78% rename from stubs/kafka-python/kafka/protocol/sasl_handshake.pyi rename to stubs/kafka-python/kafka/protocol/old/sasl_handshake.pyi index dad4e65bea5b..04281eb3b053 100644 --- a/stubs/kafka-python/kafka/protocol/sasl_handshake.pyi +++ b/stubs/kafka-python/kafka/protocol/old/sasl_handshake.pyi @@ -1,27 +1,27 @@ from _typeshed import Incomplete -from kafka.protocol.api import Request, Response +from .api import Request, Response class SaslHandshakeResponse_v0(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class SaslHandshakeResponse_v1(Response): API_KEY: int API_VERSION: int SCHEMA: Incomplete + ALIASES: dict[str, str] class SaslHandshakeRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = SaslHandshakeResponse_v0 SCHEMA: Incomplete class SaslHandshakeRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = SaslHandshakeResponse_v1 SCHEMA: Incomplete SaslHandshakeRequest: Incomplete diff --git a/stubs/kafka-python/kafka/protocol/old/struct.pyi b/stubs/kafka-python/kafka/protocol/old/struct.pyi new file mode 100644 index 000000000000..aa8c11dee6e7 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/old/struct.pyi @@ -0,0 +1,15 @@ +import abc +from typing_extensions import Self + +class Struct(metaclass=abc.ABCMeta): + @property + @abc.abstractmethod + def SCHEMA(self): ... + ALIASES: dict[str, str] + def __init__(self, *args, **kwargs) -> None: ... + def encode(self): ... + @classmethod + def decode(cls, data) -> Self: ... + def get_item(self, name): ... + def __hash__(self) -> int: ... + def __eq__(self, other) -> bool: ... diff --git a/stubs/kafka-python/kafka/protocol/txn_offset_commit.pyi b/stubs/kafka-python/kafka/protocol/old/txn_offset_commit.pyi similarity index 79% rename from stubs/kafka-python/kafka/protocol/txn_offset_commit.pyi rename to stubs/kafka-python/kafka/protocol/old/txn_offset_commit.pyi index d9b035c097da..faa3f73980fe 100644 --- a/stubs/kafka-python/kafka/protocol/txn_offset_commit.pyi +++ b/stubs/kafka-python/kafka/protocol/old/txn_offset_commit.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from kafka.protocol.api import Request, Response +from .api import Request, Response class TxnOffsetCommitResponse_v0(Response): API_KEY: int @@ -20,19 +20,16 @@ class TxnOffsetCommitResponse_v2(Response): class TxnOffsetCommitRequest_v0(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = TxnOffsetCommitResponse_v0 SCHEMA: Incomplete class TxnOffsetCommitRequest_v1(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = TxnOffsetCommitResponse_v1 SCHEMA: Incomplete class TxnOffsetCommitRequest_v2(Request): API_KEY: int API_VERSION: int - RESPONSE_TYPE = TxnOffsetCommitResponse_v2 SCHEMA: Incomplete TxnOffsetCommitRequest: Incomplete diff --git a/stubs/kafka-python/kafka/protocol/types.pyi b/stubs/kafka-python/kafka/protocol/old/types.pyi similarity index 72% rename from stubs/kafka-python/kafka/protocol/types.pyi rename to stubs/kafka-python/kafka/protocol/old/types.pyi index d1cc891ab005..4fa526218d1f 100644 --- a/stubs/kafka-python/kafka/protocol/types.pyi +++ b/stubs/kafka-python/kafka/protocol/old/types.pyi @@ -1,6 +1,8 @@ +import uuid from _typeshed import Incomplete +from typing import Final -from kafka.protocol.abstract import AbstractType as AbstractType +from .abstract import AbstractType as AbstractType class Int8(AbstractType): @classmethod @@ -32,11 +34,18 @@ class Float64(AbstractType): @classmethod def decode(cls, data): ... +class UUID(AbstractType): + ZERO_UUID: Final[uuid.UUID] + @classmethod + def encode(cls, value) -> bytes: ... + @classmethod + def decode(cls, data) -> uuid.UUID: ... + class String(AbstractType): encoding: Incomplete def __init__(self, encoding: str = "utf-8") -> None: ... - def encode(self, value): ... - def decode(self, data): ... + def encode(self, value): ... # type: ignore[override] + def decode(self, data): ... # type: ignore[override] class Bytes(AbstractType): @classmethod @@ -54,16 +63,17 @@ class Boolean(AbstractType): class Schema(AbstractType): def __init__(self, *fields) -> None: ... - def encode(self, item): ... - def decode(self, data): ... + def has_tagged_fields(self): ... + def encode(self, item): ... # type: ignore[override] + def decode(self, data): ... # type: ignore[override] def __len__(self) -> int: ... def repr(self, value): ... class Array(AbstractType): array_of: Incomplete def __init__(self, *array_of) -> None: ... - def encode(self, items): ... - def decode(self, data): ... + def encode(self, items): ... # type: ignore[override] + def decode(self, data): ... # type: ignore[override] def repr(self, list_of_items): ... class UnsignedVarInt32(AbstractType): @@ -85,8 +95,8 @@ class VarInt64(AbstractType): def encode(cls, value): ... class CompactString(String): - def decode(self, data): ... - def encode(self, value): ... + def decode(self, data): ... # type: ignore[override] + def encode(self, value): ... # type: ignore[override] class TaggedFields(AbstractType): @classmethod @@ -101,8 +111,8 @@ class CompactBytes(AbstractType): def encode(cls, value): ... class CompactArray(Array): - def encode(self, items): ... - def decode(self, data): ... + def encode(self, items): ... # type: ignore[override] + def decode(self, data): ... # type: ignore[override] class BitField(AbstractType): @classmethod diff --git a/stubs/kafka-python/kafka/protocol/parser.pyi b/stubs/kafka-python/kafka/protocol/parser.pyi index 63c350d3ee55..b67f05b9cac9 100644 --- a/stubs/kafka-python/kafka/protocol/parser.pyi +++ b/stubs/kafka-python/kafka/protocol/parser.pyi @@ -1,15 +1,10 @@ from _typeshed import Incomplete from collections import deque -from logging import Logger - -log: Logger class KafkaProtocol: in_flight_requests: deque[tuple[int, Incomplete]] bytes_to_send: list[bytes] - def __init__( - self, client_id: str | None = None, api_version: tuple[int, int, int] | None = None, max_frame_size: int = 100000000 - ) -> None: ... + def __init__(self, *, client_id: str = ..., ident: str = "", receive_message_max_bytes: int = 100000000) -> None: ... def send_request(self, request, correlation_id: int | None = None) -> int: ... def send_bytes(self) -> bytes: ... - def receive_bytes(self, data: bytes) -> list[Incomplete]: ... + def receive_bytes(self, data: bytes) -> list[tuple[Incomplete, Incomplete]]: ... diff --git a/stubs/kafka-python/kafka/protocol/producer/__init__.pyi b/stubs/kafka-python/kafka/protocol/producer/__init__.pyi new file mode 100644 index 000000000000..1661cb819399 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/producer/__init__.pyi @@ -0,0 +1,19 @@ +from .produce import * +from .transaction import * + +__all__ = [ + "ProduceRequest", + "ProduceResponse", + "InitProducerIdRequest", + "InitProducerIdResponse", + "AddPartitionsToTxnRequest", + "AddPartitionsToTxnResponse", + "AddOffsetsToTxnRequest", + "AddOffsetsToTxnResponse", + "EndTxnRequest", + "EndTxnResponse", + "TxnOffsetCommitRequest", + "TxnOffsetCommitResponse", + "WriteTxnMarkersRequest", + "WriteTxnMarkersResponse", +] diff --git a/stubs/kafka-python/kafka/protocol/producer/produce.pyi b/stubs/kafka-python/kafka/protocol/producer/produce.pyi new file mode 100644 index 000000000000..bf73051392c3 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/producer/produce.pyi @@ -0,0 +1,185 @@ +import uuid +from _typeshed import Incomplete + +from kafka.protocol.api_data import ApiData +from kafka.protocol.api_message import ApiMessage +from kafka.protocol.data_container import DataContainer + +class ProduceRequest(ApiMessage): + class TopicProduceData(DataContainer): + class PartitionProduceData(DataContainer): + index: int + records: bytes | ApiData | None + def __init__( + self, *args, index: int = ..., records: bytes | ApiData | None = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + topic_id: uuid.UUID + partition_data: list[PartitionProduceData] + def __init__( + self, + *args, + name: str = ..., + topic_id: uuid.UUID = ..., + partition_data: list[PartitionProduceData] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + transactional_id: str | None + acks: int + timeout_ms: int + topic_data: list[TopicProduceData] + def __init__( + self, + *args, + transactional_id: str | None = ..., + acks: int = ..., + timeout_ms: int = ..., + topic_data: list[TopicProduceData] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + def expect_response(self) -> bool: ... + +class ProduceResponse(ApiMessage): + class TopicProduceResponse(DataContainer): + class PartitionProduceResponse(DataContainer): + class BatchIndexAndErrorMessage(DataContainer): + batch_index: int + batch_index_error_message: str | None + def __init__( + self, + *args, + batch_index: int = ..., + batch_index_error_message: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class LeaderIdAndEpoch(DataContainer): + leader_id: int + leader_epoch: int + def __init__( + self, *args, leader_id: int = ..., leader_epoch: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + index: int + error_code: int + base_offset: int + log_append_time_ms: int + log_start_offset: int + record_errors: list[BatchIndexAndErrorMessage] + error_message: str | None + current_leader: LeaderIdAndEpoch + def __init__( + self, + *args, + index: int = ..., + error_code: int = ..., + base_offset: int = ..., + log_append_time_ms: int = ..., + log_start_offset: int = ..., + record_errors: list[BatchIndexAndErrorMessage] = ..., + error_message: str | None = ..., + current_leader: LeaderIdAndEpoch = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + topic_id: uuid.UUID + partition_responses: list[PartitionProduceResponse] + def __init__( + self, + *args, + name: str = ..., + topic_id: uuid.UUID = ..., + partition_responses: list[PartitionProduceResponse] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class NodeEndpoint(DataContainer): + node_id: int + host: str + port: int + rack: str | None + def __init__( + self, + *args, + node_id: int = ..., + host: str = ..., + port: int = ..., + rack: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + responses: list[TopicProduceResponse] + throttle_time_ms: int + node_endpoints: list[NodeEndpoint] + def __init__( + self, + *args, + responses: list[TopicProduceResponse] = ..., + throttle_time_ms: int = ..., + node_endpoints: list[NodeEndpoint] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +__all__ = ["ProduceRequest", "ProduceResponse"] diff --git a/stubs/kafka-python/kafka/protocol/producer/transaction.pyi b/stubs/kafka-python/kafka/protocol/producer/transaction.pyi new file mode 100644 index 000000000000..ccb56a9aa031 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/producer/transaction.pyi @@ -0,0 +1,620 @@ +from _typeshed import Incomplete + +from kafka.protocol.api_message import ApiMessage +from kafka.protocol.data_container import DataContainer + +class InitProducerIdRequest(ApiMessage): + transactional_id: str | None + transaction_timeout_ms: int + producer_id: int + producer_epoch: int + enable2_pc: bool + keep_prepared_txn: bool + def __init__( + self, + *args, + transactional_id: str | None = ..., + transaction_timeout_ms: int = ..., + producer_id: int = ..., + producer_epoch: int = ..., + enable2_pc: bool = ..., + keep_prepared_txn: bool = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class InitProducerIdResponse(ApiMessage): + throttle_time_ms: int + error_code: int + producer_id: int + producer_epoch: int + ongoing_txn_producer_id: int + ongoing_txn_producer_epoch: int + def __init__( + self, + *args, + throttle_time_ms: int = ..., + error_code: int = ..., + producer_id: int = ..., + producer_epoch: int = ..., + ongoing_txn_producer_id: int = ..., + ongoing_txn_producer_epoch: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class AddPartitionsToTxnRequest(ApiMessage): + class AddPartitionsToTxnTransaction(DataContainer): + class AddPartitionsToTxnTopic(DataContainer): + name: str + partitions: list[int] + def __init__( + self, *args, name: str = ..., partitions: list[int] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + transactional_id: str + producer_id: int + producer_epoch: int + verify_only: bool + topics: list[AddPartitionsToTxnTopic] + def __init__( + self, + *args, + transactional_id: str = ..., + producer_id: int = ..., + producer_epoch: int = ..., + verify_only: bool = ..., + topics: list[AddPartitionsToTxnTopic] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class AddPartitionsToTxnTopic(DataContainer): + name: str + partitions: list[int] + def __init__(self, *args, name: str = ..., partitions: list[int] = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + transactions: list[AddPartitionsToTxnTransaction] + v3_and_below_transactional_id: str + v3_and_below_producer_id: int + v3_and_below_producer_epoch: int + v3_and_below_topics: list[AddPartitionsToTxnTopic] + def __init__( + self, + *args, + transactions: list[AddPartitionsToTxnTransaction] = ..., + v3_and_below_transactional_id: str = ..., + v3_and_below_producer_id: int = ..., + v3_and_below_producer_epoch: int = ..., + v3_and_below_topics: list[AddPartitionsToTxnTopic] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class AddPartitionsToTxnResponse(ApiMessage): + class AddPartitionsToTxnResult(DataContainer): + class AddPartitionsToTxnTopicResult(DataContainer): + class AddPartitionsToTxnPartitionResult(DataContainer): + partition_index: int + partition_error_code: int + def __init__( + self, *args, partition_index: int = ..., partition_error_code: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + results_by_partition: list[AddPartitionsToTxnPartitionResult] + def __init__( + self, + *args, + name: str = ..., + results_by_partition: list[AddPartitionsToTxnPartitionResult] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + transactional_id: str + topic_results: list[AddPartitionsToTxnTopicResult] + def __init__( + self, + *args, + transactional_id: str = ..., + topic_results: list[AddPartitionsToTxnTopicResult] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + class AddPartitionsToTxnTopicResult(DataContainer): + class AddPartitionsToTxnPartitionResult(DataContainer): + partition_index: int + partition_error_code: int + def __init__( + self, *args, partition_index: int = ..., partition_error_code: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + results_by_partition: list[AddPartitionsToTxnPartitionResult] + def __init__( + self, + *args, + name: str = ..., + results_by_partition: list[AddPartitionsToTxnPartitionResult] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + error_code: int + results_by_transaction: list[AddPartitionsToTxnResult] + results_by_topic_v3_and_below: list[AddPartitionsToTxnTopicResult] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + error_code: int = ..., + results_by_transaction: list[AddPartitionsToTxnResult] = ..., + results_by_topic_v3_and_below: list[AddPartitionsToTxnTopicResult] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class AddOffsetsToTxnRequest(ApiMessage): + transactional_id: str + producer_id: int + producer_epoch: int + group_id: str + def __init__( + self, + *args, + transactional_id: str = ..., + producer_id: int = ..., + producer_epoch: int = ..., + group_id: str = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class AddOffsetsToTxnResponse(ApiMessage): + throttle_time_ms: int + error_code: int + def __init__( + self, *args, throttle_time_ms: int = ..., error_code: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class EndTxnRequest(ApiMessage): + transactional_id: str + producer_id: int + producer_epoch: int + committed: bool + def __init__( + self, + *args, + transactional_id: str = ..., + producer_id: int = ..., + producer_epoch: int = ..., + committed: bool = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class EndTxnResponse(ApiMessage): + throttle_time_ms: int + error_code: int + producer_id: int + producer_epoch: int + def __init__( + self, + *args, + throttle_time_ms: int = ..., + error_code: int = ..., + producer_id: int = ..., + producer_epoch: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class TxnOffsetCommitRequest(ApiMessage): + class TxnOffsetCommitRequestTopic(DataContainer): + class TxnOffsetCommitRequestPartition(DataContainer): + partition_index: int + committed_offset: int + committed_leader_epoch: int + committed_metadata: str | None + def __init__( + self, + *args, + partition_index: int = ..., + committed_offset: int = ..., + committed_leader_epoch: int = ..., + committed_metadata: str | None = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + partitions: list[TxnOffsetCommitRequestPartition] + def __init__( + self, + *args, + name: str = ..., + partitions: list[TxnOffsetCommitRequestPartition] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + transactional_id: str + group_id: str + producer_id: int + producer_epoch: int + generation_id: int + member_id: str + group_instance_id: str | None + topics: list[TxnOffsetCommitRequestTopic] + def __init__( + self, + *args, + transactional_id: str = ..., + group_id: str = ..., + producer_id: int = ..., + producer_epoch: int = ..., + generation_id: int = ..., + member_id: str = ..., + group_instance_id: str | None = ..., + topics: list[TxnOffsetCommitRequestTopic] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class TxnOffsetCommitResponse(ApiMessage): + class TxnOffsetCommitResponseTopic(DataContainer): + class TxnOffsetCommitResponsePartition(DataContainer): + partition_index: int + error_code: int + def __init__( + self, *args, partition_index: int = ..., error_code: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + partitions: list[TxnOffsetCommitResponsePartition] + def __init__( + self, + *args, + name: str = ..., + partitions: list[TxnOffsetCommitResponsePartition] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + throttle_time_ms: int + topics: list[TxnOffsetCommitResponseTopic] + def __init__( + self, + *args, + throttle_time_ms: int = ..., + topics: list[TxnOffsetCommitResponseTopic] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class WriteTxnMarkersRequest(ApiMessage): + class WritableTxnMarker(DataContainer): + class WritableTxnMarkerTopic(DataContainer): + name: str + partition_indexes: list[int] + def __init__( + self, *args, name: str = ..., partition_indexes: list[int] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + producer_id: int + producer_epoch: int + transaction_result: bool + topics: list[WritableTxnMarkerTopic] + coordinator_epoch: int + transaction_version: int + def __init__( + self, + *args, + producer_id: int = ..., + producer_epoch: int = ..., + transaction_result: bool = ..., + topics: list[WritableTxnMarkerTopic] = ..., + coordinator_epoch: int = ..., + transaction_version: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + markers: list[WritableTxnMarker] + def __init__(self, *args, markers: list[WritableTxnMarker] = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class WriteTxnMarkersResponse(ApiMessage): + class WritableTxnMarkerResult(DataContainer): + class WritableTxnMarkerTopicResult(DataContainer): + class WritableTxnMarkerPartitionResult(DataContainer): + partition_index: int + error_code: int + def __init__( + self, *args, partition_index: int = ..., error_code: int = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + name: str + partitions: list[WritableTxnMarkerPartitionResult] + def __init__( + self, + *args, + name: str = ..., + partitions: list[WritableTxnMarkerPartitionResult] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + producer_id: int + topics: list[WritableTxnMarkerTopicResult] + def __init__( + self, + *args, + producer_id: int = ..., + topics: list[WritableTxnMarkerTopicResult] = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + + markers: list[WritableTxnMarkerResult] + def __init__(self, *args, markers: list[WritableTxnMarkerResult] = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +__all__ = [ + "InitProducerIdRequest", + "InitProducerIdResponse", + "AddPartitionsToTxnRequest", + "AddPartitionsToTxnResponse", + "AddOffsetsToTxnRequest", + "AddOffsetsToTxnResponse", + "EndTxnRequest", + "EndTxnResponse", + "TxnOffsetCommitRequest", + "TxnOffsetCommitResponse", + "WriteTxnMarkersRequest", + "WriteTxnMarkersResponse", +] diff --git a/stubs/kafka-python/kafka/protocol/sasl.pyi b/stubs/kafka-python/kafka/protocol/sasl.pyi new file mode 100644 index 000000000000..30095d81e622 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/sasl.pyi @@ -0,0 +1,126 @@ +from _typeshed import Incomplete +from typing_extensions import Self + +from kafka.protocol.api_data import ApiData +from kafka.protocol.api_message import ApiMessage + +class SaslHandshakeRequest(ApiMessage): + mechanism: str + def __init__(self, *args, mechanism: str = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class SaslHandshakeResponse(ApiMessage): + error_code: int + mechanisms: list[str] + def __init__( + self, *args, error_code: int = ..., mechanisms: list[str] = ..., version: int | None = None, **kwargs + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class SaslAuthenticateRequest(ApiMessage): + auth_bytes: bytes | ApiData + def __init__(self, *args, auth_bytes: bytes | ApiData = ..., version: int | None = None, **kwargs) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class SaslAuthenticateResponse(ApiMessage): + error_code: int + error_message: str | None + auth_bytes: bytes | ApiData + session_lifetime_ms: int + def __init__( + self, + *args, + error_code: int = ..., + error_message: str | None = ..., + auth_bytes: bytes | ApiData = ..., + session_lifetime_ms: int = ..., + version: int | None = None, + **kwargs, + ) -> None: ... + @property + def version(self) -> int | None: ... + def to_dict(self, meta: bool = False, json: bool = True) -> dict[Incomplete, Incomplete]: ... + name: str + type: str + API_KEY: int + API_VERSION: int + valid_versions: tuple[int, int] + min_version: int + max_version: int + @property + def header(self): ... + @classmethod + def is_request(cls) -> bool: ... + def expect_response(self) -> bool: ... + def with_header(self, correlation_id: int = 0, client_id: str = "kafka-python") -> None: ... + +class SaslBytesRequest: + API_VERSION: int + header: SaslBytesResponse | None + def __init__(self, data) -> None: ... + def with_header(self, correlation_id=None, **kwargs) -> None: ... + def encode(self, framed: bool = True, header: bool = True) -> bytes: ... + def expect_response(self): ... + +class SaslBytesResponse: + correlation_id: Incomplete + error_code: int + def __init__(self, correlation_id) -> None: ... + def parse_header(self, read_buffer) -> Self: ... + auth_bytes: Incomplete + def decode(self, read_buffer) -> Self: ... + def get_response_class(self) -> Self: ... + +__all__ = [ + "SaslHandshakeRequest", + "SaslHandshakeResponse", + "SaslAuthenticateRequest", + "SaslAuthenticateResponse", + "SaslBytesRequest", + "SaslBytesResponse", +] diff --git a/stubs/kafka-python/kafka/protocol/schemas/__init__.pyi b/stubs/kafka-python/kafka/protocol/schemas/__init__.pyi new file mode 100644 index 000000000000..46c73ea289e5 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/schemas/__init__.pyi @@ -0,0 +1,4 @@ +from .fields import * +from .load_json import load_json as load_json + +__all__ = ["BaseField", "SimpleField", "StructField", "ArrayField", "StructArrayField", "load_json"] diff --git a/stubs/kafka-python/kafka/protocol/schemas/fields/__init__.pyi b/stubs/kafka-python/kafka/protocol/schemas/fields/__init__.pyi new file mode 100644 index 000000000000..95100c188f63 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/schemas/fields/__init__.pyi @@ -0,0 +1,7 @@ +from .array import ArrayField as ArrayField +from .base import BaseField as BaseField +from .simple import SimpleField as SimpleField +from .struct import StructField as StructField +from .struct_array import StructArrayField as StructArrayField + +__all__ = ["BaseField", "SimpleField", "StructField", "ArrayField", "StructArrayField"] diff --git a/stubs/kafka-python/kafka/protocol/schemas/fields/array.pyi b/stubs/kafka-python/kafka/protocol/schemas/fields/array.pyi new file mode 100644 index 000000000000..fe53ab246093 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/schemas/fields/array.pyi @@ -0,0 +1,21 @@ +from typing_extensions import Self + +from .base import BaseField +from .simple import SimpleField + +class ArrayField(BaseField): + @classmethod + def parse_inner_type(cls, json) -> SimpleField | None: ... + @classmethod + def parse_array_type(cls, json) -> str | None: ... + @classmethod + def parse_json(cls, json) -> Self | None: ... + array_of: SimpleField + def __init__(self, json, array_of: SimpleField | None = None) -> None: ... + def is_array(self) -> bool: ... + def encode(self, items, version=None, compact: bool = False, tagged: bool = False) -> bytes: ... + def encode_into(self, items, out, version=None, compact: bool = False, tagged: bool = False) -> None: ... + def emit_encode_into(self, ctx, val_expr, indent, version=None, compact: bool = False, tagged: bool = False) -> None: ... + def emit_decode_from(self, ctx, var_name, indent, version=None, compact: bool = False, tagged: bool = False) -> None: ... + def decode(self, data, version=None, compact: bool = False, tagged: bool = False): ... + def to_json(self, val): ... diff --git a/stubs/kafka-python/kafka/protocol/schemas/fields/base.pyi b/stubs/kafka-python/kafka/protocol/schemas/fields/base.pyi new file mode 100644 index 000000000000..972c93c6c3fc --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/schemas/fields/base.pyi @@ -0,0 +1,39 @@ +from _typeshed import Incomplete + +class BaseField: + FIELD_TYPES: list[type[Incomplete]] + def __init_subclass__(cls, **kw) -> None: ... + @classmethod + def parse_json_fields(cls, json): ... + @classmethod + def parse_json(cls, json): ... + @classmethod + def underscore_name(cls, name: str) -> str: ... + @classmethod + def parse_versions(cls, versions: str) -> tuple[int, ...] | None: ... + name: str + def __init__(self, json) -> None: ... + @property + def type_str(self): ... + @property + def tag(self): ... + def is_array(self) -> bool: ... + def is_struct(self) -> bool: ... + def is_struct_array(self) -> bool: ... + def is_batchable(self) -> bool: ... + def has_data_class(self) -> bool: ... + def __call__(self, *args, **kwargs): ... + @property + def fields(self): ... + @property + def min_version(self): ... + @property + def max_version(self): ... + def for_version_q(self, version) -> bool: ... + def nullable_for_version_q(self, version) -> bool: ... + def tagged_field_q(self, version) -> bool: ... + @property + def default(self): ... + def encode(self, value, version=None, compact: bool = False, tagged: bool = False): ... + def decode(self, data, version=None, compact: bool = False, tagged: bool = False): ... + def __eq__(self, other) -> bool: ... diff --git a/stubs/kafka-python/kafka/protocol/schemas/fields/codecs/__init__.pyi b/stubs/kafka-python/kafka/protocol/schemas/fields/codecs/__init__.pyi new file mode 100644 index 000000000000..2597c4205dde --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/schemas/fields/codecs/__init__.pyi @@ -0,0 +1,33 @@ +from .encode_buffer import EncodeBuffer as EncodeBuffer, EncodeBufferPool as EncodeBufferPool +from .tagged_fields import TaggedFields as TaggedFields +from .types import ( + UUID as UUID, + BitField as BitField, + Boolean as Boolean, + Bytes as Bytes, + Float64 as Float64, + Int8 as Int8, + Int16 as Int16, + Int32 as Int32, + Int64 as Int64, + String as String, + UnsignedInt16 as UnsignedInt16, + UnsignedVarInt32 as UnsignedVarInt32, +) + +__all__ = [ + "BitField", + "Boolean", + "UUID", + "Bytes", + "String", + "Int8", + "Int16", + "Int32", + "Int64", + "UnsignedInt16", + "UnsignedVarInt32", + "Float64", + "TaggedFields", + "EncodeBuffer", +] diff --git a/stubs/kafka-python/kafka/protocol/schemas/fields/codecs/encode_buffer.pyi b/stubs/kafka-python/kafka/protocol/schemas/fields/codecs/encode_buffer.pyi new file mode 100644 index 000000000000..17f9016f618b --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/schemas/fields/codecs/encode_buffer.pyi @@ -0,0 +1,22 @@ +from _typeshed import Incomplete, ReadableBuffer, Unused +from collections.abc import Iterable +from typing import SupportsIndex + +class EncodeBuffer: + __slots__ = ("buf", "pos") + buf: bytearray + pos: int + def __init__(self, size: Iterable[SupportsIndex] | SupportsIndex | ReadableBuffer = 65536) -> None: ... + def reset(self) -> None: ... + def ensure(self, needed: int) -> None: ... + def result(self) -> bytearray: ... + +class EncodeBufferPool: + @classmethod + def acquire(cls) -> _PooledBuffer: ... + +class _PooledBuffer: + __slots__ = ("_pool", "_buf") + def __init__(self, pool: EncodeBufferPool) -> None: ... + def __enter__(self) -> EncodeBuffer | Incomplete: ... + def __exit__(self, *exc: Unused): ... diff --git a/stubs/kafka-python/kafka/protocol/schemas/fields/codecs/tagged_fields.pyi b/stubs/kafka-python/kafka/protocol/schemas/fields/codecs/tagged_fields.pyi new file mode 100644 index 000000000000..0c3d23a8699b --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/schemas/fields/codecs/tagged_fields.pyi @@ -0,0 +1,11 @@ +from _typeshed import Incomplete + +class TaggedFields: + def __init__(self, fields) -> None: ... + def encode(self, item, version=None) -> bytes: ... + def encode_into(self, item, out, version=None) -> None: ... + def decode(self, data, version=None) -> dict[str, Incomplete]: ... + @classmethod + def decode_empty(cls, data) -> None: ... + @classmethod + def encode_empty(cls) -> bytes: ... diff --git a/stubs/kafka-python/kafka/protocol/schemas/fields/codecs/types.pyi b/stubs/kafka-python/kafka/protocol/schemas/fields/codecs/types.pyi new file mode 100644 index 000000000000..5302860eef6c --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/schemas/fields/codecs/types.pyi @@ -0,0 +1,138 @@ +import uuid +from _typeshed import Incomplete +from collections.abc import Iterable +from typing import ClassVar, Final, Literal + +class FixedCodec: + fmt: ClassVar[str | None] + size: ClassVar[int | None] + batchable: ClassVar[bool] + def __init_subclass__(cls, **kw) -> None: ... + @classmethod + def encode(cls, value, compact: bool = False) -> bytes: ... + @classmethod + def encode_into(cls, out, value, compact: bool = False) -> None: ... + @classmethod + def decode(cls, data, compact: bool = False): ... + @classmethod + def decode_from(cls, data, pos) -> tuple[Incomplete, Incomplete]: ... + @classmethod + def emit_encode_into(cls, ctx, val_expr, indent, compact: bool = False) -> None: ... + @classmethod + def emit_decode_from(cls, ctx, var_name, indent, compact: bool = False) -> None: ... + +class Int8(FixedCodec): + fmt: ClassVar[str] + size: ClassVar[int] + +class Int16(FixedCodec): + fmt: ClassVar[str] + size: ClassVar[int] + +class UnsignedInt16(FixedCodec): + fmt: ClassVar[str] + size: ClassVar[int] + +class Int32(FixedCodec): + fmt: ClassVar[str] + size: ClassVar[int] + +class Int64(FixedCodec): + fmt: ClassVar[str] + size: ClassVar[int] + +class Float64(FixedCodec): + fmt: ClassVar[str] + size: ClassVar[int] + +class UUID: + fmt: ClassVar[str] + size: ClassVar[int] + ZERO_UUID: Final[uuid.UUID] + @classmethod + def encode(cls, value, compact: bool = False) -> bytes: ... + @classmethod + def encode_into(cls, out, value, compact: bool = False) -> None: ... + @classmethod + def emit_encode_into(cls, ctx, val_expr, indent, compact: bool = False) -> None: ... + @classmethod + def emit_decode_from(cls, ctx, var_name, indent, compact: bool = False) -> None: ... + @classmethod + def decode(cls, data, compact: bool = False) -> uuid.UUID | None: ... + +class String: + fmt: ClassVar[str | None] + size: ClassVar[Literal["variable"]] + encoding: str + def __init__(self, encoding: str = "utf-8") -> None: ... + def encode(self, value, compact: bool = False) -> bytes: ... + def encode_into(self, out, value, compact: bool = False) -> None: ... + def emit_encode_into(self, ctx, val_expr, indent, compact: bool = False) -> None: ... + def emit_decode_from(self, ctx, var_name, indent, compact: bool = False) -> None: ... + def decode(self, data, compact: bool = False): ... + +class Bytes: + fmt: ClassVar[str] + size: ClassVar[Literal["variable"]] + @classmethod + def encode(cls, value, compact: bool = False) -> bytes: ... + @classmethod + def encode_into(cls, out, value, compact: bool = False) -> None: ... + @classmethod + def emit_encode_into(cls, ctx, val_expr, indent, compact: bool = False) -> None: ... + @classmethod + def emit_decode_from(cls, ctx, var_name, indent, compact: bool = False) -> None: ... + @classmethod + def decode(cls, data, compact: bool = False): ... + +class Boolean(FixedCodec): + fmt: ClassVar[str] + size: ClassVar[int] + +class UnsignedVarInt32: + fmt: ClassVar[str] + size: ClassVar[Literal["variable"]] + @classmethod + def decode(cls, data, compact: bool = False): ... + @classmethod + def encode(cls, value, compact: bool = False) -> bytes: ... + @classmethod + def encode_into(cls, out, value) -> None: ... + @classmethod + def emit_encode_into(cls, ctx, val_expr, indent, compact: bool = False) -> None: ... + @classmethod + def emit_decode_from(cls, ctx, var_name, indent) -> None: ... + +class VarInt32: + fmt: ClassVar[str] + size: ClassVar[Literal["variable"]] + @classmethod + def decode(cls, data, compact: bool = False): ... + @classmethod + def encode(cls, value, compact: bool = False) -> bytes: ... + +class VarInt64: + fmt: ClassVar[str] + size: ClassVar[Literal["variable"]] + @classmethod + def decode(cls, data, compact: bool = False): ... + @classmethod + def encode(cls, value, compact: bool = False) -> bytes: ... + +class BitField: + fmt: ClassVar[str] + size: ClassVar[int] + @classmethod + def decode(cls, data, compact: bool = False) -> set[Incomplete] | None: ... + @classmethod + def encode(cls, vals, compact: bool = False) -> bytes: ... + @classmethod + def encode_into(cls, out, vals, compact: bool = False) -> None: ... + @classmethod + def emit_encode_into(cls, ctx, val_expr, indent, compact: bool = False) -> None: ... + @classmethod + def emit_decode_from(cls, ctx, var_name, indent, compact: bool = False) -> None: ... + @classmethod + def to_32_bit_field(cls, vals: Iterable[int]) -> int: ... + @classmethod + def from_32_bit_field(cls, value: int) -> set[int]: ... diff --git a/stubs/kafka-python/kafka/protocol/schemas/fields/codegen.pyi b/stubs/kafka-python/kafka/protocol/schemas/fields/codegen.pyi new file mode 100644 index 000000000000..7cb3f2afa5be --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/schemas/fields/codegen.pyi @@ -0,0 +1,11 @@ +from _typeshed import Incomplete + +class CodegenContext: + lines: list[str] + globs: dict[str, Incomplete] + def __init__(self) -> None: ... + def next_var(self, prefix: str = "v") -> str: ... + def emit(self, indent, line) -> None: ... + def emit_reserve(self, indent, nbytes) -> None: ... + def source(self) -> None: ... + def print(self) -> None: ... diff --git a/stubs/kafka-python/kafka/protocol/schemas/fields/simple.pyi b/stubs/kafka-python/kafka/protocol/schemas/fields/simple.pyi new file mode 100644 index 000000000000..d2d151cbc74b --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/schemas/fields/simple.pyi @@ -0,0 +1,17 @@ +from _typeshed import Incomplete +from typing_extensions import Self + +from .base import BaseField + +class SimpleField(BaseField): + TYPES: dict[str, type[Incomplete]] + @classmethod + def parse_json(cls, json) -> Self | None: ... + def __init__(self, json) -> None: ... + def is_batchable(self) -> bool: ... + def encode(self, value, version=None, compact: bool = False, tagged: bool = False) -> bytes: ... + def encode_into(self, value, out, version=None, compact: bool = False, tagged: bool = False) -> None: ... + def emit_encode_into(self, ctx, val_expr, indent, version=None, compact: bool = False, tagged: bool = False) -> None: ... + def emit_decode_from(self, ctx, var_name, indent, version=None, compact: bool = False, tagged: bool = False) -> None: ... + def decode(self, data, version=None, compact: bool = False, tagged: bool = False): ... + def to_json(self, val): ... diff --git a/stubs/kafka-python/kafka/protocol/schemas/fields/struct.pyi b/stubs/kafka-python/kafka/protocol/schemas/fields/struct.pyi new file mode 100644 index 000000000000..74b97fd2a255 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/schemas/fields/struct.pyi @@ -0,0 +1,32 @@ +from _typeshed import Incomplete +from typing_extensions import Self + +from .base import BaseField +from .codegen import CodegenContext + +class StructField(BaseField): + @classmethod + def parse_json(cls, json) -> Self | None: ... + def __init__(self, json) -> None: ... + @property + def fields(self) -> dict[Incomplete, Incomplete]: ... + def is_struct(self): ... + def has_data_class(self) -> bool: ... + def set_data_class(self, data_class) -> None: ... + @property + def data_class(self): ... + def __call__(self, *args, **kw): ... + def tagged_fields(self, version): ... + def untagged_fields(self, version): ... + def encode(self, item, version=None, compact: bool = False, tagged: bool = False) -> bytes: ... + def emit_encode_into( + self, ctx, item_expr, indent, version=None, compact: bool = False, tagged: bool = False, tuple_access: bool = False + ) -> None: ... + def encode_into(self, item, out, version=None, compact: bool = False, tagged: bool = False) -> None: ... + def encode_into__optimized_context(self, version, compact: bool = False, tagged: bool = False) -> CodegenContext: ... + def compiled_encode_into(self, version, compact: bool = False, tagged: bool = False): ... + def emit_decode_from(self, ctx, var_name, indent, version=None, compact: bool = False, tagged: bool = False) -> None: ... + def compiled_decode_from(self, version, compact: bool = False, tagged: bool = False, data_class=None): ... + def decode(self, data, version=None, compact: bool = False, tagged: bool = False, data_class=None): ... + def __len__(self) -> int: ... + def __eq__(self, other) -> bool: ... diff --git a/stubs/kafka-python/kafka/protocol/schemas/fields/struct_array.pyi b/stubs/kafka-python/kafka/protocol/schemas/fields/struct_array.pyi new file mode 100644 index 000000000000..6227dc43647b --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/schemas/fields/struct_array.pyi @@ -0,0 +1,27 @@ +from _typeshed import Incomplete +from typing_extensions import Self + +from .array import ArrayField +from .struct import StructField + +class StructArrayField(ArrayField): + @classmethod + def parse_inner_type(cls, json) -> StructField | None: ... # type: ignore[override] + @classmethod + def parse_json(cls, json) -> Self | None: ... + map_key: Incomplete | None + def __init__(self, json, array_of=None) -> None: ... + @property + def type_str(self): ... + def is_struct_array(self): ... + @property + def fields(self): ... + def tagged_fields(self, version): ... + def untagged_fields(self, version): ... + def has_data_class(self): ... + def set_data_class(self, data_class): ... + @property + def data_class(self): ... + def __call__(self, *args, **kw): ... + def emit_decode_from(self, ctx, var_name, indent, version=None, compact: bool = False, tagged: bool = False) -> None: ... + def emit_encode_into(self, ctx, val_expr, indent, version=None, compact: bool = False, tagged: bool = False) -> None: ... diff --git a/stubs/kafka-python/kafka/protocol/schemas/load_json.pyi b/stubs/kafka-python/kafka/protocol/schemas/load_json.pyi new file mode 100644 index 000000000000..12140ce7a283 --- /dev/null +++ b/stubs/kafka-python/kafka/protocol/schemas/load_json.pyi @@ -0,0 +1,3 @@ +from types import ModuleType + +def load_json(msg_type: str, package: str | ModuleType | None = None): ... diff --git a/stubs/kafka-python/kafka/protocol/schemas/resources/__init__.pyi b/stubs/kafka-python/kafka/protocol/schemas/resources/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/stubs/kafka-python/kafka/protocol/struct.pyi b/stubs/kafka-python/kafka/protocol/struct.pyi deleted file mode 100644 index 11de387016c4..000000000000 --- a/stubs/kafka-python/kafka/protocol/struct.pyi +++ /dev/null @@ -1,14 +0,0 @@ -from _typeshed import Incomplete - -from kafka.protocol.abstract import AbstractType - -class Struct(AbstractType): - SCHEMA: Incomplete - def __init__(self, *args, **kwargs) -> None: ... - @classmethod - def encode(cls, item): ... - @classmethod - def decode(cls, data): ... - def get_item(self, name): ... - def __hash__(self): ... - def __eq__(self, other): ... diff --git a/stubs/kafka-python/kafka/record/abc.pyi b/stubs/kafka-python/kafka/record/abc.pyi index c351d4fb6611..ce0922d9bfd5 100644 --- a/stubs/kafka-python/kafka/record/abc.pyi +++ b/stubs/kafka-python/kafka/record/abc.pyi @@ -1,6 +1,7 @@ import abc class ABCRecord(metaclass=abc.ABCMeta): + __slots__ = () @property @abc.abstractmethod def size_in_bytes(self): ... @@ -29,6 +30,7 @@ class ABCRecord(metaclass=abc.ABCMeta): def headers(self): ... class ABCRecordBatchBuilder(metaclass=abc.ABCMeta): + __slots__ = () @abc.abstractmethod def append(self, offset, timestamp, key, value, headers=None): ... @abc.abstractmethod @@ -37,6 +39,7 @@ class ABCRecordBatchBuilder(metaclass=abc.ABCMeta): def build(self): ... class ABCRecordBatch(metaclass=abc.ABCMeta): + __slots__ = () @abc.abstractmethod def __iter__(self): ... @property @@ -50,6 +53,7 @@ class ABCRecordBatch(metaclass=abc.ABCMeta): def magic(self): ... class ABCRecords(metaclass=abc.ABCMeta): + __slots__ = () @abc.abstractmethod def __init__(self, buffer): ... @abc.abstractmethod diff --git a/stubs/kafka-python/kafka/record/default_records.pyi b/stubs/kafka-python/kafka/record/default_records.pyi index bdb79252bc05..766def5d8b45 100644 --- a/stubs/kafka-python/kafka/record/default_records.pyi +++ b/stubs/kafka-python/kafka/record/default_records.pyi @@ -114,6 +114,8 @@ class DefaultRecordBatchBuilder(DefaultRecordBase, ABCRecordBatchBuilder): def producer_id(self): ... @property def producer_epoch(self): ... + @property + def base_sequence(self): ... def append( # type: ignore[override] self, offset, diff --git a/stubs/kafka-python/kafka/record/legacy_records.pyi b/stubs/kafka-python/kafka/record/legacy_records.pyi index d7165b0c0b10..cd4f5495120f 100644 --- a/stubs/kafka-python/kafka/record/legacy_records.pyi +++ b/stubs/kafka-python/kafka/record/legacy_records.pyi @@ -3,6 +3,7 @@ from _typeshed import Incomplete from kafka.record.abc import ABCRecord, ABCRecordBatch, ABCRecordBatchBuilder class LegacyRecordBase: + __slots__ = () HEADER_STRUCT_V0: Incomplete HEADER_STRUCT_V1: Incomplete LOG_OVERHEAD: Incomplete @@ -25,6 +26,7 @@ class LegacyRecordBase: NO_TIMESTAMP: int class LegacyRecordBatch(ABCRecordBatch, LegacyRecordBase): + __slots__ = ("_buffer", "_magic", "_offset", "_length", "_crc", "_timestamp", "_attributes", "_decompressed") def __init__(self, buffer, magic) -> None: ... @property def base_offset(self): ... @@ -40,6 +42,7 @@ class LegacyRecordBatch(ABCRecordBatch, LegacyRecordBase): def __iter__(self): ... class LegacyRecord(ABCRecord): + __slots__ = ("_magic", "_offset", "_timestamp", "_timestamp_type", "_key", "_value", "_crc", "_crc_bytes") def __init__(self, magic, offset, timestamp, timestamp_type, key, value, crc, crc_bytes) -> None: ... @property def magic(self): ... @@ -62,6 +65,7 @@ class LegacyRecord(ABCRecord): def size_in_bytes(self): ... class LegacyRecordBatchBuilder(ABCRecordBatchBuilder, LegacyRecordBase): + __slots__ = ("_magic", "_compression_type", "_batch_size", "_buffer") def __init__(self, magic, compression_type, batch_size) -> None: ... def append(self, offset, timestamp, key, value, headers=None): ... def build(self): ... @@ -75,6 +79,7 @@ class LegacyRecordBatchBuilder(ABCRecordBatchBuilder, LegacyRecordBase): def estimate_size_in_bytes(cls, magic, compression_type, key, value): ... class LegacyRecordMetadata: + __slots__ = ("_crc", "_size", "_timestamp", "_offset") def __init__(self, offset, crc, size, timestamp) -> None: ... @property def offset(self): ... diff --git a/stubs/kafka-python/kafka/record/memory_records.pyi b/stubs/kafka-python/kafka/record/memory_records.pyi index 5dec0f3202fa..d2be8259fa71 100644 --- a/stubs/kafka-python/kafka/record/memory_records.pyi +++ b/stubs/kafka-python/kafka/record/memory_records.pyi @@ -3,6 +3,7 @@ from _typeshed import Incomplete from kafka.record.abc import ABCRecords class MemoryRecords(ABCRecords): + __slots__ = ("_buffer", "_pos", "_next_slice", "_remaining_bytes") LENGTH_OFFSET: Incomplete LOG_OVERHEAD: Incomplete MAGIC_OFFSET: Incomplete @@ -17,6 +18,18 @@ class MemoryRecords(ABCRecords): next = __next__ class MemoryRecordsBuilder: + __slots__ = ( + "_builder", + "_batch_size", + "_buffer", + "_next_offset", + "_closed", + "_magic", + "_bytes_written", + "_producer_id", + "_producer_epoch", + "_base_sequence", + ) def __init__( self, magic, @@ -29,12 +42,14 @@ class MemoryRecordsBuilder: base_sequence: int = -1, ) -> None: ... def skip(self, offsets_to_skip) -> None: ... - def append(self, timestamp, key, value, headers=[]): ... + def append(self, timestamp, key, value, headers=None): ... def set_producer_state(self, producer_id, producer_epoch, base_sequence, is_transactional) -> None: ... @property def producer_id(self): ... @property def producer_epoch(self): ... + @property + def base_sequence(self): ... def records(self): ... def close(self) -> None: ... def size_in_bytes(self): ... diff --git a/stubs/kafka-python/kafka/serializer/__init__.pyi b/stubs/kafka-python/kafka/serializer/__init__.pyi index b9caa9a2bcbb..fe3588013b49 100644 --- a/stubs/kafka-python/kafka/serializer/__init__.pyi +++ b/stubs/kafka-python/kafka/serializer/__init__.pyi @@ -1 +1,4 @@ -from kafka.serializer.abstract import Deserializer as Deserializer, Serializer as Serializer +from .abstract import Deserializer as Deserializer, Serializer as Serializer +from .default import DefaultSerializer as DefaultSerializer +from .json import JsonSerializer as JsonSerializer +from .wrapper import DeserializeWrapper as DeserializeWrapper, SerializeWrapper as SerializeWrapper diff --git a/stubs/kafka-python/kafka/serializer/abstract.pyi b/stubs/kafka-python/kafka/serializer/abstract.pyi index 5e57c8b778a0..d8b45d1f4886 100644 --- a/stubs/kafka-python/kafka/serializer/abstract.pyi +++ b/stubs/kafka-python/kafka/serializer/abstract.pyi @@ -1,15 +1,11 @@ import abc class Serializer(metaclass=abc.ABCMeta): - __meta__ = abc.ABCMeta - def __init__(self, **config) -> None: ... @abc.abstractmethod - def serialize(self, topic, value): ... + def serialize(self, topic: str, headers: list[tuple[str, bytes]], data): ... def close(self) -> None: ... class Deserializer(metaclass=abc.ABCMeta): - __meta__ = abc.ABCMeta - def __init__(self, **config) -> None: ... @abc.abstractmethod - def deserialize(self, topic, bytes_): ... + def deserialize(self, topic: str, headers: list[tuple[str, bytes]], data: bytes | None): ... def close(self) -> None: ... diff --git a/stubs/kafka-python/kafka/serializer/default.pyi b/stubs/kafka-python/kafka/serializer/default.pyi new file mode 100644 index 000000000000..104f9957e278 --- /dev/null +++ b/stubs/kafka-python/kafka/serializer/default.pyi @@ -0,0 +1,7 @@ +from .abstract import Deserializer, Serializer + +class DefaultSerializer(Serializer, Deserializer): + encoding: str + def __init__(self, encoding: str = "utf-8") -> None: ... + def serialize(self, topic: str, headers: list[tuple[str, bytes]], data: str | bytes | bytearray | memoryview | None): ... + def deserialize(self, topic: str, headers: list[tuple[str, bytes]], data: bytes | None) -> str | None: ... diff --git a/stubs/kafka-python/kafka/serializer/json.pyi b/stubs/kafka-python/kafka/serializer/json.pyi new file mode 100644 index 000000000000..39f1a1f104bb --- /dev/null +++ b/stubs/kafka-python/kafka/serializer/json.pyi @@ -0,0 +1,5 @@ +from .abstract import Deserializer, Serializer + +class JsonSerializer(Serializer, Deserializer): + def serialize(self, topic: str, headers: list[tuple[str, bytes]], data): ... + def deserialize(self, topic: str, headers: list[tuple[str, bytes]], data): ... diff --git a/stubs/kafka-python/kafka/serializer/wrapper.pyi b/stubs/kafka-python/kafka/serializer/wrapper.pyi new file mode 100644 index 000000000000..705f605a5b70 --- /dev/null +++ b/stubs/kafka-python/kafka/serializer/wrapper.pyi @@ -0,0 +1,13 @@ +from _typeshed import Incomplete + +from .abstract import Deserializer, Serializer + +class DeserializeWrapper(Deserializer): + fn: Incomplete + def __init__(self, fn) -> None: ... + def deserialize(self, topic: str, headers: list[tuple[str, bytes]], data): ... + +class SerializeWrapper(Serializer): + fn: Incomplete + def __init__(self, fn) -> None: ... + def serialize(self, topic: str, headers: list[tuple[str, bytes]], data): ... diff --git a/stubs/kafka-python/kafka/socks5_wrapper.pyi b/stubs/kafka-python/kafka/socks5_wrapper.pyi deleted file mode 100644 index 871e8b20344f..000000000000 --- a/stubs/kafka-python/kafka/socks5_wrapper.pyi +++ /dev/null @@ -1,25 +0,0 @@ -from _typeshed import Incomplete - -log: Incomplete - -class ProxyConnectionStates: - DISCONNECTED: str - CONNECTING: str - NEGOTIATE_PROPOSE: str - NEGOTIATING: str - AUTHENTICATING: str - REQUEST_SUBMIT: str - REQUESTING: str - READ_ADDRESS: str - COMPLETE: str - -class Socks5Wrapper: - def __init__(self, proxy_url, afi) -> None: ... - @classmethod - def is_inet_4_or_6(cls, gai): ... - @classmethod - def dns_lookup(cls, host, port, afi=...): ... - @classmethod - def use_remote_lookup(cls, proxy_url): ... - def socket(self, family, sock_type): ... - def connect_ex(self, addr): ... diff --git a/stubs/kafka-python/kafka/structs.pyi b/stubs/kafka-python/kafka/structs.pyi index 997afe9492f3..00e8a2dae59a 100644 --- a/stubs/kafka-python/kafka/structs.pyi +++ b/stubs/kafka-python/kafka/structs.pyi @@ -1,53 +1,32 @@ -from _typeshed import Incomplete -from typing import NamedTuple +from typing import Final, Literal, NamedTuple class TopicPartition(NamedTuple): topic: str partition: int -class BrokerMetadata(NamedTuple): - nodeId: int - host: str - port: int - rack: str | None - -class PartitionMetadata(NamedTuple): +class TopicPartitionReplica(NamedTuple): topic: str partition: int - leader: int - leader_epoch: int | None - replicas: list[int] - isr: list[int] - offline_replicas: list[int] - error: Incomplete + broker_id: int class OffsetAndMetadata(NamedTuple): - offset: int - metadata: str - leader_epoch: int + offset: int | None = None + metadata: str = "" + leader_epoch: int = -1 class OffsetAndTimestamp(NamedTuple): offset: int timestamp: int leader_epoch: int -class MemberInformation(NamedTuple): - member_id: str - client_id: str - client_host: str - member_metadata: Incomplete - member_assignment: Incomplete - -class GroupInformation(NamedTuple): - error_code: int - group: str - state: str - protocol_type: str - protocol: str - members: list[MemberInformation] - authorized_operations: list[str] - -class RetryOptions(NamedTuple): - limit: int - backoff_ms: int - retry_on_timeouts: bool +class MemberState: + UNJOINED: Final = "" + REBALANCING: Final = "" + STABLE: Final = "" + +class ConsumerGroupMetadata(NamedTuple): + group_id: str | None = None + generation_id: int = -1 + member_id: str = "" + group_instance_id: str | None = None + state: Literal["", "", ""] = ... # Please, keep in sync with MemberState diff --git a/stubs/kafka-python/kafka/util.pyi b/stubs/kafka-python/kafka/util.pyi index 4783d02b462a..83880d3b228e 100644 --- a/stubs/kafka-python/kafka/util.pyi +++ b/stubs/kafka-python/kafka/util.pyi @@ -5,18 +5,16 @@ from typing import ParamSpec, TypeVar _P = ParamSpec("_P") _T = TypeVar("_T") -MAX_INT: Incomplete -TO_SIGNED: Incomplete - -def crc32(data): ... - class Timer: + __slots__ = ("_start_at", "_expire_at", "_timeout_ms", "_error_message") def __init__(self, timeout_ms, error_message=None, start_at=None) -> None: ... @property def expired(self): ... @property def timeout_ms(self): ... @property + def timeout_secs(self) -> float | None: ... + @property def elapsed_ms(self): ... def maybe_raise(self) -> None: ... @@ -36,3 +34,14 @@ class WeakMethod: class Dict(dict[Incomplete, Incomplete]): ... def synchronized(func: Callable[_P, _T]) -> Callable[_P, _T]: ... + +class classproperty: + f: Incomplete + def __init__(self, f): ... + def __get__(self, obj, owner): ... + +class EnumHelper: + @classmethod + def build_from(cls, val): ... + @classmethod + def value_for(cls, val): ...