Skip to content

asyncpg.connect() type is Coroutine[Any, Any, Any] #1028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
lukepighetti opened this issue Apr 27, 2023 · 1 comment
Open

asyncpg.connect() type is Coroutine[Any, Any, Any] #1028

lukepighetti opened this issue Apr 27, 2023 · 1 comment

Comments

@lukepighetti
Copy link

I was expecting asyncpg.connect() to have a concrete type, but I'm new to python and I may be overlooking something obvious. Thank you.

@lukepighetti
Copy link
Author

lukepighetti commented Apr 27, 2023

I ended up having to walk the AST to find the Connection class, is there any reason why it's not exposed by default?

import asyncpg
from asyncpg.connection import Connection

async def get_postgres() -> Connection:
    client: Connection = await asyncpg.connect(
        user=settings.POSTGRES_USER,
        password=settings.POSTGRES_PASSWORD,
        database=settings.POSTGRES_DATABASE,
        host=settings.POSTGRES_HOST,
    )
    return client
}

https://github.com/MagicStack/asyncpg/blob/master/asyncpg/connection.py#L1795

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

No branches or pull requests

1 participant