asyncpg
asyncpg copied to clipboard
Add return type to PoolAcquireContext.__aenter__ and rename attribute
Summary
Improves type inference in async with pool.acquire() by:
- Adding
-> connection.Connectionreturn type toPoolAcquireContext.__aenter__ - Renaming internal attribute
self.connectiontoself._connto avoid confusion and help type checkers
Motivation
Without this change, type checkers (mypy, pyright, pylance) cannot correctly infer the type of the connection in:
async with pool.acquire() as conn:
await conn.fetchrow("SELECT 1") # ← conn has type 'Unknown' or 'Any'