|
| 1 | +from _typeshed import Incomplete |
| 2 | +from collections.abc import Awaitable, Callable, Iterable, Mapping |
1 | 3 | from types import TracebackType |
| 4 | +from typing import TypeVar |
2 | 5 |
|
3 | | -from .models.segment import SegmentContextManager |
4 | | -from .models.subsegment import SubsegmentContextManager |
| 6 | +from .models.dummy_entities import DummySegment, DummySubsegment |
| 7 | +from .models.segment import Segment, SegmentContextManager |
| 8 | +from .models.subsegment import Subsegment, SubsegmentContextManager |
5 | 9 | from .recorder import AWSXRayRecorder |
6 | 10 |
|
| 11 | +_T = TypeVar("_T") |
| 12 | + |
7 | 13 | class AsyncSegmentContextManager(SegmentContextManager): |
8 | | - async def __aenter__(self): ... |
| 14 | + async def __aenter__(self) -> DummySegment | Segment: ... |
9 | 15 | async def __aexit__( |
10 | 16 | self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None |
11 | 17 | ) -> None: ... |
12 | 18 |
|
13 | 19 | class AsyncSubsegmentContextManager(SubsegmentContextManager): |
14 | | - async def __call__(self, wrapped, instance, args, kwargs): ... |
15 | | - async def __aenter__(self): ... |
| 20 | + async def __call__( |
| 21 | + self, wrapped: Callable[..., Awaitable[_T]], instance, args: Iterable[Incomplete], kwargs: Mapping[str, Incomplete] |
| 22 | + ) -> _T: ... |
| 23 | + async def __aenter__(self) -> DummySubsegment | Subsegment | None: ... |
16 | 24 | async def __aexit__( |
17 | 25 | self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None |
18 | 26 | ) -> None: ... |
19 | 27 |
|
20 | 28 | class AsyncAWSXRayRecorder(AWSXRayRecorder): |
21 | | - def capture_async(self, name=None): ... |
22 | | - def in_segment_async(self, name=None, **segment_kwargs): ... |
23 | | - def in_subsegment_async(self, name=None, **subsegment_kwargs): ... |
24 | | - async def record_subsegment_async(self, wrapped, instance, args, kwargs, name, namespace, meta_processor): ... |
| 29 | + def capture_async(self, name: str | None = None) -> AsyncSubsegmentContextManager: ... |
| 30 | + def in_segment_async( |
| 31 | + self, name: str | None = None, *, traceid: str | None = None, parent_id: str | None = None, sampling: bool | None = None |
| 32 | + ) -> AsyncSegmentContextManager: ... |
| 33 | + def in_subsegment_async(self, name: str | None = None, *, namespace: str = "local") -> AsyncSubsegmentContextManager: ... |
| 34 | + async def record_subsegment_async( |
| 35 | + self, |
| 36 | + wrapped: Callable[..., Awaitable[_T]], |
| 37 | + instance, |
| 38 | + args: Iterable[Incomplete], |
| 39 | + kwargs: Mapping[str, Incomplete], |
| 40 | + name: str, |
| 41 | + namespace: str, |
| 42 | + meta_processor: Callable[..., object] | None, |
| 43 | + ) -> _T: ... |
0 commit comments