Skip to content

Commit f6b79d6

Browse files
Use PEP 673 Self for DqliteConnection / ConnectionPool __aenter__ returns
See dbapi sibling commit for full rationale: subclass-correct context-manager / chainable-return signatures. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e7c6ca1 commit f6b79d6

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/dqliteclient/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from collections.abc import AsyncIterator, Awaitable, Callable, Mapping, Sequence
1212
from contextlib import asynccontextmanager
1313
from types import TracebackType
14-
from typing import Any, Final, NoReturn
14+
from typing import Any, Final, NoReturn, Self
1515

1616
from dqliteclient.exceptions import (
1717
DataError,
@@ -1325,7 +1325,7 @@ async def _abort_protocol(self) -> None:
13251325
exc_info=True,
13261326
)
13271327

1328-
async def __aenter__(self) -> "DqliteConnection":
1328+
async def __aenter__(self) -> Self:
13291329
await self.connect()
13301330
return self
13311331

src/dqliteclient/pool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from collections.abc import AsyncIterator, Sequence
88
from contextlib import asynccontextmanager
99
from types import TracebackType
10-
from typing import Any, Final, NoReturn
10+
from typing import Any, Final, NoReturn, Self
1111

1212
from dqliteclient import connection as _conn_mod
1313
from dqliteclient.cluster import ClusterClient
@@ -1503,7 +1503,7 @@ async def close(self) -> None:
15031503
# returning to the pool. Force-closing them here would race with
15041504
# the acquire context manager and corrupt _size.
15051505

1506-
async def __aenter__(self) -> "ConnectionPool":
1506+
async def __aenter__(self) -> Self:
15071507
await self.initialize()
15081508
return self
15091509

0 commit comments

Comments
 (0)