mosquito / aiormq

Pure python AMQP 0.9.1 asynchronous client library
Other
276 stars 58 forks source link

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

Open MaPePeR opened 1 year ago

MaPePeR commented 1 year ago

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.

mosquito commented 1 year ago

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

MaPePeR commented 1 year ago

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.