Skip to content

Commit

Permalink
Add type annotations to controllers/supla.py (#813)
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery committed Feb 5, 2024
1 parent 62a5bed commit c44ace8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
1 change: 0 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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$
Expand Down
19 changes: 15 additions & 4 deletions pychromecast/controllers/supla.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
"""
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c44ace8

Please sign in to comment.