aiormq icon indicating copy to clipboard operation
aiormq copied to clipboard

Channel.basic_publish does not adhere to it's return type.

Open MaPePeR opened this issue 2 years ago • 2 comments

Specify that ConfirmationType Future contains ConfirmationFrameType.

Channel.confirmations contains the Futures used by basic_publish, so the Future needs to adhere to the return type of basic_publish.

Setting the type reveals an error in Channel._on_return_frame, which resolves the Future to DeliveredMessage, which is not a ConfirmationFrameType, thus breaking it's contract.

Not sure how to proceed here, tbh., because fixing this can probably be considered a BC-break at this point?

The DeliveredMessage that is wrongly returned by basic_publish can be reproduced by trying to publish to the default_exchange with a routing_key that doesn't match any queue and having on_return_raises=False (which for some reason is the default in aio-pika? :flushed:).

#100 might be related to this.

MaPePeR avatar Jun 02 '23 16:06 MaPePeR

This not compatible for older python versions as you can see.

mosquito avatar Jun 02 '23 18:06 mosquito

Latest commit should fix the incompatibility with old python versions. Sadly had to resort to sys.version_info. I would have preferred hasattr(asyncio.Future, '__getitem__'), but mypy didn't understand that.

MaPePeR avatar Jun 02 '23 20:06 MaPePeR