Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Hjelmare <[email protected]>
  • Loading branch information
joostlek and MartinHjelmare authored Sep 9, 2023
1 parent 01f1884 commit 48179d5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions homeassistant/components/vlc_telnet/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __init__(
@catch_vlc_errors
async def async_update(self) -> None:
"""Get the latest details from the device."""
if not self._attr_available:
if not self.available:
try:
await self._vlc.connect()
except ConnectError as err:
Expand Down Expand Up @@ -145,7 +145,7 @@ async def async_update(self) -> None:
vlc_position = time_output.time

# Check if current position is stale.
if vlc_position != self._attr_media_position:
if vlc_position != self.media_position:
self._attr_media_position_updated_at = dt_util.utcnow()
self._attr_media_position = vlc_position

Expand All @@ -160,11 +160,11 @@ async def async_update(self) -> None:

# Many radio streams put artist/title/album in now_playing and title is the station name.
if now_playing:
if not self._attr_media_artist:
if not self.media_artist:
self._attr_media_artist = self._attr_media_title
self._attr_media_title = now_playing

if self._attr_media_title:
if self.media_title:
return

# Fall back to filename.
Expand All @@ -173,7 +173,7 @@ async def async_update(self) -> None:

# Strip out auth signatures if streaming local media
if (
self._attr_media_title
self.media_title
and (pos := self._attr_media_title.find("?authSig=")) != -1

Check failure on line 177 in homeassistant/components/vlc_telnet/media_player.py

View workflow job for this annotation

GitHub Actions / Check mypy

Item "None" of "str | None" has no attribute "find" [union-attr]
):
self._attr_media_title = self._attr_media_title[:pos]

Check failure on line 179 in homeassistant/components/vlc_telnet/media_player.py

View workflow job for this annotation

GitHub Actions / Check mypy

Value of type "str | None" is not indexable [index]
Expand Down Expand Up @@ -201,7 +201,7 @@ async def async_set_volume_level(self, volume: float) -> None:
await self._vlc.set_volume(round(volume * MAX_VOLUME))
self._attr_volume_level = volume

if self._attr_is_volume_muted and self._attr_volume_level > 0:
if self.is_volume_muted and self.volume_level > 0:

Check failure on line 204 in homeassistant/components/vlc_telnet/media_player.py

View workflow job for this annotation

GitHub Actions / Check mypy

Unsupported operand types for < ("int" and "None") [operator]
# This can happen if we were muted and then see a volume_up.
self._attr_is_volume_muted = False

Expand Down

0 comments on commit 48179d5

Please sign in to comment.