asyncpg
asyncpg copied to clipboard
asyncpg.connect() type is Coroutine[Any, Any, Any]
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.
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