Fix repr for device created with no sysinfo or discovery info" (#1266)

Co-authored-by: Teemu R. <tpr@iki.fi>
This commit is contained in:
Steven B.
2024-11-18 13:14:39 +00:00
committed by GitHub
parent fd5258c28b
commit 9d46996e9b
7 changed files with 101 additions and 18 deletions

View File

@@ -42,7 +42,9 @@ def requires_update(f: Callable) -> Any:
@functools.wraps(f)
async def wrapped(*args: Any, **kwargs: Any) -> Any:
self = args[0]
if self._last_update is None and f.__name__ not in self._sys_info:
if self._last_update is None and (
self._sys_info is None or f.__name__ not in self._sys_info
):
raise KasaException("You need to await update() to access the data")
return await f(*args, **kwargs)
@@ -51,7 +53,9 @@ def requires_update(f: Callable) -> Any:
@functools.wraps(f)
def wrapped(*args: Any, **kwargs: Any) -> Any:
self = args[0]
if self._last_update is None and f.__name__ not in self._sys_info:
if self._last_update is None and (
self._sys_info is None or f.__name__ not in self._sys_info
):
raise KasaException("You need to await update() to access the data")
return f(*args, **kwargs)