Skip to content

Commit 94eaa96

Browse files
committed
Revert typing of asyncpg.create_pool() and add test
Refs #121
1 parent 58248a4 commit 94eaa96

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

asyncpg-stubs/pool.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ class PoolAcquireContext(Generic[_Record]):
519519
) -> Generator[Any, None, PoolConnectionProxy[_Record]]: ...
520520

521521
@overload
522-
async def create_pool(
522+
def create_pool(
523523
dsn: str | None = ...,
524524
*,
525525
min_size: int = ...,
@@ -546,7 +546,7 @@ async def create_pool(
546546
server_settings: dict[str, str] | None = ...,
547547
) -> Pool[protocol.Record]: ...
548548
@overload
549-
async def create_pool(
549+
def create_pool(
550550
dsn: str | None = ...,
551551
*,
552552
min_size: int = ...,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ incremental = true
5757
strict = true
5858

5959
[tool.pyright]
60-
include = ["asyncpg-stubs"]
60+
include = ["asyncpg-stubs", "tests"]
6161

6262
pythonVersion = "3.7"
6363
reportUnnecessaryTypeIgnoreComment = "warning"

tests/test_pool.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from __future__ import annotations
2+
3+
from typing_extensions import assert_type
4+
5+
import asyncpg
6+
7+
8+
async def main() -> None:
9+
pool = await asyncpg.create_pool()
10+
assert_type(pool, 'asyncpg.Pool[asyncpg.Record] | None')
11+
assert pool is not None
12+
assert_type(await pool, 'asyncpg.Pool[asyncpg.Record] | None')
13+
14+
async with asyncpg.create_pool() as pool:
15+
assert_type(pool, asyncpg.Pool[asyncpg.Record])

0 commit comments

Comments
 (0)