Skip to content

Commit 3e51a6c

Browse files
committed
Add ignore rules and document indirectly raised exceptions
The documentation linting expects functions to have a `raise` statement for each documented exception, so we need to add ignore rules when we want to document exceptions that are raised indirectly by other functions called in the implementation. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 23deabe commit 3e51a6c

File tree

8 files changed

+19
-12
lines changed

8 files changed

+19
-12
lines changed

src/frequenz/sdk/actor/power_distributing/_battery_pool_status.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class BatteryPoolStatus:
7070
Send set of working and uncertain batteries, when the any battery change status.
7171
"""
7272

73-
def __init__(
73+
def __init__( # noqa: DOC502 (RuntimeError is raised indirectly by BatteryStatus)
7474
self,
7575
battery_ids: Set[int],
7676
battery_status_sender: Sender[BatteryStatus],

src/frequenz/sdk/microgrid/client/_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ async def _expect_category(
443443
f", not a {expected_category}."
444444
)
445445

446-
async def meter_data(
446+
async def meter_data( # noqa: DOC502 (ValueError is raised indirectly by _expect_category)
447447
self,
448448
component_id: int,
449449
maxsize: int = RECEIVER_MAX_SIZE,
@@ -473,7 +473,7 @@ async def meter_data(
473473
MeterData.from_proto,
474474
).new_receiver(maxsize=maxsize)
475475

476-
async def battery_data(
476+
async def battery_data( # noqa: DOC502 (ValueError is raised indirectly by _expect_category)
477477
self,
478478
component_id: int,
479479
maxsize: int = RECEIVER_MAX_SIZE,
@@ -503,7 +503,7 @@ async def battery_data(
503503
BatteryData.from_proto,
504504
).new_receiver(maxsize=maxsize)
505505

506-
async def inverter_data(
506+
async def inverter_data( # noqa: DOC502 (ValueError is raised indirectly by _expect_category)
507507
self,
508508
component_id: int,
509509
maxsize: int = RECEIVER_MAX_SIZE,
@@ -533,7 +533,7 @@ async def inverter_data(
533533
InverterData.from_proto,
534534
).new_receiver(maxsize=maxsize)
535535

536-
async def ev_charger_data(
536+
async def ev_charger_data( # noqa: DOC502 (ValueError is raised indirectly by _expect_category)
537537
self,
538538
component_id: int,
539539
maxsize: int = RECEIVER_MAX_SIZE,

src/frequenz/sdk/timeseries/_formula_engine/_formula_generators/_chp_power_formula.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
class CHPPowerFormula(FormulaGenerator[Power]):
2626
"""Formula generator for CHP Power."""
2727

28-
def generate(self) -> FormulaEngine[Power]:
28+
def generate( # noqa: DOC502 (FormulaGenerationError is raised indirectly by _get_chp_meters)
29+
self,
30+
) -> FormulaEngine[Power]:
2931
"""Make a formula for the cumulative CHP power of a microgrid.
3032
3133
The calculation is performed by adding the active power measurements from

src/frequenz/sdk/timeseries/_formula_engine/_formula_generators/_grid_current_formula.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
class GridCurrentFormula(FormulaGenerator[Current]):
1515
"""Create a formula engine from the component graph for calculating grid current."""
1616

17-
def generate(self) -> FormulaEngine3Phase[Current]:
17+
def generate( # noqa: DOC502 (ComponentNotFound is raised indirectly by _get_grid_component_successors)
18+
self,
19+
) -> FormulaEngine3Phase[Current]:
1820
"""Generate a formula for calculating grid current from the component graph.
1921
2022
Returns:

src/frequenz/sdk/timeseries/_formula_engine/_formula_generators/_grid_power_formula.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class GridPowerFormula(FormulaGenerator[Power]):
1313
"""Creates a formula engine from the component graph for calculating grid power."""
1414

15-
def generate(
15+
def generate( # noqa: DOC502 (ComponentNotFound is raised indirectly by _get_grid_component_successors)
1616
self,
1717
) -> FormulaEngine[Power]:
1818
"""Generate a formula for calculating grid power from the component graph.

src/frequenz/sdk/timeseries/_formula_engine/_formula_generators/_pv_power_formula.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
class PVPowerFormula(FormulaGenerator[Power]):
1818
"""Creates a formula engine for calculating the PV power production."""
1919

20-
def generate(self) -> FormulaEngine[Power]:
20+
def generate( # noqa: DOC502 (ComponentNotFound and RuntimeError are raised
21+
# indirectly by _get_pv_power_components)
22+
self,
23+
) -> FormulaEngine[Power]:
2124
"""Make a formula for the PV power production of a microgrid.
2225
2326
Returns:

src/frequenz/sdk/timeseries/_ringbuffer/serialization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def load(path: str) -> OrderedRingBuffer[FloatArray] | None:
4545
return instance
4646

4747

48-
def dump(
48+
def dump( # noqa: DOC502 (OSError is raised indirectly by open and pickle.dump)
4949
ringbuffer: OrderedRingBuffer[FloatArray],
5050
path: str,
5151
file_format_version: int = FILE_FORMAT_VERSION,

src/frequenz/sdk/timeseries/battery_pool/_component_metric_fetcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class LatestBatteryMetricsFetcher(LatestMetricsFetcher[BatteryData]):
169169
"""Subscribe for the latest battery data using MicrogridApiClient."""
170170

171171
@classmethod
172-
async def async_new(
172+
async def async_new( # noqa: DOC502 (ValueError is raised indirectly super.async_new)
173173
cls,
174174
component_id: int,
175175
metrics: Iterable[ComponentMetricId],
@@ -220,7 +220,7 @@ class LatestInverterMetricsFetcher(LatestMetricsFetcher[InverterData]):
220220
"""Subscribe for the latest inverter data using MicrogridApiClient."""
221221

222222
@classmethod
223-
async def async_new(
223+
async def async_new( # noqa: DOC502 (ValueError is raised indirectly by super.async_new)
224224
cls,
225225
component_id: int,
226226
metrics: Iterable[ComponentMetricId],

0 commit comments

Comments
 (0)