Skip to content

Commit b6ee9a4

Browse files
adamtheturtleclaude
andcommitted
Remove getattr calls in async transport closing
Add aclose to the AsyncTransport protocol and call it directly instead of using getattr to check for its existence. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 97589d6 commit b6ee9a4

4 files changed

Lines changed: 7 additions & 9 deletions

File tree

src/vws/async_query.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ def __init__(
6464

6565
async def aclose(self) -> None:
6666
"""Close the underlying transport if it supports closing."""
67-
close = getattr(self._transport, "aclose", None)
68-
if close is not None:
69-
await close()
67+
await self._transport.aclose()
7068

7169
async def __aenter__(self) -> Self:
7270
"""Enter the async context manager."""

src/vws/async_vumark_service.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ def __init__(
5050

5151
async def aclose(self) -> None:
5252
"""Close the underlying transport if it supports closing."""
53-
close = getattr(self._transport, "aclose", None)
54-
if close is not None:
55-
await close()
53+
await self._transport.aclose()
5654

5755
async def __aenter__(self) -> Self:
5856
"""Enter the async context manager."""

src/vws/async_vws.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ def __init__(
6161

6262
async def aclose(self) -> None:
6363
"""Close the underlying transport if it supports closing."""
64-
close = getattr(self._transport, "aclose", None)
65-
if close is not None:
66-
await close()
64+
await self._transport.aclose()
6765

6866
async def __aenter__(self) -> Self:
6967
"""Enter the async context manager."""

src/vws/transports.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ class AsyncTransport(Protocol):
167167
and returns a ``Response``.
168168
"""
169169

170+
async def aclose(self) -> None:
171+
"""Close the transport and release resources."""
172+
... # pylint: disable=unnecessary-ellipsis
173+
170174
def __call__(
171175
self,
172176
*,

0 commit comments

Comments
 (0)