Improve typing in ping binary sensor (#87073)
This commit is contained in:
parent
22c295fbdc
commit
275438adf3
1 changed files with 11 additions and 7 deletions
|
@ -70,10 +70,10 @@ async def async_setup_platform(
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the Ping Binary sensor."""
|
"""Set up the Ping Binary sensor."""
|
||||||
host = config[CONF_HOST]
|
host: str = config[CONF_HOST]
|
||||||
count = config[CONF_PING_COUNT]
|
count: int = config[CONF_PING_COUNT]
|
||||||
name = config.get(CONF_NAME, f"{DEFAULT_NAME} {host}")
|
name: str = config.get(CONF_NAME, f"{DEFAULT_NAME} {host}")
|
||||||
privileged = hass.data[DOMAIN][PING_PRIVS]
|
privileged: bool | None = hass.data[DOMAIN][PING_PRIVS]
|
||||||
ping_cls: type[PingDataSubProcess | PingDataICMPLib]
|
ping_cls: type[PingDataSubProcess | PingDataICMPLib]
|
||||||
if privileged is None:
|
if privileged is None:
|
||||||
ping_cls = PingDataSubProcess
|
ping_cls = PingDataSubProcess
|
||||||
|
@ -156,7 +156,7 @@ class PingBinarySensor(RestoreEntity, BinarySensorEntity):
|
||||||
class PingData:
|
class PingData:
|
||||||
"""The base class for handling the data retrieval."""
|
"""The base class for handling the data retrieval."""
|
||||||
|
|
||||||
def __init__(self, hass, host, count) -> None:
|
def __init__(self, hass: HomeAssistant, host: str, count: int) -> None:
|
||||||
"""Initialize the data object."""
|
"""Initialize the data object."""
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
self._ip_address = host
|
self._ip_address = host
|
||||||
|
@ -168,7 +168,9 @@ class PingData:
|
||||||
class PingDataICMPLib(PingData):
|
class PingDataICMPLib(PingData):
|
||||||
"""The Class for handling the data retrieval using icmplib."""
|
"""The Class for handling the data retrieval using icmplib."""
|
||||||
|
|
||||||
def __init__(self, hass, host, count, privileged) -> None:
|
def __init__(
|
||||||
|
self, hass: HomeAssistant, host: str, count: int, privileged: bool | None
|
||||||
|
) -> None:
|
||||||
"""Initialize the data object."""
|
"""Initialize the data object."""
|
||||||
super().__init__(hass, host, count)
|
super().__init__(hass, host, count)
|
||||||
self._privileged = privileged
|
self._privileged = privileged
|
||||||
|
@ -203,7 +205,9 @@ class PingDataICMPLib(PingData):
|
||||||
class PingDataSubProcess(PingData):
|
class PingDataSubProcess(PingData):
|
||||||
"""The Class for handling the data retrieval using the ping binary."""
|
"""The Class for handling the data retrieval using the ping binary."""
|
||||||
|
|
||||||
def __init__(self, hass, host, count, privileged) -> None:
|
def __init__(
|
||||||
|
self, hass: HomeAssistant, host: str, count: int, privileged: bool | None
|
||||||
|
) -> None:
|
||||||
"""Initialize the data object."""
|
"""Initialize the data object."""
|
||||||
super().__init__(hass, host, count)
|
super().__init__(hass, host, count)
|
||||||
self._ping_cmd = [
|
self._ping_cmd = [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue