♻️ refactor: use params= for query strings everywhere #204

Merged
mat merged 1 commit from refactor/params-style into main 2026-10-27 14:41:05 +00:00
Owner

Summary

Every f-string query construction moves to params= (#185) — 12 sites, not just the two the issue cited:

get_devices · get_tiles · get_electricity_price · get_measure_keys · get_alert_configs ·
get_thermal_control · switch_capacity · get_connected_objects (both branches) ·
create_typical_day (POST + params) · get_plannings / get_typical_days (via _paginate)

_paginate(path, params=None)  ──► params merged with the page counter in one dict
                                 (a "page" entry in params is rejected with ValueError)

params= URL-encodes values and keeps query keys greppable; site_uid / gateway_uid are opaque strings, so the f-string route was an encoding bug waiting to happen.

Evidence

  • Before: grep 'f"/.*?.*{' comwatt_client/ returned 12 query-building sites.
    After: the grep returns nothing. pytest -q → 242 passed with zero test edits — every existing query-string assertion (siteId, deviceId, enable=true/false, page merging) passes unchanged, proving the wire is identical. mypy → clean.

Merge Danger

Door: two-way

Blast Radius: low — same URLs for all current inputs. Note: #199 (paginate hardening) rewrites part of the old _paginate this PR replaces; whichever merges first, I will rebase the other myself (the page-cap guard moves into the new params loop).

Closes #185.

## Summary Every f-string query construction moves to `params=` (#185) — 12 sites, not just the two the issue cited: ```text get_devices · get_tiles · get_electricity_price · get_measure_keys · get_alert_configs · get_thermal_control · switch_capacity · get_connected_objects (both branches) · create_typical_day (POST + params) · get_plannings / get_typical_days (via _paginate) _paginate(path, params=None) ──► params merged with the page counter in one dict (a "page" entry in params is rejected with ValueError) ``` `params=` URL-encodes values and keeps query keys greppable; `site_uid` / `gateway_uid` are opaque strings, so the f-string route was an encoding bug waiting to happen. ## Evidence - **Before:** `grep 'f"/.*?.*{' comwatt_client/` returned 12 query-building sites. **After:** the grep returns nothing. `pytest -q` → **242 passed with zero test edits** — every existing query-string assertion (siteId, deviceId, enable=true/false, page merging) passes unchanged, proving the wire is identical. `mypy` → clean. ## Merge Danger **Door:** two-way **Blast Radius:** low — same URLs for all current inputs. Note: #199 (paginate hardening) rewrites part of the old `_paginate` this PR replaces; whichever merges first, I will rebase the other myself (the page-cap guard moves into the new `params` loop). Closes #185.
♻️ refactor: use params= for query strings everywhere
All checks were successful
Tests / forgejo-pytest (push) Successful in 44s
Tests / forgejo-pytest (pull_request) Successful in 44s
2013bfddf1
mat force-pushed refactor/params-style from 2013bfddf1
All checks were successful
Tests / forgejo-pytest (push) Successful in 44s
Tests / forgejo-pytest (pull_request) Successful in 44s
to 5f69ff8c0e
All checks were successful
Tests / forgejo-pytest (pull_request) Successful in 45s
Tests / forgejo-pytest (push) Successful in 46s
2026-10-27 14:40:56 +00:00
Compare
mat changed title from WIP: ♻️ refactor: use params= for query strings everywhere to ♻️ refactor: use params= for query strings everywhere 2026-10-27 14:41:04 +00:00
mat merged commit 7c7b19ef14 into main 2026-10-27 14:41:05 +00:00
Sign in to join this conversation.
No reviewers
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!204
No description provided.