Type vlc_telnet strictly (#59154)

This commit is contained in:
Martin Hjelmare 2021-11-05 14:42:08 +01:00 committed by GitHub
parent 442d65e8da
commit c0801c1233
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 11 deletions

View File

@ -135,6 +135,7 @@ homeassistant.components.uptime.*
homeassistant.components.uptimerobot.* homeassistant.components.uptimerobot.*
homeassistant.components.vacuum.* homeassistant.components.vacuum.*
homeassistant.components.vallox.* homeassistant.components.vallox.*
homeassistant.components.vlc_telnet.*
homeassistant.components.water_heater.* homeassistant.components.water_heater.*
homeassistant.components.watttime.* homeassistant.components.watttime.*
homeassistant.components.weather.* homeassistant.components.weather.*

View File

@ -104,7 +104,7 @@ def catch_vlc_errors(func: Func) -> Func:
"""Catch VLC errors.""" """Catch VLC errors."""
@wraps(func) @wraps(func)
async def wrapper(self, *args: Any, **kwargs: Any) -> Any: async def wrapper(self: VlcDevice, *args: Any, **kwargs: Any) -> Any:
"""Catch VLC errors and modify availability.""" """Catch VLC errors and modify availability."""
try: try:
await func(self, *args, **kwargs) await func(self, *args, **kwargs)
@ -206,12 +206,12 @@ class VlcDevice(MediaPlayerEntity):
self._media_title = data_info["filename"] self._media_title = data_info["filename"]
@property @property
def name(self): def name(self) -> str:
"""Return the name of the device.""" """Return the name of the device."""
return self._name return self._name
@property @property
def state(self): def state(self) -> str | None:
"""Return the state of the device.""" """Return the state of the device."""
return self._state return self._state
@ -226,42 +226,42 @@ class VlcDevice(MediaPlayerEntity):
return self._volume return self._volume
@property @property
def is_volume_muted(self): def is_volume_muted(self) -> bool | None:
"""Boolean if volume is currently muted.""" """Boolean if volume is currently muted."""
return self._muted return self._muted
@property @property
def supported_features(self): def supported_features(self) -> int:
"""Flag media player features that are supported.""" """Flag media player features that are supported."""
return SUPPORT_VLC return SUPPORT_VLC
@property @property
def media_content_type(self): def media_content_type(self) -> str:
"""Content type of current playing media.""" """Content type of current playing media."""
return MEDIA_TYPE_MUSIC return MEDIA_TYPE_MUSIC
@property @property
def media_duration(self): def media_duration(self) -> int | None:
"""Duration of current playing media in seconds.""" """Duration of current playing media in seconds."""
return self._media_duration return self._media_duration
@property @property
def media_position(self): def media_position(self) -> int | None:
"""Position of current playing media in seconds.""" """Position of current playing media in seconds."""
return self._media_position return self._media_position
@property @property
def media_position_updated_at(self): def media_position_updated_at(self) -> datetime | None:
"""When was the position of the current playing media valid.""" """When was the position of the current playing media valid."""
return self._media_position_updated_at return self._media_position_updated_at
@property @property
def media_title(self): def media_title(self) -> str | None:
"""Title of current playing media.""" """Title of current playing media."""
return self._media_title return self._media_title
@property @property
def media_artist(self): def media_artist(self) -> str | None:
"""Artist of current playing media, music track only.""" """Artist of current playing media, music track only."""
return self._media_artist return self._media_artist

View File

@ -1496,6 +1496,17 @@ no_implicit_optional = true
warn_return_any = true warn_return_any = true
warn_unreachable = true warn_unreachable = true
[mypy-homeassistant.components.vlc_telnet.*]
check_untyped_defs = true
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_decorators = true
disallow_untyped_defs = true
no_implicit_optional = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.water_heater.*] [mypy-homeassistant.components.water_heater.*]
check_untyped_defs = true check_untyped_defs = true
disallow_incomplete_defs = true disallow_incomplete_defs = true