Skip to content

get_stats() raises TypeError when the API returns result: null #45

Description

@don4of4

In get_stats() on main:

info, sw_data = await asyncio.gather(*tasks)
data = info["runtimeData"]   # TypeError when info is None
if data is None:             # the guard is one line too late
    raise InvalidDataException

get_composite_info() returns (await self._get(url, params))["result"], which is None when the API replies result: null — seen intermittently on working accounts (richo/homeassistant-franklinwh#82, and reproduced on mine). Callers get TypeError: 'NoneType' object is not subscriptable instead of InvalidDataException.

data = info.get("runtimeData") if info else None before the check fixes it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions