Skip to content

Commit

Permalink
Add type annotations to controllers inheriting BaseMediaPlayer (#809)
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery authored Feb 1, 2024
1 parent e1d2547 commit 21c9072
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ disallow_untyped_decorators = true
disallow_untyped_defs = true
warn_return_any = true
warn_unreachable = true
files = pychromecast/__init__.py, pychromecast/config.py, pychromecast/const.py, pychromecast/dial.py, pychromecast/discovery.py, pychromecast/error.py, pychromecast/models.py, pychromecast/response_handler.py, pychromecast/socket_client.py, pychromecast/controllers/__init__.py, pychromecast/controllers/media.py, pychromecast/controllers/multizone.py, pychromecast/controllers/receiver.py
files = pychromecast/__init__.py, pychromecast/config.py, pychromecast/const.py, pychromecast/dial.py, pychromecast/discovery.py, pychromecast/error.py, pychromecast/models.py, pychromecast/response_handler.py, pychromecast/socket_client.py, pychromecast/controllers/__init__.py, pychromecast/controllers/bbciplayer.py, pychromecast/controllers/bbcsounds.py, pychromecast/controllers/bubbleupnp.py, pychromecast/controllers/homeassistant_media.py, pychromecast/controllers/media.py, pychromecast/controllers/multizone.py, pychromecast/controllers/nrkradio.py, pychromecast/controllers/receiver.py, pychromecast/controllers/nrktv.py, pychromecast/controllers/shaka.py
11 changes: 9 additions & 2 deletions pychromecast/controllers/bbciplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# b09w70r2 | 960x540"

import logging
from typing import Any

from .media import STREAM_TYPE_BUFFERED, STREAM_TYPE_LIVE, BaseMediaPlayer
from ..config import APP_BBCIPLAYER
Expand All @@ -18,12 +19,18 @@
class BbcIplayerController(BaseMediaPlayer):
"""Controller to interact with BBC iPlayer namespace."""

def __init__(self):
def __init__(self) -> None:
super().__init__(APP_BBCIPLAYER)
self.logger = logging.getLogger(__name__)

# pylint: disable-next=arguments-differ
def quick_play(self, media_id=None, is_live=False, metadata=None, **kwargs):
def quick_play(
self,
media_id: str | None = None,
is_live: bool = False,
metadata: dict[str, Any] | None = None,
**kwargs: Any
) -> None:
"""Quick Play helper for BBC iPlayer media."""
stream_type = STREAM_TYPE_LIVE if is_live else STREAM_TYPE_BUFFERED
metadata_default = {"metadataType": 0, "title": ""}
Expand Down
11 changes: 9 additions & 2 deletions pychromecast/controllers/bbcsounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# e.g. https://www.bbc.co.uk/sounds/live:bbc_radio_one

import logging
from typing import Any

from .media import STREAM_TYPE_BUFFERED, STREAM_TYPE_LIVE, BaseMediaPlayer
from ..config import APP_BBCSOUNDS
Expand All @@ -15,12 +16,18 @@
class BbcSoundsController(BaseMediaPlayer):
"""Controller to interact with BBC Sounds namespace."""

def __init__(self):
def __init__(self) -> None:
super().__init__(APP_BBCSOUNDS)
self.logger = logging.getLogger(__name__)

# pylint: disable-next=arguments-differ
def quick_play(self, media_id=None, is_live=False, metadata=None, **kwargs):
def quick_play(
self,
media_id: str | None = None,
is_live: bool = False,
metadata: dict[str, Any] | None = None,
**kwargs: Any
) -> Any:
"""Quick Play helper for BBC Sounds media"""
stream_type = STREAM_TYPE_LIVE if is_live else STREAM_TYPE_BUFFERED
metadata_default = {"metadataType": 0, "title": ""}
Expand Down
4 changes: 2 additions & 2 deletions pychromecast/controllers/bubbleupnp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
Simple Controller to use BubbleUPNP as a media controller.
"""

from ..config import APP_BUBBLEUPNP
from .media import BaseMediaPlayer
from ..config import APP_BUBBLEUPNP


class BubbleUPNPController(BaseMediaPlayer):
"""Controller to interact with BubbleUPNP app namespace."""

def __init__(self):
def __init__(self) -> None:
super().__init__(supporting_app_id=APP_BUBBLEUPNP)
2 changes: 1 addition & 1 deletion pychromecast/controllers/homeassistant_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
class HomeAssistantMediaController(BaseMediaPlayer):
"""Controller to interact with HomeAssistantMedia app namespace."""

def __init__(self):
def __init__(self) -> None:
super().__init__(supporting_app_id=APP_HOMEASSISTANT_MEDIA)
2 changes: 1 addition & 1 deletion pychromecast/controllers/nrkradio.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
class NrkRadioController(BaseMediaPlayer):
"""Controller to interact with NRK Radio."""

def __init__(self):
def __init__(self) -> None:
super().__init__(supporting_app_id=APP_NRKRADIO)
2 changes: 1 addition & 1 deletion pychromecast/controllers/nrktv.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
class NrkTvController(BaseMediaPlayer):
"""Controller to interact with NRK TV."""

def __init__(self):
def __init__(self) -> None:
super().__init__(supporting_app_id=APP_NRKTV)
2 changes: 1 addition & 1 deletion pychromecast/controllers/shaka.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
class ShakaController(BaseMediaPlayer):
"""Controller to interact with Shaka app namespace."""

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

0 comments on commit 21c9072

Please sign in to comment.