From c44ace8614031b25c8e74f44b02b7379e06cff15 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 5 Feb 2024 11:43:44 +0100 Subject: [PATCH] Add type annotations to controllers/supla.py (#813) --- mypy.ini | 1 - pychromecast/controllers/supla.py | 19 +++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/mypy.ini b/mypy.ini index 2a0482898..499abda04 100644 --- a/mypy.ini +++ b/mypy.ini @@ -22,7 +22,6 @@ warn_unreachable = true exclude = (?x)( ^pychromecast/generated/ # The protobuf autogenerated files are not annotated | ^pychromecast/controllers/plex\.py$ - | ^pychromecast/controllers/supla\.py$ | ^pychromecast/controllers/yleareena\.py$ | ^pychromecast/controllers/youtube\.py$ | ^pychromecast/quick_play\.py$ diff --git a/pychromecast/controllers/supla.py b/pychromecast/controllers/supla.py index ff93e49ee..3f71f473e 100644 --- a/pychromecast/controllers/supla.py +++ b/pychromecast/controllers/supla.py @@ -2,8 +2,9 @@ Controller to interface with Supla. """ import logging +from typing import Any -from . import BaseController +from . import BaseController, CallbackType from ..config import APP_SUPLA from ..error import PyChromecastError from ..response_handler import WaitResponse @@ -15,12 +16,18 @@ class SuplaController(BaseController): """Controller to interact with Supla namespace.""" - def __init__(self): + def __init__(self) -> None: super().__init__(APP_NAMESPACE, APP_SUPLA) self.logger = logging.getLogger(__name__) - def play_media(self, media_id, is_live=False, callback_function=None): + def play_media( + self, + media_id: str, + *, + is_live: bool = False, + callback_function: CallbackType | None = None + ) -> None: """ Play Supla media """ @@ -48,8 +55,12 @@ def play_media(self, media_id, is_live=False, callback_function=None): no_add_request_id=True, ) - def quick_play(self, media_id=None, is_live=False, **kwargs): + def quick_play( + self, media_id: str | None = None, is_live: bool = False, **kwargs: Any + ) -> None: """Quick Play""" + if media_id is None: + raise ValueError("media_id must be specified") response_handler = WaitResponse(10) self.play_media( media_id,