We use the comment-style for type annotation because collections.Counter
is generic only since Python 3.9.
for retry in retries:
with retry:
with pool.ConnectionPool(dsn, min_size=4) as p:
- counts = Counter()
+ counts = Counter() # type: Counter[int]
for i in range(8):
with p.connection() as conn:
sleep(0.1)
async for retry in retries:
with retry:
async with pool.AsyncConnectionPool(dsn, min_size=4) as p:
- counts = Counter()
+ counts = Counter() # type: Counter[int]
for i in range(8):
async with p.connection() as conn:
await asyncio.sleep(0.1)