♻️ Split client.py into domain mixin modules #38
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "split-client"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
comwatt_client/client.pyhad grown to ~620 lines holding transport, auth and every endpoint. This splits it into a_BaseClientcore plus one private mixin module per API domain — pure refactor, zero behavior change.Layout
_core.py_BaseClient: session, timeout,_request(auto-reauth), error mapping,close, context manager_auth.pyauthenticate,is_authenticated,_hash_password_aggregations.py_aggregations_query,_format_timestamp_devices.pyget_devices,get_device,put_device,get_device_kinds,switch_capacity_sites.pyget_sites,get_authenticated_user,get_tiles_connected_objects.pyget_measure_keysclient.pyComwattClient(AuthMixin, AggregationsMixin, DevicesMixin, SitesMixin, ConnectedObjectsMixin)— 21 linesCompatibility
from comwatt_client import ComwattClientandfrom comwatt_client.client import ComwattClientboth keep working;__init__.pyuntouched.__enter__TypeVar annotation adjusted,typing.Selfneeds 3.11 and floor is 3.10).get_tiles(#34) andget_device_kinds(#35) placed in their domain mixins.import json; updated hash reference indocs/energy.comwatt.com/auth.md.Tests
disallow_untyped_defs)b56907b8b9641c651212Rebased on main (now includes #36 and #37).
New module in the layout:
_grid.py→GridMixinwith the external grid-signal/tariff endpoints:get_electricity_price(site_id)(EDF Tempo, #37)get_ecowatt()(RTE EcoWatt, #36)ComwattClientis now(AuthMixin, AggregationsMixin, DevicesMixin, GridMixin, SitesMixin, ConnectedObjectsMixin).Verified after rebase: 85/85 tests passing (tests unmodified), mypy clean (10 source files).