Commit f2c1366
committed
🗑️ Deprecate the two *-time-ago aggregation methods (#44)
## Summary
Soft-deprecates the two legacy aggregation aliases in favour of their current-spelling replacements:
- `get_site_networks_ts_time_ago` → **`get_site_time_series`**
- `get_site_consumption_breakdown_time_ago` → **`get_top_consumption`**
Both legacy methods now emit a `DeprecationWarning` (with `stacklevel=2`, so it points at the caller) but are **otherwise unchanged**: same endpoints (`site-networks-ts-time-ago` / `consumption-breakdown-time-ago`, both still returning `200` live), same defaults, same response shape. Nothing is removed — existing callers (e.g. the Home Assistant integration) keep working without changes.
Why not just delete them / re-point them at the new endpoints? Because the new methods have **different defaults** (`aggregation_level` NONE→HOUR, `time_ago_unit` HOUR→DAY), so delegating would silently change behaviour for callers relying on defaults. A pure soft-deprecation is zero-risk.
## Changes
- `comwatt_client/_aggregations.py`: `warnings.warn(..., DeprecationWarning, stacklevel=2)` at the top of both methods + a `.. deprecated::` docstring note.
- `tests/test_aggregations.py`: two new tests asserting the warning category/message and that behaviour (endpoint + returned data) is unchanged; the existing legacy-method tests get a per-test `@pytest.mark.filterwarnings("ignore::DeprecationWarning")` so the project's global `filterwarnings = error` policy stays intact everywhere else.
- `README.md`: both methods flagged **Deprecated** in the feature list; usage example switched to `get_site_time_series` / `get_top_consumption`.
## Not included (by request)
- No version bump / release commit — releases are separate commits in this repo.
## Test plan
- [x] `pytest` → 94 passed (2 new).
- [x] `mypy comwatt_client` → clean.
- [x] `filterwarnings = error` kept globally; only the legacy-method tests opt out.
Opened as a draft (WIP) — mark ready for review when you're happy.
Co-authored-by: Mateo Greil <mateo@go-electra.com>
Reviewed-on: https://git.greil.fr/mat/python-comwatt-client/pulls/441 parent 84c12a8 commit f2c1366
3 files changed
Lines changed: 89 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
| 16 | + | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
72 | | - | |
73 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
74 | 74 | | |
75 | | - | |
76 | | - | |
77 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
79 | 86 | | |
80 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
81 | 95 | | |
82 | 96 | | |
83 | 97 | | |
| |||
115 | 129 | | |
116 | 130 | | |
117 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
118 | 138 | | |
119 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
120 | 147 | | |
121 | 148 | | |
122 | 149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| 58 | + | |
56 | 59 | | |
57 | 60 | | |
58 | 61 | | |
| |||
81 | 84 | | |
82 | 85 | | |
83 | 86 | | |
| 87 | + | |
84 | 88 | | |
85 | 89 | | |
86 | 90 | | |
| |||
96 | 100 | | |
97 | 101 | | |
98 | 102 | | |
| 103 | + | |
99 | 104 | | |
100 | 105 | | |
101 | 106 | | |
| |||
120 | 125 | | |
121 | 126 | | |
122 | 127 | | |
| 128 | + | |
123 | 129 | | |
124 | 130 | | |
125 | 131 | | |
| |||
147 | 153 | | |
148 | 154 | | |
149 | 155 | | |
| 156 | + | |
150 | 157 | | |
151 | 158 | | |
152 | 159 | | |
| |||
188 | 195 | | |
189 | 196 | | |
190 | 197 | | |
| 198 | + | |
191 | 199 | | |
192 | 200 | | |
193 | 201 | | |
| |||
214 | 222 | | |
215 | 223 | | |
216 | 224 | | |
| 225 | + | |
217 | 226 | | |
218 | 227 | | |
219 | 228 | | |
| |||
240 | 249 | | |
241 | 250 | | |
242 | 251 | | |
| 252 | + | |
243 | 253 | | |
244 | 254 | | |
245 | 255 | | |
| |||
260 | 270 | | |
261 | 271 | | |
262 | 272 | | |
| 273 | + | |
263 | 274 | | |
264 | 275 | | |
265 | 276 | | |
| |||
281 | 292 | | |
282 | 293 | | |
283 | 294 | | |
| 295 | + | |
284 | 296 | | |
285 | 297 | | |
286 | 298 | | |
| |||
290 | 302 | | |
291 | 303 | | |
292 | 304 | | |
| 305 | + | |
293 | 306 | | |
294 | 307 | | |
295 | 308 | | |
| |||
316 | 329 | | |
317 | 330 | | |
318 | 331 | | |
| 332 | + | |
319 | 333 | | |
320 | 334 | | |
321 | 335 | | |
| |||
702 | 716 | | |
703 | 717 | | |
704 | 718 | | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
0 commit comments