@@ -284,6 +284,7 @@ class Message:
284284 timestamp : Optional [Tuple [int , int ]] = ...,
285285 latency : Optional [float ] = ...,
286286 leader_epoch : Optional [int ] = ...,
287+ delivery_count : Optional [int ] = ...,
287288 ) -> None : ...
288289 def topic (self ) -> Optional [str ]: ...
289290 def partition (self ) -> Optional [int ]: ...
@@ -295,6 +296,7 @@ class Message:
295296 def timestamp (self ) -> Tuple [int , int ]: ... # (timestamp_type, timestamp)
296297 def latency (self ) -> Optional [float ]: ...
297298 def leader_epoch (self ) -> Optional [int ]: ...
299+ def delivery_count (self ) -> Optional [int ]: ...
298300 def set_headers (self , headers : HeadersType ) -> None : ...
299301 def set_key (self , key : Any ) -> None : ...
300302 def set_value (self , value : Any ) -> None : ...
@@ -343,13 +345,9 @@ class Producer:
343345 Producer({'bootstrap.servers': 'localhost:9092'})
344346 """
345347 ...
348+
346349 @overload
347- def __init__ (
348- self ,
349- config : Dict [str , Any ],
350- / ,
351- ** kwargs : Any
352- ) -> None :
350+ def __init__ (self , config : Dict [str , Any ], / , ** kwargs : Any ) -> None :
353351 """
354352 Create Producer with configuration dict and additional keyword arguments.
355353 Keyword arguments override values in the config dict.
@@ -363,6 +361,7 @@ class Producer:
363361 Producer({'bootstrap.servers': 'localhost'}, enable_idempotence=True)
364362 """
365363 ...
364+
366365 @overload
367366 def __init__ (self , ** config : Any ) -> None :
368367 """
@@ -376,6 +375,7 @@ class Producer:
376375 Producer(bootstrap_servers='localhost:9092')
377376 """
378377 ...
378+
379379 def produce (
380380 self ,
381381 topic : str ,
@@ -426,13 +426,9 @@ class Consumer:
426426 Consumer({'bootstrap.servers': 'localhost', 'group.id': 'mygroup'})
427427 """
428428 ...
429+
429430 @overload
430- def __init__ (
431- self ,
432- config : dict [str , Any ],
433- / ,
434- ** kwargs : Any
435- ) -> None :
431+ def __init__ (self , config : dict [str , Any ], / , ** kwargs : Any ) -> None :
436432 """
437433 Create Consumer with configuration dict and additional keyword arguments.
438434 Keyword arguments override values in the config dict.
@@ -446,6 +442,7 @@ class Consumer:
446442 Consumer({'bootstrap.servers': 'localhost'}, group_id='mygroup')
447443 """
448444 ...
445+
449446 @overload
450447 def __init__ (self , ** config : Any ) -> None :
451448 """
@@ -459,6 +456,7 @@ class Consumer:
459456 Consumer(bootstrap_servers='localhost', group_id='mygroup')
460457 """
461458 ...
459+
462460 def subscribe (
463461 self ,
464462 topics : List [str ],
@@ -482,6 +480,7 @@ class Consumer:
482480 Message and offsets omitted, asynchronous.
483481 """
484482 ...
483+
485484 @overload
486485 def commit (
487486 self ,
@@ -492,6 +491,7 @@ class Consumer:
492491 Message and offsets omitted, synchronous.
493492 """
494493 ...
494+
495495 @overload
496496 def commit (
497497 self ,
@@ -503,6 +503,7 @@ class Consumer:
503503 Message specified, asynchronous.
504504 """
505505 ...
506+
506507 @overload
507508 def commit (
508509 self ,
@@ -514,17 +515,19 @@ class Consumer:
514515 Message specified, synchronous.
515516 """
516517 ...
518+
517519 @overload
518520 def commit (
519- self ,
520- * ,
521- offsets : List [TopicPartition ],
522- asynchronous : Literal [True ] = ...,
521+ self ,
522+ * ,
523+ offsets : List [TopicPartition ],
524+ asynchronous : Literal [True ] = ...,
523525 ) -> None :
524526 """
525527 Offsets specified, asynchronous.
526528 """
527529 ...
530+
528531 @overload
529532 def commit (
530533 self ,
@@ -536,6 +539,7 @@ class Consumer:
536539 Offsets specified, synchronous
537540 """
538541 ...
542+
539543 def get_watermark_offsets (
540544 self , partition : TopicPartition , timeout : float = - 1 , cached : bool = False
541545 ) -> Tuple [int , int ]: ...
@@ -560,6 +564,7 @@ class Consumer:
560564
561565class ShareConsumer :
562566 """Share Consumer for queue-like message consumption (KIP-932)."""
567+
563568 @overload
564569 def __init__ (self , config : Dict [str , Any ]) -> None : ...
565570 @overload
@@ -579,6 +584,12 @@ class ShareConsumer:
579584 def acknowledge_offset (
580585 self , topic : str , partition : int , offset : int , ack_type : AcknowledgeType = ...
581586 ) -> None : ...
587+ # TODO KIP-932: Java's share-consumer commit returns a map keyed by
588+ # TopicIdPartition (topic name + topic UUID + partition). Python uses
589+ # the existing TopicPartition (no UUID) for now. Add a TopicIdPartition
590+ # class once the interface is finalized.
591+ def commit_sync (self , timeout : float = 60 ) -> Dict [TopicPartition , Optional [KafkaError ]]: ...
592+ def commit_async (self ) -> None : ...
582593 def close (self ) -> None : ...
583594 def __enter__ (self ) -> "ShareConsumer" : ...
584595 def __exit__ (self , exc_type : Any , exc_value : Any , exc_traceback : Any ) -> Optional [bool ]: ...
0 commit comments