Skip to content

Commit 84cf72f

Browse files
committed
feature/generic-connect-funcs
1 parent 55ca5da commit 84cf72f

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

aio_pika/connection.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
log = get_logger(__name__)
2525
T = TypeVar("T")
26+
ConnT = TypeVar("ConnT", bound=AbstractConnection)
2627

2728

2829
class Connection(AbstractConnection):
@@ -290,9 +291,9 @@ async def connect(
290291
ssl_context: Optional[SSLContext] = None,
291292
timeout: TimeoutType = None,
292293
client_properties: Optional[FieldTable] = None,
293-
connection_class: Type[AbstractConnection] = Connection,
294+
connection_class: Type[ConnT] = Connection,
294295
**kwargs: Any,
295-
) -> AbstractConnection:
296+
) -> ConnT:
296297
""" Make connection to the broker.
297298
298299
Example:
@@ -373,7 +374,7 @@ async def main():
373374
374375
"""
375376

376-
connection: AbstractConnection = connection_class(
377+
connection: ConnT = connection_class(
377378
make_url(
378379
url,
379380
host=host,

aio_pika/robust_connection.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
from ssl import SSLContext
3-
from typing import Any, Optional, Tuple, Type, Union
3+
from typing import Any, Optional, Tuple, Type, TypeVar, Union
44
from weakref import WeakSet
55

66
import aiormq.abc
@@ -20,6 +20,7 @@
2020

2121

2222
log = get_logger(__name__)
23+
ConnT = TypeVar("ConnT", bound=AbstractRobustConnection)
2324

2425

2526
class RobustConnection(Connection, AbstractRobustConnection):
@@ -245,9 +246,9 @@ async def connect_robust(
245246
ssl_context: Optional[SSLContext] = None,
246247
timeout: TimeoutType = None,
247248
client_properties: Optional[FieldTable] = None,
248-
connection_class: Type[AbstractRobustConnection] = RobustConnection,
249+
connection_class: Type[ConnT] = RobustConnection,
249250
**kwargs: Any,
250-
) -> AbstractRobustConnection:
251+
) -> ConnT:
251252

252253
"""Make connection to the broker.
253254
@@ -330,7 +331,7 @@ async def main():
330331
331332
"""
332333

333-
connection: AbstractRobustConnection = connection_class(
334+
connection: ConnT = connection_class(
334335
make_url(
335336
url,
336337
host=host,

0 commit comments

Comments
 (0)