Fix typing.Any spelling (#49673)
This commit is contained in:
parent
85438db1ec
commit
631ab367e2
17 changed files with 55 additions and 36 deletions
|
@ -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)},
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)},
|
||||
|
|
|
@ -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)},
|
||||
|
|
|
@ -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"])},
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)},
|
||||
|
|
|
@ -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)},
|
||||
|
|
|
@ -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)},
|
||||
|
|
|
@ -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)},
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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", {})
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue