-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample_types.py
More file actions
64 lines (40 loc) · 1.47 KB
/
example_types.py
File metadata and controls
64 lines (40 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from __future__ import annotations
from typing import Any, Union, Callable, Protocol, Awaitable
from dataclasses import field, dataclass
@dataclass
class ExampleCheck:
"""Result of a single validation check in an example."""
name: str
passed: bool
details: str | None = None
@dataclass
class ExampleCleanupFailure:
"""Record of a cleanup action that failed."""
resource: str
reason: str
@dataclass
class ExampleCleanupStatus:
"""Tracks cleanup operations during example execution."""
attempted: list[str] = field(default_factory=lambda: [])
succeeded: list[str] = field(default_factory=lambda: [])
failed: list[ExampleCleanupFailure] = field(default_factory=lambda: [])
@dataclass
class ExampleResult:
"""Full result of running an example, including checks and cleanup status."""
resources_created: list[str]
checks: list[ExampleCheck]
cleanup_status: ExampleCleanupStatus
skipped: bool = False
@dataclass
class RecipeOutput:
"""Output from a recipe function before cleanup runs."""
resources_created: list[str]
checks: list[ExampleCheck]
CleanupAction = Callable[[], Union[None, Awaitable[None]]]
class CleanupTracker(Protocol):
"""Protocol for tracking cleanup actions."""
def add(self, resource: str, action: CleanupAction) -> None: ...
@dataclass
class RecipeContext:
"""Context passed to recipe functions."""
cleanup: Any # CleanupTracker, but using Any to avoid circular typing issues