Skip to content

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

Open
MaPePeR wants to merge 3 commits intomosquito:masterfrom
MaPePeR:confirmationtype_future_type_fix
Open

Channel.basic_publish does not adhere to it's return type.#183
MaPePeR wants to merge 3 commits intomosquito:masterfrom
MaPePeR:confirmationtype_future_type_fix

Conversation

@MaPePeR
Copy link
Copy Markdown

@MaPePeR MaPePeR commented Jun 2, 2023

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? 😳).

#100 might be related to this.

…ype`.

`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`
@mosquito
Copy link
Copy Markdown
Owner

mosquito commented Jun 2, 2023

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

@MaPePeR
Copy link
Copy Markdown
Author

MaPePeR commented Jun 2, 2023

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.

This avoids the check for sys.version_info.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants