Skip to content

Commit 9ae1fb0

Browse files
authored
[kafka-python] Add missing __slots__ (#16218)
1 parent b7cee76 commit 9ae1fb0

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

stubs/kafka-python/kafka/record/default_records.pyi

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ from _typeshed import Incomplete
33
from kafka.record.abc import ABCRecord, ABCRecordBatch, ABCRecordBatchBuilder
44

55
class DefaultRecordBase:
6+
__slots__ = ()
67
HEADER_STRUCT: Incomplete
78
ATTRIBUTES_OFFSET: Incomplete
89
CRC_OFFSET: Incomplete
@@ -23,6 +24,7 @@ class DefaultRecordBase:
2324
MAX_INT: int
2425

2526
class DefaultRecordBatch(DefaultRecordBase, ABCRecordBatch):
27+
__slots__ = ("_buffer", "_header_data", "_pos", "_num_records", "_next_record_index", "_decompressed")
2628
def __init__(self, buffer) -> None: ...
2729
@property
2830
def base_offset(self): ...
@@ -73,6 +75,7 @@ class DefaultRecordBatch(DefaultRecordBase, ABCRecordBatch):
7375
def validate_crc(self): ...
7476

7577
class DefaultRecord(ABCRecord):
78+
__slots__ = ("_size_in_bytes", "_offset", "_timestamp", "_timestamp_type", "_key", "_value", "_headers")
7679
def __init__(self, size_in_bytes, offset, timestamp, timestamp_type, key, value, headers) -> None: ...
7780
@property
7881
def size_in_bytes(self): ...
@@ -93,6 +96,7 @@ class DefaultRecord(ABCRecord):
9396
def validate_crc(self): ...
9497

9598
class ControlRecord(DefaultRecord):
99+
__slots__ = ("_size_in_bytes", "_offset", "_timestamp", "_timestamp_type", "_key", "_value", "_headers", "_version", "_type")
96100
KEY_STRUCT: Incomplete
97101
def __init__(self, size_in_bytes, offset, timestamp, timestamp_type, key, value, headers) -> None: ...
98102
@property
@@ -105,6 +109,20 @@ class ControlRecord(DefaultRecord):
105109
def commit(self): ...
106110

107111
class DefaultRecordBatchBuilder(DefaultRecordBase, ABCRecordBatchBuilder):
112+
__slots__ = (
113+
"_magic",
114+
"_compression_type",
115+
"_batch_size",
116+
"_is_transactional",
117+
"_producer_id",
118+
"_producer_epoch",
119+
"_base_sequence",
120+
"_first_timestamp",
121+
"_max_timestamp",
122+
"_last_offset",
123+
"_num_records",
124+
"_buffer",
125+
)
108126
MAX_RECORD_OVERHEAD: int
109127
def __init__(
110128
self, magic, compression_type, is_transactional, producer_id, producer_epoch, base_sequence, batch_size
@@ -146,6 +164,7 @@ class DefaultRecordBatchBuilder(DefaultRecordBase, ABCRecordBatchBuilder):
146164
def estimate_size_in_bytes(cls, key, value, headers): ...
147165

148166
class DefaultRecordMetadata:
167+
__slots__ = ("_size", "_timestamp", "_offset")
149168
def __init__(self, offset, size, timestamp) -> None: ...
150169
@property
151170
def offset(self): ...

0 commit comments

Comments
 (0)