Skip to content

Make connect and connect_robust generic#696

Open
glav-git wants to merge 2 commits intomosquito:masterfrom
glav-git:master
Open

Make connect and connect_robust generic#696
glav-git wants to merge 2 commits intomosquito:masterfrom
glav-git:master

Conversation

@glav-git
Copy link

Fixes #695

Just a draft on how issue could be resolved. Gave a detailed explanation on why this is a good idea in the issue itself. Since it's just a typing change, should't be a breaking change in the api?

@coveralls
Copy link

coveralls commented Feb 22, 2026

Coverage Status

coverage: 91.981% (+0.004%) from 91.977%
when pulling 544fe41 on glav-git:master
into 57029c3 on mosquito:master.

@glav-git
Copy link
Author

glav-git commented Feb 24, 2026

I noticed my commit introduced 2 new mypy errors:

aio_pika/connection.py:319: error: Incompatible default for argument "connection_class" (default has type "type[Connection]", argument has type "type[CT]")  [assignment]
aio_pika/robust_connection.py:276: error: Incompatible default for argument "connection_class" (default has type "type[RobustConnection]", argument has type "type[CT]")  [assignment]

Unfortunately it's known issue: python/mypy#3737 and so far I was not able to find any solution that would satisfy both mypy and pyright at the same time.

So i guess solution here is either # type: ignore[assignment] or just wait until mypy figures out what to do with default values of genericly typed arguments.

@mosquito
Copy link
Owner

mosquito commented Mar 4, 2026

@glav-git # type: ignore[assignment] looks good solution for this case

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.

connect and connect_robust always returns Abstract class

3 participants