Skip to content

Commit d86187f

Browse files
committed
Add docstrings for class attributes in AST nodes
Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 6a78e50 commit d86187f

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

src/frequenz/sdk/timeseries/formulas/_ast.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,19 @@ class TelemetryStream(AstNode[QuantityT]):
2626
"""A AST node that retrieves values from a component's telemetry stream."""
2727

2828
source: str
29+
"""The source formula string."""
30+
2931
metric_fetcher: (
3032
Callable[
3133
[], Coroutine[None, None, Receiver[Sample[QuantityT] | Sample[Quantity]]]
3234
]
3335
| None
3436
)
37+
"""A callable that fetches the telemetry stream for this component."""
38+
3539
create_method: Callable[[float], QuantityT]
40+
"""A method to create QuantityT from a base float value."""
41+
3642
_stream: Receiver[Sample[QuantityT] | Sample[Quantity]] | None = None
3743
_latest_sample: Sample[QuantityT] | None = None
3844

@@ -100,6 +106,7 @@ class Constant(AstNode[QuantityT]):
100106
"""A constant numerical value in the formula."""
101107

102108
value: QuantityT
109+
"""The constant value."""
103110

104111
@override
105112
async def evaluate(self) -> QuantityT | None:
@@ -125,7 +132,11 @@ class Add(AstNode[QuantityT]):
125132
"""Addition operation node."""
126133

127134
left: AstNode[QuantityT]
135+
"""The left operand."""
136+
128137
right: AstNode[QuantityT]
138+
"""The right operand."""
139+
129140
_synchronizer: NodeSynchronizer[QuantityT] = field(
130141
init=False, default_factory=NodeSynchronizer
131142
)
@@ -198,7 +209,11 @@ class Sub(AstNode[QuantityT]):
198209
"""Subtraction operation node."""
199210

200211
left: AstNode[QuantityT]
212+
"""The left operand."""
213+
201214
right: AstNode[QuantityT]
215+
"""The right operand."""
216+
202217
_synchronizer: NodeSynchronizer[QuantityT] = field(
203218
init=False, default_factory=NodeSynchronizer
204219
)
@@ -271,7 +286,11 @@ class Mul(AstNode[QuantityT]):
271286
"""Multiplication operation node."""
272287

273288
left: AstNode[QuantityT]
289+
"""The left operand."""
290+
274291
right: AstNode[QuantityT]
292+
"""The right operand."""
293+
275294
_synchronizer: NodeSynchronizer[QuantityT] = field(
276295
init=False, default_factory=NodeSynchronizer
277296
)
@@ -343,7 +362,11 @@ class Div(AstNode[QuantityT]):
343362
"""Division operation node."""
344363

345364
left: AstNode[QuantityT]
365+
"""The left operand."""
366+
346367
right: AstNode[QuantityT]
368+
"""The right operand."""
369+
347370
_synchronizer: NodeSynchronizer[QuantityT] = field(
348371
init=False, default_factory=NodeSynchronizer
349372
)

src/frequenz/sdk/timeseries/formulas/_base_ast_node.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class AstNode(abc.ABC, Generic[QuantityT]):
2323
"""An abstract syntax tree node representing a formula expression."""
2424

2525
span: tuple[int, int] | None = None
26+
"""The span (start, end) of the expression in the input string."""
2627

2728
@abc.abstractmethod
2829
async def evaluate(self) -> Sample[QuantityT] | QuantityT | None:

src/frequenz/sdk/timeseries/formulas/_token.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class Component(Token):
2424
"""An electrical component token."""
2525

2626
id: str
27+
"""The unique ID of the component."""
2728

2829

2930
@dataclass

0 commit comments

Comments
 (0)