Improve entity type hints [p] (#77871)

This commit is contained in:
epenet 2022-09-06 09:51:33 +02:00 committed by GitHub
parent 6f564e4f51
commit 474844744b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 130 additions and 107 deletions

View file

@ -2,6 +2,7 @@
from __future__ import annotations
import logging
from typing import Any
from pulsectl import Pulse, PulseError
import voluptuous as vol
@ -100,7 +101,7 @@ class PALoopbackSwitch(SwitchEntity):
return None
@property
def available(self):
def available(self) -> bool:
"""Return true when connected to server."""
return self._pa_svr.connected
@ -114,7 +115,7 @@ class PALoopbackSwitch(SwitchEntity):
"""Return true if device is on."""
return self._module_idx is not None
def turn_on(self, **kwargs):
def turn_on(self, **kwargs: Any) -> None:
"""Turn the device on."""
if not self.is_on:
self._pa_svr.module_load(
@ -124,13 +125,13 @@ class PALoopbackSwitch(SwitchEntity):
else:
_LOGGER.warning(IGNORED_SWITCH_WARN)
def turn_off(self, **kwargs):
def turn_off(self, **kwargs: Any) -> None:
"""Turn the device off."""
if self.is_on:
self._pa_svr.module_unload(self._module_idx)
else:
_LOGGER.warning(IGNORED_SWITCH_WARN)
def update(self):
def update(self) -> None:
"""Refresh state in case an alternate process modified this data."""
self._module_idx = self._get_module_idx()