Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type annotations to controllers/yleareena.py #815

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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