[client] Consolidate mixin modules per #151 audit (batch, thermal-control, grid, contracts, plannings, typical-days) #176

Closed
opened 2026-10-27 11:31:53 +00:00 by mat · 0 comments
Owner

Executes the file-consolidation part of the #151 audit. All moves are between private modules — the public API (48 flat methods on ComwattClient, see README) is unchanged, no deprecation path needed.

Verified safety: no mixin carries state, no mixin defines __init__, cooperative super().__init__(timeout=, auto_reauth=) works (client.py), and there are zero method-name collisions across all 16 mixins.

Moves:

  • _batch.py → _aggregations.py: BatchMixin holds a single method, get_devices_ts_time_ago, which fans out get_device_ts_time_ago and reaches into the aggregations mixin via cast("AggregationsMixin", self) (_batch.py:41) — implicit MRO coupling that disappears once the method lives next to get_device_ts_time_ago. Drop the cast.
  • _thermal_control.py → _capacities.py: same actuation domain (capacity switch / pilot-wire vs thermal-control configs).
  • _grid.py + _electricity_contracts.py → one module: both are energy-market context reads (ecowatt, electricity price, contracts).
  • _typical_days.py + _plannings.py → one module: plannings embed typicalDaySchedules (_plannings.py:24), same scheduling domain.

Open choice: keep distinct mixin classes living in merged files, or merge the classes too (e.g. one SchedulingMixin) — either preserves the flat API. Update client.py imports accordingly.

Done when: modules merged, cast removed, pytest -q green, README unchanged.

Executes the file-consolidation part of the #151 audit. All moves are between private modules — the public API (48 flat methods on `ComwattClient`, see README) is unchanged, no deprecation path needed. **Verified safety:** no mixin carries state, no mixin defines `__init__`, cooperative `super().__init__(timeout=, auto_reauth=)` works (`client.py`), and there are zero method-name collisions across all 16 mixins. **Moves:** - `_batch.py` → `_aggregations.py`: `BatchMixin` holds a single method, `get_devices_ts_time_ago`, which fans out `get_device_ts_time_ago` and reaches into the aggregations mixin via `cast("AggregationsMixin", self)` (`_batch.py:41`) — implicit MRO coupling that disappears once the method lives next to `get_device_ts_time_ago`. Drop the cast. - `_thermal_control.py` → `_capacities.py`: same actuation domain (capacity switch / pilot-wire vs thermal-control configs). - `_grid.py` + `_electricity_contracts.py` → one module: both are energy-market context reads (ecowatt, electricity price, contracts). - `_typical_days.py` + `_plannings.py` → one module: plannings embed `typicalDaySchedules` (`_plannings.py:24`), same scheduling domain. **Open choice:** keep distinct mixin classes living in merged files, or merge the classes too (e.g. one `SchedulingMixin`) — either preserves the flat API. Update `client.py` imports accordingly. **Done when:** modules merged, cast removed, `pytest -q` green, README unchanged.
mat closed this issue 2026-10-27 14:41:47 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mat/python-comwatt-client#176
No description provided.