Skip to content

Commit

Permalink
Add type annotations to controllers/yleareena.py (#815)
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery authored Feb 5, 2024
1 parent c44ace8 commit f569438
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 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/yleareena\.py$
| ^pychromecast/controllers/youtube\.py$
| ^pychromecast/quick_play\.py$
)
34 changes: 23 additions & 11 deletions pychromecast/controllers/yleareena.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Controller to interface with the Yle Areena app namespace.
"""

from typing import Any

from . import CallbackType
from .media import BaseMediaPlayer, STREAM_TYPE_BUFFERED, TYPE_LOAD, MESSAGE_TYPE
from ..config import APP_YLEAREENA
from ..error import PyChromecastError
Expand All @@ -11,19 +14,20 @@
class YleAreenaController(BaseMediaPlayer):
"""Controller to interact with Yle Areena app namespace."""

def __init__(self):
def __init__(self) -> None:
super().__init__(supporting_app_id=APP_YLEAREENA)

def play_areena_media( # pylint: disable=too-many-locals
self,
kaltura_id,
audio_language="",
text_language="off",
current_time=0,
autoplay=True,
stream_type=STREAM_TYPE_BUFFERED,
callback_function=None,
):
kaltura_id: str,
*,
audio_language: str = "",
text_language: str = "off",
current_time: float = 0,
autoplay: bool = True,
stream_type: str = STREAM_TYPE_BUFFERED,
callback_function: CallbackType | None = None,
) -> None:
"""
Play media with the entry id "kaltura_id".
This value can be found by loading a page on Areena, e.g. https://areena.yle.fi/1-50097921
Expand Down Expand Up @@ -54,15 +58,23 @@ def play_areena_media( # pylint: disable=too-many-locals
self.send_message(msg, inc_session_id=True, callback_function=callback_function)

# pylint: disable-next=arguments-differ
def quick_play(self, media_id=None, audio_lang="", text_lang="off", **kwargs):
def quick_play(
self,
media_id: str | None = None,
audio_lang: str = "",
text_lang: str = "off",
**kwargs: Any,
) -> None:
"""Quick Play"""
if media_id is None:
raise ValueError("media_id must be specified")
response_handler = WaitResponse(10)
self.play_areena_media(
media_id,
audio_language=audio_lang,
text_language=text_lang,
**kwargs,
callback_function=response_handler.callback
callback_function=response_handler.callback,
)
request_completed = response_handler.wait_response()

Expand Down

0 comments on commit f569438

Please sign in to comment.