Remove ping from mypy ignored modules (#64439)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
4a102d6b2a
commit
211b99e22d
4 changed files with 21 additions and 21 deletions
|
@ -74,6 +74,7 @@ async def async_setup_platform(
|
|||
count = config[CONF_PING_COUNT]
|
||||
name = config.get(CONF_NAME, f"{DEFAULT_NAME} {host}")
|
||||
privileged = hass.data[DOMAIN][PING_PRIVS]
|
||||
ping_cls: type[PingDataSubProcess | PingDataICMPLib]
|
||||
if privileged is None:
|
||||
ping_cls = PingDataSubProcess
|
||||
else:
|
||||
|
@ -87,7 +88,7 @@ async def async_setup_platform(
|
|||
class PingBinarySensor(RestoreEntity, BinarySensorEntity):
|
||||
"""Representation of a Ping Binary sensor."""
|
||||
|
||||
def __init__(self, name: str, ping) -> None:
|
||||
def __init__(self, name: str, ping: PingDataSubProcess | PingDataICMPLib) -> None:
|
||||
"""Initialize the Ping Binary sensor."""
|
||||
self._available = False
|
||||
self._name = name
|
||||
|
@ -99,7 +100,7 @@ class PingBinarySensor(RestoreEntity, BinarySensorEntity):
|
|||
return self._name
|
||||
|
||||
@property
|
||||
def available(self) -> str:
|
||||
def available(self) -> bool:
|
||||
"""Return if we have done the first ping."""
|
||||
return self._available
|
||||
|
||||
|
@ -114,9 +115,10 @@ class PingBinarySensor(RestoreEntity, BinarySensorEntity):
|
|||
return self._ping.is_alive
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> dict[str, Any]:
|
||||
def extra_state_attributes(self) -> dict[str, Any] | None:
|
||||
"""Return the state attributes of the ICMP checo request."""
|
||||
if self._ping.data is not False:
|
||||
if self._ping.data is None:
|
||||
return None
|
||||
return {
|
||||
ATTR_ROUND_TRIP_TIME_AVG: self._ping.data["avg"],
|
||||
ATTR_ROUND_TRIP_TIME_MAX: self._ping.data["max"],
|
||||
|
@ -159,7 +161,7 @@ class PingData:
|
|||
self.hass = hass
|
||||
self._ip_address = host
|
||||
self._count = count
|
||||
self.data = {}
|
||||
self.data: dict[str, Any] | None = None
|
||||
self.is_alive = False
|
||||
|
||||
|
||||
|
@ -187,7 +189,7 @@ class PingDataICMPLib(PingData):
|
|||
|
||||
self.is_alive = data.is_alive
|
||||
if not self.is_alive:
|
||||
self.data = False
|
||||
self.data = None
|
||||
return
|
||||
|
||||
self.data = {
|
||||
|
@ -270,11 +272,11 @@ class PingDataSubProcess(PingData):
|
|||
await pinger.kill()
|
||||
del pinger
|
||||
|
||||
return False
|
||||
return None
|
||||
except AttributeError:
|
||||
return False
|
||||
return None
|
||||
|
||||
async def async_update(self) -> None:
|
||||
"""Retrieve the latest details from the host."""
|
||||
self.data = await self.async_ping()
|
||||
self.is_alive = bool(self.data)
|
||||
self.is_alive = self.data is not None
|
||||
|
|
|
@ -11,7 +11,9 @@ from icmplib import async_multiping
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant import const, util
|
||||
from homeassistant.components.device_tracker import PLATFORM_SCHEMA
|
||||
from homeassistant.components.device_tracker import (
|
||||
PLATFORM_SCHEMA as BASE_PLATFORM_SCHEMA,
|
||||
)
|
||||
from homeassistant.components.device_tracker.const import (
|
||||
CONF_SCAN_INTERVAL,
|
||||
SCAN_INTERVAL,
|
||||
|
@ -32,7 +34,7 @@ PARALLEL_UPDATES = 0
|
|||
CONF_PING_COUNT = "count"
|
||||
CONCURRENT_PING_LIMIT = 6
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
PLATFORM_SCHEMA = BASE_PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Required(const.CONF_HOSTS): {cv.slug: cv.string},
|
||||
vol.Optional(CONF_PING_COUNT, default=1): cv.positive_int,
|
||||
|
|
3
mypy.ini
3
mypy.ini
|
@ -2155,9 +2155,6 @@ ignore_errors = true
|
|||
[mypy-homeassistant.components.philips_js.*]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.ping.*]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.pioneer.*]
|
||||
ignore_errors = true
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@ IGNORED_MODULES: Final[list[str]] = [
|
|||
"homeassistant.components.onvif.*",
|
||||
"homeassistant.components.ozw.*",
|
||||
"homeassistant.components.philips_js.*",
|
||||
"homeassistant.components.ping.*",
|
||||
"homeassistant.components.pioneer.*",
|
||||
"homeassistant.components.plaato.*",
|
||||
"homeassistant.components.plex.*",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue