99from functools import singledispatch
1010from types import TracebackType
1111from typing import (
12- Any , AsyncContextManager , AsyncIterable , Awaitable , Callable , Dict ,
13- Generator , Iterator , Literal , Mapping , Optional , Tuple , Type , TypedDict ,
14- TypeVar , Union , overload ,
12+ Any ,
13+ AsyncContextManager ,
14+ AsyncIterable ,
15+ Awaitable ,
16+ Callable ,
17+ Dict ,
18+ Generator ,
19+ Iterator ,
20+ Literal ,
21+ Mapping ,
22+ Optional ,
23+ Tuple ,
24+ Type ,
25+ TypedDict ,
26+ TypeVar ,
27+ Union ,
28+ overload ,
1529)
1630
1731import aiormq .abc
2135
2236from .pool import PoolInstance
2337from .tools import (
24- CallbackCollection , CallbackSetType , CallbackType , OneShotCallback ,
38+ CallbackCollection ,
39+ CallbackSetType ,
40+ CallbackType ,
41+ OneShotCallback ,
2542)
2643
2744
@@ -80,18 +97,21 @@ class AbstractTransaction:
8097
8198 @abstractmethod
8299 async def select (
83- self , timeout : TimeoutType = None ,
100+ self ,
101+ timeout : TimeoutType = None ,
84102 ) -> aiormq .spec .Tx .SelectOk :
85103 raise NotImplementedError
86104
87105 @abstractmethod
88106 async def rollback (
89- self , timeout : TimeoutType = None ,
107+ self ,
108+ timeout : TimeoutType = None ,
90109 ) -> aiormq .spec .Tx .RollbackOk :
91110 raise NotImplementedError
92111
93112 async def commit (
94- self , timeout : TimeoutType = None ,
113+ self ,
114+ timeout : TimeoutType = None ,
95115 ) -> aiormq .spec .Tx .CommitOk :
96116 raise NotImplementedError
97117
@@ -280,7 +300,8 @@ def __init__(
280300
281301 @abstractmethod
282302 async def declare (
283- self , timeout : TimeoutType = None ,
303+ self ,
304+ timeout : TimeoutType = None ,
284305 ) -> aiormq .spec .Queue .DeclareOk :
285306 raise NotImplementedError
286307
@@ -319,42 +340,55 @@ async def consume(
319340
320341 @abstractmethod
321342 async def cancel (
322- self , consumer_tag : ConsumerTag ,
343+ self ,
344+ consumer_tag : ConsumerTag ,
323345 timeout : TimeoutType = None ,
324346 nowait : bool = False ,
325347 ) -> aiormq .spec .Basic .CancelOk :
326348 raise NotImplementedError
327349
328350 @overload
329351 async def get (
330- self , * , no_ack : bool = False ,
331- fail : Literal [True ] = ..., timeout : TimeoutType = ...,
332- ) -> AbstractIncomingMessage :
333- ...
352+ self ,
353+ * ,
354+ no_ack : bool = False ,
355+ fail : Literal [True ] = ...,
356+ timeout : TimeoutType = ...,
357+ ) -> AbstractIncomingMessage : ...
334358
335359 @overload
336360 async def get (
337- self , * , no_ack : bool = False ,
338- fail : Literal [False ] = ..., timeout : TimeoutType = ...,
339- ) -> Optional [AbstractIncomingMessage ]:
340- ...
361+ self ,
362+ * ,
363+ no_ack : bool = False ,
364+ fail : Literal [False ] = ...,
365+ timeout : TimeoutType = ...,
366+ ) -> Optional [AbstractIncomingMessage ]: ...
341367
342368 @abstractmethod
343369 async def get (
344- self , * , no_ack : bool = False ,
345- fail : bool = True , timeout : TimeoutType = 5 ,
370+ self ,
371+ * ,
372+ no_ack : bool = False ,
373+ fail : bool = True ,
374+ timeout : TimeoutType = 5 ,
346375 ) -> Optional [AbstractIncomingMessage ]:
347376 raise NotImplementedError
348377
349378 @abstractmethod
350379 async def purge (
351- self , no_wait : bool = False , timeout : TimeoutType = None ,
380+ self ,
381+ no_wait : bool = False ,
382+ timeout : TimeoutType = None ,
352383 ) -> aiormq .spec .Queue .PurgeOk :
353384 raise NotImplementedError
354385
355386 @abstractmethod
356387 async def delete (
357- self , * , if_unused : bool = True , if_empty : bool = True ,
388+ self ,
389+ * ,
390+ if_unused : bool = True ,
391+ if_empty : bool = True ,
358392 timeout : TimeoutType = None ,
359393 ) -> aiormq .spec .Queue .DeleteOk :
360394 raise NotImplementedError
@@ -424,7 +458,8 @@ def __init__(
424458
425459 @abstractmethod
426460 async def declare (
427- self , timeout : TimeoutType = None ,
461+ self ,
462+ timeout : TimeoutType = None ,
428463 ) -> aiormq .spec .Exchange .DeclareOk :
429464 raise NotImplementedError
430465
@@ -463,7 +498,9 @@ async def publish(
463498
464499 @abstractmethod
465500 async def delete (
466- self , if_unused : bool = False , timeout : TimeoutType = None ,
501+ self ,
502+ if_unused : bool = False ,
503+ timeout : TimeoutType = None ,
467504 ) -> aiormq .spec .Exchange .DeleteOk :
468505 raise NotImplementedError
469506
@@ -475,8 +512,10 @@ class UnderlayChannel:
475512
476513 @classmethod
477514 async def create (
478- cls , connection : aiormq .abc .AbstractConnection ,
479- close_callback : Callable [..., Awaitable [Any ]], ** kwargs : Any ,
515+ cls ,
516+ connection : aiormq .abc .AbstractConnection ,
517+ close_callback : Callable [..., Awaitable [Any ]],
518+ ** kwargs : Any ,
480519 ) -> "UnderlayChannel" :
481520 close_callback = OneShotCallback (close_callback )
482521
@@ -586,7 +625,10 @@ async def declare_exchange(
586625
587626 @abstractmethod
588627 async def get_exchange (
589- self , name : str , * , ensure : bool = True ,
628+ self ,
629+ name : str ,
630+ * ,
631+ ensure : bool = True ,
590632 ) -> AbstractExchange :
591633 raise NotImplementedError
592634
@@ -606,7 +648,10 @@ async def declare_queue(
606648
607649 @abstractmethod
608650 async def get_queue (
609- self , name : str , * , ensure : bool = True ,
651+ self ,
652+ name : str ,
653+ * ,
654+ ensure : bool = True ,
610655 ) -> AbstractQueue :
611656 raise NotImplementedError
612657
@@ -662,22 +707,31 @@ class UnderlayConnection:
662707
663708 @classmethod
664709 async def make_connection (
665- cls , url : URL , timeout : TimeoutType = None , ** kwargs : Any ,
710+ cls ,
711+ url : URL ,
712+ timeout : TimeoutType = None ,
713+ ** kwargs : Any ,
666714 ) -> aiormq .abc .AbstractConnection :
667715 connection : aiormq .abc .AbstractConnection = await asyncio .wait_for (
668- aiormq .connect (url , ** kwargs ), timeout = timeout ,
716+ aiormq .connect (url , ** kwargs ),
717+ timeout = timeout ,
669718 )
670719 await connection .ready ()
671720 return connection
672721
673722 @classmethod
674723 async def connect (
675- cls , url : URL , close_callback : Callable [..., Awaitable [Any ]],
676- timeout : TimeoutType = None , ** kwargs : Any ,
724+ cls ,
725+ url : URL ,
726+ close_callback : Callable [..., Awaitable [Any ]],
727+ timeout : TimeoutType = None ,
728+ ** kwargs : Any ,
677729 ) -> "UnderlayConnection" :
678730 try :
679731 connection = await cls .make_connection (
680- url , timeout = timeout , ** kwargs ,
732+ url ,
733+ timeout = timeout ,
734+ ** kwargs ,
681735 )
682736 close_callback = OneShotCallback (close_callback )
683737 connection .closing .add_done_callback (close_callback )
@@ -736,7 +790,9 @@ class AbstractConnection(PoolInstance, ABC):
736790
737791 @abstractmethod
738792 def __init__ (
739- self , url : URL , loop : Optional [asyncio .AbstractEventLoop ] = None ,
793+ self ,
794+ url : URL ,
795+ loop : Optional [asyncio .AbstractEventLoop ] = None ,
740796 ** kwargs : Any ,
741797 ):
742798 raise NotImplementedError (
@@ -793,8 +849,11 @@ async def __aexit__(
793849
794850 @abstractmethod
795851 async def update_secret (
796- self , new_secret : str , * ,
797- reason : str = "" , timeout : TimeoutType = None ,
852+ self ,
853+ new_secret : str ,
854+ * ,
855+ reason : str = "" ,
856+ timeout : TimeoutType = None ,
798857 ) -> aiormq .spec .Connection .UpdateSecretOk :
799858 raise NotImplementedError
800859
@@ -916,19 +975,20 @@ def channel(
916975
917976
918977ChannelCloseCallback = Callable [
919- [Optional [AbstractChannel ], Optional [BaseException ]], Any ,
978+ [Optional [AbstractChannel ], Optional [BaseException ]],
979+ Any ,
920980]
921981ConnectionCloseCallback = Callable [
922- [Optional [AbstractConnection ], Optional [BaseException ]], Any ,
982+ [Optional [AbstractConnection ], Optional [BaseException ]],
983+ Any ,
923984]
924985ConnectionType = TypeVar ("ConnectionType" , bound = AbstractConnection )
925986
926987
927988@singledispatch
928989def get_exchange_name (value : Any ) -> str :
929990 raise ValueError (
930- "exchange argument must be an exchange "
931- f"instance or str not { value !r} " ,
991+ f"exchange argument must be an exchange instance or str not { value !r} " ,
932992 )
933993
934994
0 commit comments