From 631ab367e2ff3827b4b83e7bf1582d9ae7451031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 25 Apr 2021 22:36:21 +0300 Subject: [PATCH] Fix typing.Any spelling (#49673) --- .../components/asuswrt/device_tracker.py | 6 ++++-- homeassistant/components/asuswrt/sensor.py | 7 ++++--- homeassistant/components/dsmr/sensor.py | 3 ++- .../components/freebox/device_tracker.py | 7 ++++--- homeassistant/components/freebox/sensor.py | 17 +++++++++-------- homeassistant/components/freebox/switch.py | 3 ++- homeassistant/components/icloud/account.py | 7 ++++--- .../components/icloud/device_tracker.py | 6 ++++-- homeassistant/components/icloud/sensor.py | 6 ++++-- homeassistant/components/plugwise/gateway.py | 3 ++- .../components/synology_dsm/__init__.py | 7 ++++--- homeassistant/components/synology_dsm/camera.py | 3 ++- homeassistant/components/synology_dsm/switch.py | 3 ++- homeassistant/components/upnp/device.py | 3 ++- tests/components/mysensors/test_config_flow.py | 3 ++- tests/components/mysensors/test_init.py | 3 ++- tests/components/upnp/mock_device.py | 4 ++-- 17 files changed, 55 insertions(+), 36 deletions(-) diff --git a/homeassistant/components/asuswrt/device_tracker.py b/homeassistant/components/asuswrt/device_tracker.py index dabbc25ba10..abaa6c1965d 100644 --- a/homeassistant/components/asuswrt/device_tracker.py +++ b/homeassistant/components/asuswrt/device_tracker.py @@ -1,6 +1,8 @@ """Support for ASUSWRT routers.""" from __future__ import annotations +from typing import Any + from homeassistant.components.device_tracker import SOURCE_TYPE_ROUTER from homeassistant.components.device_tracker.config_entry import ScannerEntity from homeassistant.config_entries import ConfigEntry @@ -78,7 +80,7 @@ class AsusWrtDevice(ScannerEntity): return SOURCE_TYPE_ROUTER @property - def extra_state_attributes(self) -> dict[str, any]: + def extra_state_attributes(self) -> dict[str, Any]: """Return the attributes.""" attrs = {} if self._device.last_activity: @@ -103,7 +105,7 @@ class AsusWrtDevice(ScannerEntity): return self._device.mac @property - def device_info(self) -> dict[str, any]: + def device_info(self) -> dict[str, Any]: """Return the device information.""" data = { "connections": {(CONNECTION_NETWORK_MAC, self._device.mac)}, diff --git a/homeassistant/components/asuswrt/sensor.py b/homeassistant/components/asuswrt/sensor.py index a1a9b2ff3e8..7a3ffccc00b 100644 --- a/homeassistant/components/asuswrt/sensor.py +++ b/homeassistant/components/asuswrt/sensor.py @@ -3,6 +3,7 @@ from __future__ import annotations import logging from numbers import Number +from typing import Any from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry @@ -106,7 +107,7 @@ class AsusWrtSensor(CoordinatorEntity, SensorEntity): coordinator: DataUpdateCoordinator, router: AsusWrtRouter, sensor_type: str, - sensor: dict[str, any], + sensor: dict[str, Any], ) -> None: """Initialize a AsusWrt sensor.""" super().__init__(coordinator) @@ -161,11 +162,11 @@ class AsusWrtSensor(CoordinatorEntity, SensorEntity): return self._device_class @property - def extra_state_attributes(self) -> dict[str, any]: + def extra_state_attributes(self) -> dict[str, Any]: """Return the attributes.""" return {"hostname": self._router.host} @property - def device_info(self) -> dict[str, any]: + def device_info(self) -> dict[str, Any]: """Return the device information.""" return self._router.device_info diff --git a/homeassistant/components/dsmr/sensor.py b/homeassistant/components/dsmr/sensor.py index 656c066b980..3885302329a 100644 --- a/homeassistant/components/dsmr/sensor.py +++ b/homeassistant/components/dsmr/sensor.py @@ -7,6 +7,7 @@ from contextlib import suppress from datetime import timedelta from functools import partial import logging +from typing import Any from dsmr_parser import obis_references as obis_ref from dsmr_parser.clients.protocol import create_dsmr_reader, create_tcp_dsmr_reader @@ -361,7 +362,7 @@ class DSMREntity(SensorEntity): return self._unique_id @property - def device_info(self) -> dict[str, any]: + def device_info(self) -> dict[str, Any]: """Return the device information.""" return { "identifiers": {(DOMAIN, self._device_serial)}, diff --git a/homeassistant/components/freebox/device_tracker.py b/homeassistant/components/freebox/device_tracker.py index 7485c9da856..d2814a1c126 100644 --- a/homeassistant/components/freebox/device_tracker.py +++ b/homeassistant/components/freebox/device_tracker.py @@ -2,6 +2,7 @@ from __future__ import annotations from datetime import datetime +from typing import Any from homeassistant.components.device_tracker import SOURCE_TYPE_ROUTER from homeassistant.components.device_tracker.config_entry import ScannerEntity @@ -52,7 +53,7 @@ def add_entities(router, async_add_entities, tracked): class FreeboxDevice(ScannerEntity): """Representation of a Freebox device.""" - def __init__(self, router: FreeboxRouter, device: dict[str, any]) -> None: + def __init__(self, router: FreeboxRouter, device: dict[str, Any]) -> None: """Initialize a Freebox device.""" self._router = router self._name = device["primary_name"].strip() or DEFAULT_DEVICE_NAME @@ -105,12 +106,12 @@ class FreeboxDevice(ScannerEntity): return self._icon @property - def extra_state_attributes(self) -> dict[str, any]: + def extra_state_attributes(self) -> dict[str, Any]: """Return the attributes.""" return self._attrs @property - def device_info(self) -> dict[str, any]: + def device_info(self) -> dict[str, Any]: """Return the device information.""" return { "connections": {(CONNECTION_NETWORK_MAC, self._mac)}, diff --git a/homeassistant/components/freebox/sensor.py b/homeassistant/components/freebox/sensor.py index c121974f1fa..8f097b2d73a 100644 --- a/homeassistant/components/freebox/sensor.py +++ b/homeassistant/components/freebox/sensor.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry @@ -77,7 +78,7 @@ class FreeboxSensor(SensorEntity): """Representation of a Freebox sensor.""" def __init__( - self, router: FreeboxRouter, sensor_type: str, sensor: dict[str, any] + self, router: FreeboxRouter, sensor_type: str, sensor: dict[str, Any] ) -> None: """Initialize a Freebox sensor.""" self._state = None @@ -129,7 +130,7 @@ class FreeboxSensor(SensorEntity): return self._device_class @property - def device_info(self) -> dict[str, any]: + def device_info(self) -> dict[str, Any]: """Return the device information.""" return self._router.device_info @@ -160,7 +161,7 @@ class FreeboxCallSensor(FreeboxSensor): """Representation of a Freebox call sensor.""" def __init__( - self, router: FreeboxRouter, sensor_type: str, sensor: dict[str, any] + self, router: FreeboxRouter, sensor_type: str, sensor: dict[str, Any] ) -> None: """Initialize a Freebox call sensor.""" super().__init__(router, sensor_type, sensor) @@ -180,7 +181,7 @@ class FreeboxCallSensor(FreeboxSensor): self._state = len(self._call_list_for_type) @property - def extra_state_attributes(self) -> dict[str, any]: + def extra_state_attributes(self) -> dict[str, Any]: """Return device specific state attributes.""" return { dt_util.utc_from_timestamp(call["datetime"]).isoformat(): call["name"] @@ -194,10 +195,10 @@ class FreeboxDiskSensor(FreeboxSensor): def __init__( self, router: FreeboxRouter, - disk: dict[str, any], - partition: dict[str, any], + disk: dict[str, Any], + partition: dict[str, Any], sensor_type: str, - sensor: dict[str, any], + sensor: dict[str, Any], ) -> None: """Initialize a Freebox disk sensor.""" super().__init__(router, sensor_type, sensor) @@ -207,7 +208,7 @@ class FreeboxDiskSensor(FreeboxSensor): self._unique_id = f"{self._router.mac} {sensor_type} {self._disk['id']} {self._partition['id']}" @property - def device_info(self) -> dict[str, any]: + def device_info(self) -> dict[str, Any]: """Return the device information.""" return { "identifiers": {(DOMAIN, self._disk["id"])}, diff --git a/homeassistant/components/freebox/switch.py b/homeassistant/components/freebox/switch.py index f309524ceb4..ebe573be9ed 100644 --- a/homeassistant/components/freebox/switch.py +++ b/homeassistant/components/freebox/switch.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any from freebox_api.exceptions import InsufficientPermissionsError @@ -49,7 +50,7 @@ class FreeboxWifiSwitch(SwitchEntity): return self._state @property - def device_info(self) -> dict[str, any]: + def device_info(self) -> dict[str, Any]: """Return the device information.""" return self._router.device_info diff --git a/homeassistant/components/icloud/account.py b/homeassistant/components/icloud/account.py index 55fd661768d..5a33b5d9508 100644 --- a/homeassistant/components/icloud/account.py +++ b/homeassistant/components/icloud/account.py @@ -4,6 +4,7 @@ from __future__ import annotations from datetime import timedelta import logging import operator +from typing import Any from pyicloud import PyiCloudService from pyicloud.exceptions import ( @@ -355,7 +356,7 @@ class IcloudAccount: return self._fetch_interval @property - def devices(self) -> dict[str, any]: + def devices(self) -> dict[str, Any]: """Return the account devices.""" return self._devices @@ -496,11 +497,11 @@ class IcloudDevice: return self._battery_status @property - def location(self) -> dict[str, any]: + def location(self) -> dict[str, Any]: """Return the Apple device location.""" return self._location @property - def extra_state_attributes(self) -> dict[str, any]: + def extra_state_attributes(self) -> dict[str, Any]: """Return the attributes.""" return self._attrs diff --git a/homeassistant/components/icloud/device_tracker.py b/homeassistant/components/icloud/device_tracker.py index 131f9335b43..0615d6fcc7f 100644 --- a/homeassistant/components/icloud/device_tracker.py +++ b/homeassistant/components/icloud/device_tracker.py @@ -1,6 +1,8 @@ """Support for tracking for iCloud devices.""" from __future__ import annotations +from typing import Any + from homeassistant.components.device_tracker import SOURCE_TYPE_GPS from homeassistant.components.device_tracker.config_entry import TrackerEntity from homeassistant.config_entries import ConfigEntry @@ -105,12 +107,12 @@ class IcloudTrackerEntity(TrackerEntity): return icon_for_icloud_device(self._device) @property - def extra_state_attributes(self) -> dict[str, any]: + def extra_state_attributes(self) -> dict[str, Any]: """Return the device state attributes.""" return self._device.extra_state_attributes @property - def device_info(self) -> dict[str, any]: + def device_info(self) -> dict[str, Any]: """Return the device information.""" return { "identifiers": {(DOMAIN, self._device.unique_id)}, diff --git a/homeassistant/components/icloud/sensor.py b/homeassistant/components/icloud/sensor.py index 3a875db81ed..7c13171688e 100644 --- a/homeassistant/components/icloud/sensor.py +++ b/homeassistant/components/icloud/sensor.py @@ -1,6 +1,8 @@ """Support for iCloud sensors.""" from __future__ import annotations +from typing import Any + from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import DEVICE_CLASS_BATTERY, PERCENTAGE @@ -90,12 +92,12 @@ class IcloudDeviceBatterySensor(SensorEntity): ) @property - def extra_state_attributes(self) -> dict[str, any]: + def extra_state_attributes(self) -> dict[str, Any]: """Return default attributes for the iCloud device entity.""" return self._device.extra_state_attributes @property - def device_info(self) -> dict[str, any]: + def device_info(self) -> dict[str, Any]: """Return the device information.""" return { "identifiers": {(DOMAIN, self._device.unique_id)}, diff --git a/homeassistant/components/plugwise/gateway.py b/homeassistant/components/plugwise/gateway.py index 70a4a822431..3f805f1475d 100644 --- a/homeassistant/components/plugwise/gateway.py +++ b/homeassistant/components/plugwise/gateway.py @@ -4,6 +4,7 @@ from __future__ import annotations import asyncio from datetime import timedelta import logging +from typing import Any import async_timeout from plugwise.exceptions import ( @@ -197,7 +198,7 @@ class SmileGateway(CoordinatorEntity): return self._name @property - def device_info(self) -> dict[str, any]: + def device_info(self) -> dict[str, Any]: """Return the device information.""" device_information = { "identifiers": {(DOMAIN, self._dev_id)}, diff --git a/homeassistant/components/synology_dsm/__init__.py b/homeassistant/components/synology_dsm/__init__.py index 74cf8775b1c..cdfad25e972 100644 --- a/homeassistant/components/synology_dsm/__init__.py +++ b/homeassistant/components/synology_dsm/__init__.py @@ -4,6 +4,7 @@ from __future__ import annotations import asyncio from datetime import timedelta import logging +from typing import Any import async_timeout from synology_dsm import SynologyDSM @@ -626,12 +627,12 @@ class SynologyDSMBaseEntity(CoordinatorEntity): return self._class @property - def extra_state_attributes(self) -> dict[str, any]: + def extra_state_attributes(self) -> dict[str, Any]: """Return the state attributes.""" return {ATTR_ATTRIBUTION: ATTRIBUTION} @property - def device_info(self) -> dict[str, any]: + def device_info(self) -> dict[str, Any]: """Return the device information.""" return { "identifiers": {(DOMAIN, self._api.information.serial)}, @@ -701,7 +702,7 @@ class SynologyDSMDeviceEntity(SynologyDSMBaseEntity): return bool(self._api.storage) @property - def device_info(self) -> dict[str, any]: + def device_info(self) -> dict[str, Any]: """Return the device information.""" return { "identifiers": {(DOMAIN, self._api.information.serial, self._device_id)}, diff --git a/homeassistant/components/synology_dsm/camera.py b/homeassistant/components/synology_dsm/camera.py index cdd4b88186a..80cf70de8a9 100644 --- a/homeassistant/components/synology_dsm/camera.py +++ b/homeassistant/components/synology_dsm/camera.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any from synology_dsm.api.surveillance_station import SynoSurveillanceStation from synology_dsm.exceptions import ( @@ -80,7 +81,7 @@ class SynoDSMCamera(SynologyDSMBaseEntity, Camera): return self.coordinator.data["cameras"][self._camera_id] @property - def device_info(self) -> dict[str, any]: + def device_info(self) -> dict[str, Any]: """Return the device information.""" return { "identifiers": { diff --git a/homeassistant/components/synology_dsm/switch.py b/homeassistant/components/synology_dsm/switch.py index 3b71e481d6e..51736663d50 100644 --- a/homeassistant/components/synology_dsm/switch.py +++ b/homeassistant/components/synology_dsm/switch.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any from synology_dsm.api.surveillance_station import SynoSurveillanceStation @@ -96,7 +97,7 @@ class SynoDSMSurveillanceHomeModeToggle(SynologyDSMBaseEntity, ToggleEntity): return bool(self._api.surveillance_station) @property - def device_info(self) -> dict[str, any]: + def device_info(self) -> dict[str, Any]: """Return the device information.""" return { "identifiers": { diff --git a/homeassistant/components/upnp/device.py b/homeassistant/components/upnp/device.py index e5b6099e9f3..496293926d3 100644 --- a/homeassistant/components/upnp/device.py +++ b/homeassistant/components/upnp/device.py @@ -4,6 +4,7 @@ from __future__ import annotations import asyncio from collections.abc import Mapping from ipaddress import IPv4Address +from typing import Any from urllib.parse import urlparse from async_upnp_client import UpnpFactory @@ -162,7 +163,7 @@ class Device: """Get string representation.""" return f"IGD Device: {self.name}/{self.udn}::{self.device_type}" - async def async_get_traffic_data(self) -> Mapping[str, any]: + async def async_get_traffic_data(self) -> Mapping[str, Any]: """ Get all traffic data in one go. diff --git a/tests/components/mysensors/test_config_flow.py b/tests/components/mysensors/test_config_flow.py index dfad2b50558..66900066cd1 100644 --- a/tests/components/mysensors/test_config_flow.py +++ b/tests/components/mysensors/test_config_flow.py @@ -1,6 +1,7 @@ """Test the MySensors config flow.""" from __future__ import annotations +from typing import Any from unittest.mock import patch import pytest @@ -369,7 +370,7 @@ async def test_config_invalid( mqtt: config_entries.ConfigEntry, gateway_type: ConfGatewayType, expected_step_id: str, - user_input: dict[str, any], + user_input: dict[str, Any], err_field, err_string, ) -> None: diff --git a/tests/components/mysensors/test_init.py b/tests/components/mysensors/test_init.py index 30fbf3ea686..4fb51d6c17a 100644 --- a/tests/components/mysensors/test_init.py +++ b/tests/components/mysensors/test_init.py @@ -1,6 +1,7 @@ """Test function in __init__.py.""" from __future__ import annotations +from typing import Any from unittest.mock import patch import pytest @@ -232,7 +233,7 @@ async def test_import( config: ConfigType, expected_calls: int, expected_to_succeed: bool, - expected_config_flow_user_input: dict[str, any], + expected_config_flow_user_input: dict[str, Any], ) -> None: """Test importing a gateway.""" await async_setup_component(hass, "persistent_notification", {}) diff --git a/tests/components/upnp/mock_device.py b/tests/components/upnp/mock_device.py index d2ef9ad41e3..7161ae69598 100644 --- a/tests/components/upnp/mock_device.py +++ b/tests/components/upnp/mock_device.py @@ -1,6 +1,6 @@ """Mock device for testing purposes.""" -from typing import Mapping +from typing import Any, Mapping from unittest.mock import AsyncMock from homeassistant.components.upnp.const import ( @@ -60,7 +60,7 @@ class MockDevice(Device): """Get the hostname.""" return "mock-hostname" - async def async_get_traffic_data(self) -> Mapping[str, any]: + async def async_get_traffic_data(self) -> Mapping[str, Any]: """Get traffic data.""" self.times_polled += 1 return {