Fix typing.Any spelling (#49673)

This commit is contained in:
Ville Skyttä 2021-04-25 22:36:21 +03:00 committed by GitHub
parent 85438db1ec
commit 631ab367e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 55 additions and 36 deletions

View file

@ -1,6 +1,8 @@
"""Support for ASUSWRT routers.""" """Support for ASUSWRT routers."""
from __future__ import annotations from __future__ import annotations
from typing import Any
from homeassistant.components.device_tracker import SOURCE_TYPE_ROUTER from homeassistant.components.device_tracker import SOURCE_TYPE_ROUTER
from homeassistant.components.device_tracker.config_entry import ScannerEntity from homeassistant.components.device_tracker.config_entry import ScannerEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
@ -78,7 +80,7 @@ class AsusWrtDevice(ScannerEntity):
return SOURCE_TYPE_ROUTER return SOURCE_TYPE_ROUTER
@property @property
def extra_state_attributes(self) -> dict[str, any]: def extra_state_attributes(self) -> dict[str, Any]:
"""Return the attributes.""" """Return the attributes."""
attrs = {} attrs = {}
if self._device.last_activity: if self._device.last_activity:
@ -103,7 +105,7 @@ class AsusWrtDevice(ScannerEntity):
return self._device.mac return self._device.mac
@property @property
def device_info(self) -> dict[str, any]: def device_info(self) -> dict[str, Any]:
"""Return the device information.""" """Return the device information."""
data = { data = {
"connections": {(CONNECTION_NETWORK_MAC, self._device.mac)}, "connections": {(CONNECTION_NETWORK_MAC, self._device.mac)},

View file

@ -3,6 +3,7 @@ from __future__ import annotations
import logging import logging
from numbers import Number from numbers import Number
from typing import Any
from homeassistant.components.sensor import SensorEntity from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
@ -106,7 +107,7 @@ class AsusWrtSensor(CoordinatorEntity, SensorEntity):
coordinator: DataUpdateCoordinator, coordinator: DataUpdateCoordinator,
router: AsusWrtRouter, router: AsusWrtRouter,
sensor_type: str, sensor_type: str,
sensor: dict[str, any], sensor: dict[str, Any],
) -> None: ) -> None:
"""Initialize a AsusWrt sensor.""" """Initialize a AsusWrt sensor."""
super().__init__(coordinator) super().__init__(coordinator)
@ -161,11 +162,11 @@ class AsusWrtSensor(CoordinatorEntity, SensorEntity):
return self._device_class return self._device_class
@property @property
def extra_state_attributes(self) -> dict[str, any]: def extra_state_attributes(self) -> dict[str, Any]:
"""Return the attributes.""" """Return the attributes."""
return {"hostname": self._router.host} return {"hostname": self._router.host}
@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 self._router.device_info return self._router.device_info

View file

@ -7,6 +7,7 @@ from contextlib import suppress
from datetime import timedelta from datetime import timedelta
from functools import partial from functools import partial
import logging import logging
from typing import Any
from dsmr_parser import obis_references as obis_ref from dsmr_parser import obis_references as obis_ref
from dsmr_parser.clients.protocol import create_dsmr_reader, create_tcp_dsmr_reader from dsmr_parser.clients.protocol import create_dsmr_reader, create_tcp_dsmr_reader
@ -361,7 +362,7 @@ class DSMREntity(SensorEntity):
return self._unique_id return self._unique_id
@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 {
"identifiers": {(DOMAIN, self._device_serial)}, "identifiers": {(DOMAIN, self._device_serial)},

View file

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
from datetime import datetime from datetime import datetime
from typing import Any
from homeassistant.components.device_tracker import SOURCE_TYPE_ROUTER from homeassistant.components.device_tracker import SOURCE_TYPE_ROUTER
from homeassistant.components.device_tracker.config_entry import ScannerEntity from homeassistant.components.device_tracker.config_entry import ScannerEntity
@ -52,7 +53,7 @@ def add_entities(router, async_add_entities, tracked):
class FreeboxDevice(ScannerEntity): class FreeboxDevice(ScannerEntity):
"""Representation of a Freebox device.""" """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.""" """Initialize a Freebox device."""
self._router = router self._router = router
self._name = device["primary_name"].strip() or DEFAULT_DEVICE_NAME self._name = device["primary_name"].strip() or DEFAULT_DEVICE_NAME
@ -105,12 +106,12 @@ class FreeboxDevice(ScannerEntity):
return self._icon return self._icon
@property @property
def extra_state_attributes(self) -> dict[str, any]: def extra_state_attributes(self) -> dict[str, Any]:
"""Return the attributes.""" """Return the attributes."""
return self._attrs return self._attrs
@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)},

View file

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any
from homeassistant.components.sensor import SensorEntity from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
@ -77,7 +78,7 @@ class FreeboxSensor(SensorEntity):
"""Representation of a Freebox sensor.""" """Representation of a Freebox sensor."""
def __init__( def __init__(
self, router: FreeboxRouter, sensor_type: str, sensor: dict[str, any] self, router: FreeboxRouter, sensor_type: str, sensor: dict[str, Any]
) -> None: ) -> None:
"""Initialize a Freebox sensor.""" """Initialize a Freebox sensor."""
self._state = None self._state = None
@ -129,7 +130,7 @@ class FreeboxSensor(SensorEntity):
return self._device_class return self._device_class
@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 self._router.device_info return self._router.device_info
@ -160,7 +161,7 @@ class FreeboxCallSensor(FreeboxSensor):
"""Representation of a Freebox call sensor.""" """Representation of a Freebox call sensor."""
def __init__( def __init__(
self, router: FreeboxRouter, sensor_type: str, sensor: dict[str, any] self, router: FreeboxRouter, sensor_type: str, sensor: dict[str, Any]
) -> None: ) -> None:
"""Initialize a Freebox call sensor.""" """Initialize a Freebox call sensor."""
super().__init__(router, sensor_type, sensor) super().__init__(router, sensor_type, sensor)
@ -180,7 +181,7 @@ class FreeboxCallSensor(FreeboxSensor):
self._state = len(self._call_list_for_type) self._state = len(self._call_list_for_type)
@property @property
def extra_state_attributes(self) -> dict[str, any]: def extra_state_attributes(self) -> dict[str, Any]:
"""Return device specific state attributes.""" """Return device specific state attributes."""
return { return {
dt_util.utc_from_timestamp(call["datetime"]).isoformat(): call["name"] dt_util.utc_from_timestamp(call["datetime"]).isoformat(): call["name"]
@ -194,10 +195,10 @@ class FreeboxDiskSensor(FreeboxSensor):
def __init__( def __init__(
self, self,
router: FreeboxRouter, router: FreeboxRouter,
disk: dict[str, any], disk: dict[str, Any],
partition: dict[str, any], partition: dict[str, Any],
sensor_type: str, sensor_type: str,
sensor: dict[str, any], sensor: dict[str, Any],
) -> None: ) -> None:
"""Initialize a Freebox disk sensor.""" """Initialize a Freebox disk sensor."""
super().__init__(router, sensor_type, 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']}" self._unique_id = f"{self._router.mac} {sensor_type} {self._disk['id']} {self._partition['id']}"
@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 {
"identifiers": {(DOMAIN, self._disk["id"])}, "identifiers": {(DOMAIN, self._disk["id"])},

View file

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any
from freebox_api.exceptions import InsufficientPermissionsError from freebox_api.exceptions import InsufficientPermissionsError
@ -49,7 +50,7 @@ class FreeboxWifiSwitch(SwitchEntity):
return self._state return self._state
@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 self._router.device_info return self._router.device_info

View file

@ -4,6 +4,7 @@ from __future__ import annotations
from datetime import timedelta from datetime import timedelta
import logging import logging
import operator import operator
from typing import Any
from pyicloud import PyiCloudService from pyicloud import PyiCloudService
from pyicloud.exceptions import ( from pyicloud.exceptions import (
@ -355,7 +356,7 @@ class IcloudAccount:
return self._fetch_interval return self._fetch_interval
@property @property
def devices(self) -> dict[str, any]: def devices(self) -> dict[str, Any]:
"""Return the account devices.""" """Return the account devices."""
return self._devices return self._devices
@ -496,11 +497,11 @@ class IcloudDevice:
return self._battery_status return self._battery_status
@property @property
def location(self) -> dict[str, any]: def location(self) -> dict[str, Any]:
"""Return the Apple device location.""" """Return the Apple device location."""
return self._location return self._location
@property @property
def extra_state_attributes(self) -> dict[str, any]: def extra_state_attributes(self) -> dict[str, Any]:
"""Return the attributes.""" """Return the attributes."""
return self._attrs return self._attrs

View file

@ -1,6 +1,8 @@
"""Support for tracking for iCloud devices.""" """Support for tracking for iCloud devices."""
from __future__ import annotations from __future__ import annotations
from typing import Any
from homeassistant.components.device_tracker import SOURCE_TYPE_GPS from homeassistant.components.device_tracker import SOURCE_TYPE_GPS
from homeassistant.components.device_tracker.config_entry import TrackerEntity from homeassistant.components.device_tracker.config_entry import TrackerEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
@ -105,12 +107,12 @@ class IcloudTrackerEntity(TrackerEntity):
return icon_for_icloud_device(self._device) return icon_for_icloud_device(self._device)
@property @property
def extra_state_attributes(self) -> dict[str, any]: def extra_state_attributes(self) -> dict[str, Any]:
"""Return the device state attributes.""" """Return the device state attributes."""
return self._device.extra_state_attributes return self._device.extra_state_attributes
@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 {
"identifiers": {(DOMAIN, self._device.unique_id)}, "identifiers": {(DOMAIN, self._device.unique_id)},

View file

@ -1,6 +1,8 @@
"""Support for iCloud sensors.""" """Support for iCloud sensors."""
from __future__ import annotations from __future__ import annotations
from typing import Any
from homeassistant.components.sensor import SensorEntity from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import DEVICE_CLASS_BATTERY, PERCENTAGE from homeassistant.const import DEVICE_CLASS_BATTERY, PERCENTAGE
@ -90,12 +92,12 @@ class IcloudDeviceBatterySensor(SensorEntity):
) )
@property @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 default attributes for the iCloud device entity."""
return self._device.extra_state_attributes return self._device.extra_state_attributes
@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 {
"identifiers": {(DOMAIN, self._device.unique_id)}, "identifiers": {(DOMAIN, self._device.unique_id)},

View file

@ -4,6 +4,7 @@ from __future__ import annotations
import asyncio import asyncio
from datetime import timedelta from datetime import timedelta
import logging import logging
from typing import Any
import async_timeout import async_timeout
from plugwise.exceptions import ( from plugwise.exceptions import (
@ -197,7 +198,7 @@ class SmileGateway(CoordinatorEntity):
return self._name return self._name
@property @property
def device_info(self) -> dict[str, any]: def device_info(self) -> dict[str, Any]:
"""Return the device information.""" """Return the device information."""
device_information = { device_information = {
"identifiers": {(DOMAIN, self._dev_id)}, "identifiers": {(DOMAIN, self._dev_id)},

View file

@ -4,6 +4,7 @@ from __future__ import annotations
import asyncio import asyncio
from datetime import timedelta from datetime import timedelta
import logging import logging
from typing import Any
import async_timeout import async_timeout
from synology_dsm import SynologyDSM from synology_dsm import SynologyDSM
@ -626,12 +627,12 @@ class SynologyDSMBaseEntity(CoordinatorEntity):
return self._class return self._class
@property @property
def extra_state_attributes(self) -> dict[str, any]: def extra_state_attributes(self) -> dict[str, Any]:
"""Return the state attributes.""" """Return the state attributes."""
return {ATTR_ATTRIBUTION: ATTRIBUTION} return {ATTR_ATTRIBUTION: ATTRIBUTION}
@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 {
"identifiers": {(DOMAIN, self._api.information.serial)}, "identifiers": {(DOMAIN, self._api.information.serial)},
@ -701,7 +702,7 @@ class SynologyDSMDeviceEntity(SynologyDSMBaseEntity):
return bool(self._api.storage) return bool(self._api.storage)
@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 {
"identifiers": {(DOMAIN, self._api.information.serial, self._device_id)}, "identifiers": {(DOMAIN, self._api.information.serial, self._device_id)},

View file

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any
from synology_dsm.api.surveillance_station import SynoSurveillanceStation from synology_dsm.api.surveillance_station import SynoSurveillanceStation
from synology_dsm.exceptions import ( from synology_dsm.exceptions import (
@ -80,7 +81,7 @@ class SynoDSMCamera(SynologyDSMBaseEntity, Camera):
return self.coordinator.data["cameras"][self._camera_id] return self.coordinator.data["cameras"][self._camera_id]
@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 {
"identifiers": { "identifiers": {

View file

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any
from synology_dsm.api.surveillance_station import SynoSurveillanceStation from synology_dsm.api.surveillance_station import SynoSurveillanceStation
@ -96,7 +97,7 @@ class SynoDSMSurveillanceHomeModeToggle(SynologyDSMBaseEntity, ToggleEntity):
return bool(self._api.surveillance_station) return bool(self._api.surveillance_station)
@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 {
"identifiers": { "identifiers": {

View file

@ -4,6 +4,7 @@ from __future__ import annotations
import asyncio import asyncio
from collections.abc import Mapping from collections.abc import Mapping
from ipaddress import IPv4Address from ipaddress import IPv4Address
from typing import Any
from urllib.parse import urlparse from urllib.parse import urlparse
from async_upnp_client import UpnpFactory from async_upnp_client import UpnpFactory
@ -162,7 +163,7 @@ class Device:
"""Get string representation.""" """Get string representation."""
return f"IGD Device: {self.name}/{self.udn}::{self.device_type}" 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. Get all traffic data in one go.

View file

@ -1,6 +1,7 @@
"""Test the MySensors config flow.""" """Test the MySensors config flow."""
from __future__ import annotations from __future__ import annotations
from typing import Any
from unittest.mock import patch from unittest.mock import patch
import pytest import pytest
@ -369,7 +370,7 @@ async def test_config_invalid(
mqtt: config_entries.ConfigEntry, mqtt: config_entries.ConfigEntry,
gateway_type: ConfGatewayType, gateway_type: ConfGatewayType,
expected_step_id: str, expected_step_id: str,
user_input: dict[str, any], user_input: dict[str, Any],
err_field, err_field,
err_string, err_string,
) -> None: ) -> None:

View file

@ -1,6 +1,7 @@
"""Test function in __init__.py.""" """Test function in __init__.py."""
from __future__ import annotations from __future__ import annotations
from typing import Any
from unittest.mock import patch from unittest.mock import patch
import pytest import pytest
@ -232,7 +233,7 @@ async def test_import(
config: ConfigType, config: ConfigType,
expected_calls: int, expected_calls: int,
expected_to_succeed: bool, expected_to_succeed: bool,
expected_config_flow_user_input: dict[str, any], expected_config_flow_user_input: dict[str, Any],
) -> None: ) -> None:
"""Test importing a gateway.""" """Test importing a gateway."""
await async_setup_component(hass, "persistent_notification", {}) await async_setup_component(hass, "persistent_notification", {})

View file

@ -1,6 +1,6 @@
"""Mock device for testing purposes.""" """Mock device for testing purposes."""
from typing import Mapping from typing import Any, Mapping
from unittest.mock import AsyncMock from unittest.mock import AsyncMock
from homeassistant.components.upnp.const import ( from homeassistant.components.upnp.const import (
@ -60,7 +60,7 @@ class MockDevice(Device):
"""Get the hostname.""" """Get the hostname."""
return "mock-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.""" """Get traffic data."""
self.times_polled += 1 self.times_polled += 1
return { return {