From 50932103775a490f268d2aa6d4c1e61455e616aa Mon Sep 17 00:00:00 2001 From: MaPePeR Date: Fri, 2 Jun 2023 18:32:12 +0200 Subject: [PATCH 1/3] Specify that `ConfirmationType` `Future` contains `ConfirmationFrameType`. `Channel.confirmations` contains the `Future`s used by `basic_publish`, so the `Future` needs to adhere to the return type of `basic_publish`. This reveals an error in `Channel._on_return_frame`, which resolves the `Future` to `DeliveredMessage`, which is not a `ConfirmationFrameType` --- aiormq/channel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiormq/channel.py b/aiormq/channel.py index 2066167..e80da76 100644 --- a/aiormq/channel.py +++ b/aiormq/channel.py @@ -69,7 +69,7 @@ class Returning(asyncio.Future): pass -ConfirmationType = Union[asyncio.Future, Returning] +ConfirmationType = Union[asyncio.Future[ConfirmationFrameType], Returning] class Channel(Base, AbstractChannel): From d570f0cdc4cab426339f26b0d605ff742172ed1b Mon Sep 17 00:00:00 2001 From: MaPePeR Date: Fri, 2 Jun 2023 22:04:10 +0200 Subject: [PATCH 2/3] Use sys.version_info to determine if `asyncio.Future` is as a Generic. --- aiormq/channel.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/aiormq/channel.py b/aiormq/channel.py index e80da76..590214c 100644 --- a/aiormq/channel.py +++ b/aiormq/channel.py @@ -1,6 +1,7 @@ import asyncio import io import logging +import sys from collections import OrderedDict from contextlib import suppress from functools import partial @@ -69,7 +70,11 @@ class Returning(asyncio.Future): pass -ConfirmationType = Union[asyncio.Future[ConfirmationFrameType], Returning] +if sys.version_info >= (3, 9): + ConfirmationFrameTypeFuture = asyncio.Future[ConfirmationFrameType] +else: + ConfirmationFrameTypeFuture = asyncio.Future +ConfirmationType = Union[ConfirmationFrameTypeFuture, Returning] class Channel(Base, AbstractChannel): From 494e9d5b0632bda87ff564322bb78a350bfdbfc1 Mon Sep 17 00:00:00 2001 From: MaPePeR Date: Fri, 2 Jun 2023 23:43:38 +0200 Subject: [PATCH 3/3] Wrap `asyncio.Future[...]` in `""`, so it works in python 3.7 This avoids the check for sys.version_info. --- aiormq/channel.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/aiormq/channel.py b/aiormq/channel.py index 590214c..24dcaa6 100644 --- a/aiormq/channel.py +++ b/aiormq/channel.py @@ -1,7 +1,6 @@ import asyncio import io import logging -import sys from collections import OrderedDict from contextlib import suppress from functools import partial @@ -70,11 +69,7 @@ class Returning(asyncio.Future): pass -if sys.version_info >= (3, 9): - ConfirmationFrameTypeFuture = asyncio.Future[ConfirmationFrameType] -else: - ConfirmationFrameTypeFuture = asyncio.Future -ConfirmationType = Union[ConfirmationFrameTypeFuture, Returning] +ConfirmationType = Union["asyncio.Future[ConfirmationFrameType]", Returning] class Channel(Base, AbstractChannel):