mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Fix pylint failures caused by fritz (#49655)
* Fix test failures caused by fritz * Fix typing.Any Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
This commit is contained in:
parent
3077363f44
commit
7ecd4f5eed
@ -1,8 +1,10 @@
|
|||||||
"""Support for AVM FRITZ!Box classes."""
|
"""Support for AVM FRITZ!Box classes."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Dict, Optional
|
from typing import Any
|
||||||
|
|
||||||
# pylint: disable=import-error
|
# pylint: disable=import-error
|
||||||
from fritzconnection import FritzConnection
|
from fritzconnection import FritzConnection
|
||||||
@ -48,7 +50,7 @@ class FritzBoxTools:
|
|||||||
"""Initialize FritzboxTools class."""
|
"""Initialize FritzboxTools class."""
|
||||||
self._cancel_scan = None
|
self._cancel_scan = None
|
||||||
self._device_info = None
|
self._device_info = None
|
||||||
self._devices: Dict[str, Any] = {}
|
self._devices: dict[str, Any] = {}
|
||||||
self._unique_id = None
|
self._unique_id = None
|
||||||
self.connection = None
|
self.connection = None
|
||||||
self.fritzhosts = None
|
self.fritzhosts = None
|
||||||
@ -65,7 +67,6 @@ class FritzBoxTools:
|
|||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
"""Set up FritzboxTools class."""
|
"""Set up FritzboxTools class."""
|
||||||
|
|
||||||
self.connection = FritzConnection(
|
self.connection = FritzConnection(
|
||||||
address=self.host,
|
address=self.host,
|
||||||
port=self.port,
|
port=self.port,
|
||||||
@ -116,7 +117,7 @@ class FritzBoxTools:
|
|||||||
return self._device_info
|
return self._device_info
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def devices(self) -> Dict[str, Any]:
|
def devices(self) -> dict[str, Any]:
|
||||||
"""Return devices."""
|
"""Return devices."""
|
||||||
return self._devices
|
return self._devices
|
||||||
|
|
||||||
@ -134,9 +135,8 @@ class FritzBoxTools:
|
|||||||
"""Retrieve latest information from the FRITZ!Box."""
|
"""Retrieve latest information from the FRITZ!Box."""
|
||||||
return self.fritzhosts.get_hosts_info()
|
return self.fritzhosts.get_hosts_info()
|
||||||
|
|
||||||
def scan_devices(self, now: Optional[datetime] = None) -> None:
|
def scan_devices(self, now: datetime | None) -> None:
|
||||||
"""Scan for new devices and return a list of found device ids."""
|
"""Scan for new devices and return a list of found device ids."""
|
||||||
|
|
||||||
_LOGGER.debug("Checking devices for FRITZ!Box router %s", self.host)
|
_LOGGER.debug("Checking devices for FRITZ!Box router %s", self.host)
|
||||||
|
|
||||||
new_device = False
|
new_device = False
|
||||||
|
@ -118,7 +118,6 @@ class FritzBoxToolsFlowHandler(ConfigFlow):
|
|||||||
|
|
||||||
async def async_step_confirm(self, user_input=None):
|
async def async_step_confirm(self, user_input=None):
|
||||||
"""Handle user-confirmation of discovered node."""
|
"""Handle user-confirmation of discovered node."""
|
||||||
|
|
||||||
if user_input is None:
|
if user_input is None:
|
||||||
return self._show_setup_form_confirm()
|
return self._show_setup_form_confirm()
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
"""Support for FRITZ!Box routers."""
|
"""Support for FRITZ!Box routers."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from typing import Dict
|
from typing import Any
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -42,7 +44,6 @@ PLATFORM_SCHEMA = vol.All(
|
|||||||
|
|
||||||
async def async_get_scanner(hass: HomeAssistant, config: ConfigType):
|
async def async_get_scanner(hass: HomeAssistant, config: ConfigType):
|
||||||
"""Import legacy FRITZ!Box configuration."""
|
"""Import legacy FRITZ!Box configuration."""
|
||||||
|
|
||||||
_LOGGER.debug("Import legacy FRITZ!Box configuration from YAML")
|
_LOGGER.debug("Import legacy FRITZ!Box configuration from YAML")
|
||||||
|
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
@ -143,7 +144,7 @@ class FritzBoxTracker(ScannerEntity):
|
|||||||
return SOURCE_TYPE_ROUTER
|
return SOURCE_TYPE_ROUTER
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> Dict[str, any]:
|
def device_info(self) -> dict[str, Any]:
|
||||||
"""Return the device information."""
|
"""Return the device information."""
|
||||||
return {
|
return {
|
||||||
"connections": {(CONNECTION_NETWORK_MAC, self._mac)},
|
"connections": {(CONNECTION_NETWORK_MAC, self._mac)},
|
||||||
@ -168,7 +169,6 @@ class FritzBoxTracker(ScannerEntity):
|
|||||||
@callback
|
@callback
|
||||||
def async_process_update(self) -> None:
|
def async_process_update(self) -> None:
|
||||||
"""Update device."""
|
"""Update device."""
|
||||||
|
|
||||||
device = self._router.devices[self._mac]
|
device = self._router.devices[self._mac]
|
||||||
self._active = device.is_connected
|
self._active = device.is_connected
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user