Skip to content

Commit 1856f87

Browse files
feat: add async context manager support to ClientTransport (linter)
1 parent 578c220 commit 1856f87

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/a2a/client/transports/base.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
from abc import ABC, abstractmethod
44
from collections.abc import AsyncGenerator, Callable
5+
from typing import TYPE_CHECKING
6+
7+
from typing_extensions import Self
8+
9+
10+
if TYPE_CHECKING:
11+
from types import TracebackType
512

613
from a2a.client.middleware import ClientCallContext
714
from a2a.types import (
@@ -21,15 +28,15 @@
2128
class ClientTransport(ABC):
2229
"""Abstract base class for a client transport."""
2330

24-
async def __aenter__(self) -> ClientTransport:
31+
async def __aenter__(self) -> Self:
2532
"""Enter the async context manager, returning the transport itself."""
2633
return self
2734

2835
async def __aexit__(
2936
self,
3037
exc_type: type[BaseException] | None,
3138
exc_val: BaseException | None,
32-
exc_tb: object | None,
39+
exc_tb: TracebackType | None,
3340
) -> None:
3441
"""Exit the async context manager, ensuring close() is called."""
3542
await self.close()

0 commit comments

Comments
 (0)