diff --git a/src/uiprotect/cli/__init__.py b/src/uiprotect/cli/__init__.py index 8f20b661..70ba6ea6 100644 --- a/src/uiprotect/cli/__init__.py +++ b/src/uiprotect/cli/__init__.py @@ -279,14 +279,14 @@ def decode_ws_msg( ws_data: str | None = ARG_WS_DATA, ) -> None: """Decodes a base64 encoded UniFi Protect Websocket binary message.""" - if ws_file is None and ws_data is None: - typer.secho("Websocket data required", fg="red") + if ws_file is None and ws_data is None: # type: ignore[unreachable] + typer.secho("Websocket data required", fg="red") # type: ignore[unreachable] sys.exit(1) ws_data_raw = b"" if ws_file is not None: ws_data_raw = ws_file.read() - elif ws_data is not None: + elif ws_data is not None: # type: ignore[unreachable] ws_data_raw = base64.b64decode(ws_data.encode("utf8")) packet = WSPacket(ws_data_raw) diff --git a/src/uiprotect/cli/backup.py b/src/uiprotect/cli/backup.py index 7ff276ad..e3bb00ab 100644 --- a/src/uiprotect/cli/backup.py +++ b/src/uiprotect/cli/backup.py @@ -114,7 +114,7 @@ class EventTypeChoice(str, Enum): SMART_DETECT_LINE = d.EventType.SMART_DETECT_LINE.value -class EventSmartType(Base): +class EventSmartType(Base): # type: ignore[valid-type,misc] __tablename__ = "event_smart_type" id = Column(Integer, primary_key=True) @@ -122,7 +122,7 @@ class EventSmartType(Base): smart_type = Column(String(32), index=True) -class Event(Base): +class Event(Base): # type: ignore[valid-type,misc] __tablename__ = "event" __allow_unmapped__ = True diff --git a/src/uiprotect/data/base.py b/src/uiprotect/data/base.py index 3ffa44e5..2de8cd95 100644 --- a/src/uiprotect/data/base.py +++ b/src/uiprotect/data/base.py @@ -269,8 +269,8 @@ def _get_protect_dicts_set(cls) -> set[str]: @classmethod def _get_api(cls, api: ProtectApiClient | None) -> ProtectApiClient | None: """Helper method to try to find and the current ProjtectAPIClient instance from given data""" - if api is None and isinstance(cls, ProtectBaseObject) and hasattr(cls, "_api"): - api = cls._api + if api is None and isinstance(cls, ProtectBaseObject) and hasattr(cls, "_api"): # type: ignore[unreachable] + api = cls._api # type: ignore[unreachable] return api @@ -479,15 +479,15 @@ def unifi_dict( data[key] = self._unifi_dict_protect_obj_dict(data, key, use_obj) # all child objects have been serialized correctly do not do it twice - data: dict[str, Any] = serialize_unifi_obj(data, levels=2) + new_data: dict[str, Any] = serialize_unifi_obj(data, levels=2) remaps = self._get_to_unifi_remaps() - for to_key in set(data).intersection(remaps): - data[remaps[to_key]] = data.pop(to_key) + for to_key in set(new_data).intersection(remaps): + new_data[remaps[to_key]] = new_data.pop(to_key) - if "api" in data: - del data["api"] + if "api" in new_data: + del new_data["api"] - return data + return new_data def _inject_api( self, diff --git a/src/uiprotect/data/devices.py b/src/uiprotect/data/devices.py index 86b893e7..5635dc56 100644 --- a/src/uiprotect/data/devices.py +++ b/src/uiprotect/data/devices.py @@ -3225,7 +3225,7 @@ def _get_unifi_remaps(cls) -> dict[str, str]: def camera(self) -> Camera | None: """Paired Camera will always be none if no camera is paired""" if self.camera_id is None: - return None + return None # type: ignore[unreachable] return self.api.bootstrap.cameras[self.camera_id] diff --git a/src/uiprotect/utils.py b/src/uiprotect/utils.py index a921b1bd..9ed70d47 100644 --- a/src/uiprotect/utils.py +++ b/src/uiprotect/utils.py @@ -600,7 +600,7 @@ def run_async(callback: Coroutine[Any, Any, T]) -> T: """Run async coroutine.""" if sys.version_info >= (3, 11): return asyncio.run(callback) - loop = asyncio.get_event_loop() + loop = asyncio.get_event_loop() # type: ignore[unreachable] return loop.run_until_complete(callback)