11from _typeshed import Incomplete , Unused
2- from collections .abc import Generator , Sequence
2+ from collections .abc import Callable , Generator , Sequence
33from logging import Logger
44from types import TracebackType
5- from typing import NamedTuple
5+ from typing import Any , NamedTuple , TypeVar
66from typing_extensions import Self
77
88from ..connection import Parameters
9- from ..data import _ArgumentMapping
109from ..exchange_type import ExchangeType
11- from ..spec import BasicProperties
10+ from ..frame import Method
11+ from ..spec import Basic , BasicProperties , Connection , Exchange , Queue , Tx
12+
13+ T = TypeVar ("T" , bound = Connection .Blocked | Connection .Unblocked )
1214
1315LOGGER : Logger
1416
@@ -189,19 +191,33 @@ class BlockingChannel:
189191 def add_on_cancel_callback (self , callback ) -> None : ...
190192 def add_on_return_callback (self , callback ): ...
191193 def basic_consume (
192- self , queue , on_message_callback , auto_ack : bool = False , exclusive : bool = False , consumer_tag = None , arguments = None
193- ): ...
194- def basic_cancel (self , consumer_tag ): ...
194+ self ,
195+ queue : str ,
196+ on_message_callback : Callable [[BlockingChannel , Basic .Deliver , BasicProperties , bytes ], object ],
197+ auto_ack : bool = False ,
198+ exclusive : bool = False ,
199+ consumer_tag : str | None = None ,
200+ arguments : dict [str , Any ] | None = None ,
201+ ) -> str : ...
202+ def basic_cancel (self , consumer_tag : str ) -> Sequence [tuple [Basic .Deliver , BasicProperties , bytes ]]: ...
195203 def start_consuming (self ) -> None : ...
196- def stop_consuming (self , consumer_tag = None ) -> None : ...
204+ def stop_consuming (self , consumer_tag : str | None = None ) -> None : ...
197205 def consume (
198- self , queue , auto_ack : bool = False , exclusive : bool = False , arguments = None , inactivity_timeout = None
199- ) -> Generator [Incomplete ]: ...
200- def get_waiting_message_count (self ): ...
201- def cancel (self ): ...
206+ self ,
207+ queue : str ,
208+ auto_ack : bool = False ,
209+ exclusive : bool = False ,
210+ arguments : dict [str , Any ] | None = None ,
211+ inactivity_timeout : float | None = None ,
212+ consumer_tag : str | None = None ,
213+ ) -> Generator [tuple [Basic .Deliver | None , BasicProperties | None , bytes | None ]]: ...
214+ def get_waiting_message_count (self ) -> int : ...
215+ def cancel (self ) -> int : ...
202216 def basic_ack (self , delivery_tag : int = 0 , multiple : bool = False ) -> None : ...
203217 def basic_nack (self , delivery_tag : int = 0 , multiple : bool = False , requeue : bool = True ) -> None : ...
204- def basic_get (self , queue , auto_ack : bool = False ): ...
218+ def basic_get (
219+ self , queue : str , auto_ack : bool = False
220+ ) -> tuple [Basic .GetOk | None , BasicProperties | None , bytes | None ]: ...
205221 def basic_publish (
206222 self ,
207223 exchange : str ,
@@ -222,24 +238,36 @@ class BlockingChannel:
222238 durable : bool = False ,
223239 auto_delete : bool = False ,
224240 internal : bool = False ,
225- arguments : _ArgumentMapping | None = None ,
226- ): ...
227- def exchange_delete (self , exchange : str | None = None , if_unused : bool = False ): ...
228- def exchange_bind (self , destination , source , routing_key : str = "" , arguments = None ): ...
229- def exchange_unbind (self , destination = None , source = None , routing_key : str = "" , arguments = None ): ...
241+ arguments : dict [str , Any ] | None = None ,
242+ ) -> None : ...
243+ def exchange_delete (self , exchange : str | None = None , if_unused : bool = False ) -> Method [Exchange .DeleteOk ]: ...
244+ def exchange_bind (
245+ self , destination : str , source : str , routing_key : str = "" , arguments : dict [str , Any ] | None = None
246+ ) -> Method [Exchange .BindOk ]: ...
247+ def exchange_unbind (
248+ self ,
249+ destination : str | None = None ,
250+ source : str | None = None ,
251+ routing_key : str = "" ,
252+ arguments : dict [str , Any ] | None = None ,
253+ ) -> Method [Exchange .UnbindOk ]: ...
230254 def queue_declare (
231255 self ,
232- queue ,
256+ queue : str ,
233257 passive : bool = False ,
234258 durable : bool = False ,
235259 exclusive : bool = False ,
236260 auto_delete : bool = False ,
237- arguments = None ,
238- ): ...
239- def queue_delete (self , queue , if_unused : bool = False , if_empty : bool = False ): ...
240- def queue_purge (self , queue ): ...
241- def queue_bind (self , queue , exchange , routing_key = None , arguments = None ): ...
242- def queue_unbind (self , queue , exchange = None , routing_key = None , arguments = None ): ...
243- def tx_select (self ): ...
244- def tx_commit (self ): ...
245- def tx_rollback (self ): ...
261+ arguments : dict [str , Any ] | None = None ,
262+ ) -> Method [Queue .DeclareOk ]: ...
263+ def queue_delete (self , queue : str , if_unused : bool = False , if_empty : bool = False ) -> Method [Queue .DeleteOk ]: ...
264+ def queue_purge (self , queue : str ) -> Method [Queue .PurgeOk ]: ...
265+ def queue_bind (
266+ self , queue : str , exchange : str , routing_key : str | None = None , arguments : dict [str , Any ] | None = None
267+ ) -> Method [Queue .BindOk ]: ...
268+ def queue_unbind (
269+ self , queue : str , exchange : str , routing_key : str | None = None , arguments : dict [str , Any ] | None = None
270+ ) -> Method [Queue .UnbindOk ]: ...
271+ def tx_select (self ) -> Method [Tx .SelectOk ]: ...
272+ def tx_commit (self ) -> Method [Tx .CommitOk ]: ...
273+ def tx_rollback (self ) -> Method [Tx .RollbackOk ]: ...
0 commit comments