Skip to content

[pika] Fix connection parameter for callbacks - #16106

Merged
srittau merged 2 commits into
python:mainfrom
srittau:pika-connection-cbs
Jul 29, 2026
Merged

[pika] Fix connection parameter for callbacks#16106
srittau merged 2 commits into
python:mainfrom
srittau:pika-connection-cbs

Conversation

@srittau

@srittau srittau commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

The callbacks provided to a connection get passed the connection as first argument. While this was correctly typed as Self in the base Connection class, the concrete Connection class was used in sub-classes. Fixed to use Self in sub-classes as well.

srittau added 2 commits July 29, 2026 11:43
The callbacks provided to a connection get passed the connection as
first argument. While this was correctly typed as `Self` in the base
`Connection` class, the concrete `Connection` class was used in
sub-classes. Fixed to use `Self` in sub-classes as well.
@github-actions

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

zulip (https://github.com/zulip/zulip)
- zerver/lib/queue.py:286: error: Argument "on_open_error_callback" to "ExceptionFreeTornadoConnection" has incompatible type "Callable[[Connection, str | Exception], None]"; expected "Callable[[Connection, BaseException], object] | None"  [arg-type]
+ zerver/lib/queue.py:286: error: Argument "on_open_error_callback" to "ExceptionFreeTornadoConnection" has incompatible type "Callable[[Connection, str | Exception], None]"; expected "Callable[[ExceptionFreeTornadoConnection, BaseException], object] | None"  [arg-type]
- zerver/lib/queue.py:287: error: Argument "on_close_callback" to "ExceptionFreeTornadoConnection" has incompatible type "Callable[[Connection, Exception], None]"; expected "Callable[[Connection, BaseException], object] | None"  [arg-type]
+ zerver/lib/queue.py:287: error: Argument "on_close_callback" to "ExceptionFreeTornadoConnection" has incompatible type "Callable[[Connection, Exception], None]"; expected "Callable[[ExceptionFreeTornadoConnection, BaseException], object] | None"  [arg-type]

@srittau
srittau merged commit 2abacaf into python:main Jul 29, 2026
106 of 107 checks passed
@srittau
srittau deleted the pika-connection-cbs branch July 29, 2026 12:30
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