Skip to content

Commit b3a08b8

Browse files
committed
fix(teslemetry): drop raw parameter from find_authorized_clients
list_authorized_clients() already returns the raw response, so find_authorized_clients() stays typed-only with no raw option.
1 parent 91b2603 commit b3a08b8

3 files changed

Lines changed: 8 additions & 36 deletions

File tree

docs/teslemetry.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -559,12 +559,11 @@ an unrecognized response shape raises
559559
never mistaken for "no authorized clients". The raw response is still
560560
available on `raw` for anything not modeled.
561561

562-
`find_authorized_clients(raw=True)` skips the typed parse and returns the
563-
exact response `list_authorized_clients()` would, matching the call shape of
564-
a local gateway path that also wants to opt out of typing. The parsing itself
565-
lives in the module-level `tesla_fleet_api.teslemetry.energysite.parse_authorized_clients`
566-
function, which other callers (e.g. a local/LAN client using the same
567-
envelope shape) can reuse directly to get the same `AuthorizedClients` result.
562+
The parsing itself lives in the module-level
563+
`tesla_fleet_api.teslemetry.energysite.parse_authorized_clients` function,
564+
which other callers (e.g. a local/LAN client using the same envelope shape)
565+
can reuse directly to get the same `AuthorizedClients` result. For the
566+
unparsed response, use `list_authorized_clients()`.
568567

569568
`remove_authorized_client(public_key)` accepts raw DER bytes or an already
570569
base64-encoded key string. Removal requires no physical presence proof, so any

tesla_fleet_api/teslemetry/energysite.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import warnings
99
from collections.abc import Awaitable, Callable
1010
from dataclasses import dataclass
11-
from typing import Any, Literal, overload, cast
11+
from typing import Any, cast
1212

1313
from tesla_fleet_api.const import (
1414
AuthorizationRole,
@@ -406,15 +406,7 @@ async def list_authorized_clients(self) -> dict[str, Any]:
406406
f"api/1/energy_sites/{self.energy_site_id}/command/authorized_clients",
407407
)
408408

409-
@overload
410-
async def find_authorized_clients(
411-
self, raw: Literal[False] = False
412-
) -> AuthorizedClients: ...
413-
@overload
414-
async def find_authorized_clients(self, raw: Literal[True]) -> dict[str, Any]: ...
415-
async def find_authorized_clients(
416-
self, raw: bool = False
417-
) -> AuthorizedClients | dict[str, Any]:
409+
async def find_authorized_clients(self) -> AuthorizedClients:
418410
"""List authorized clients on the energy gateway, parsed into a typed result.
419411
420412
Prefer this over :meth:`list_authorized_clients` for consumers that
@@ -426,14 +418,9 @@ async def find_authorized_clients(
426418
treating either as "no clients". See :class:`AuthorizedClients` for
427419
the exact parsing semantics.
428420
429-
``raw=True`` returns the unparsed response exactly as
430-
:meth:`list_authorized_clients` does, skipping the typed parse - for
431-
callers that want the same call shape aligned with the local
432-
gateway path while still opting out of typing.
421+
For the unparsed response, use :meth:`list_authorized_clients`.
433422
"""
434423
response = await self.list_authorized_clients()
435-
if raw:
436-
return response
437424
return parse_authorized_clients(response)
438425

439426
async def remove_authorized_client(self, public_key: bytes | str) -> dict[str, Any]:

tests/test_teslemetry_authorized_clients.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,6 @@ async def test_private_alias_still_works_for_one_release(self) -> None:
9696

9797

9898
class GetAuthorizedClientsTests(IsolatedAsyncioTestCase):
99-
async def test_raw_true_returns_unparsed_response(self) -> None:
100-
payload = {
101-
"response": {
102-
"authorized_clients": [
103-
{"public_key": PUBLIC_KEY_B64, "state": 3},
104-
]
105-
}
106-
}
107-
site = _make_site(payload)
108-
109-
result = await site.find_authorized_clients(raw=True)
110-
111-
self.assertEqual(result, payload)
112-
11399
async def test_default_raw_false_behaviour_unchanged(self) -> None:
114100
payload = {
115101
"response": {

0 commit comments

Comments
 (0)