From 4d50eb311a00df2f62b97a9e37769930b5eb4f68 Mon Sep 17 00:00:00 2001 From: Dennis Alexandersson Date: Wed, 20 May 2020 17:46:46 +0200 Subject: [PATCH] Make PoolAcquireContext return a Connection type `__aenter__` should be defined to return a `Connection` type. This will help IDEs to properly help suggesting methods when using with `pool.acquire() as con` --- asyncpg/pool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asyncpg/pool.py b/asyncpg/pool.py index 20a3234e..b592f03c 100644 --- a/asyncpg/pool.py +++ b/asyncpg/pool.py @@ -767,7 +767,7 @@ def __init__(self, pool, timeout): self.connection = None self.done = False - async def __aenter__(self): + async def __aenter__(self) -> connection.Connection: if self.connection is not None or self.done: raise exceptions.InterfaceError('a connection is already acquired') self.connection = await self.pool._acquire(self.timeout)