Update typing 10 (#48071)

This commit is contained in:
Marc Mueller 2021-03-18 13:07:04 +01:00 committed by GitHub
parent 00dca88024
commit 25a13d1554
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
73 changed files with 412 additions and 333 deletions

View file

@ -1,6 +1,8 @@
"""MySensors constants."""
from __future__ import annotations
from collections import defaultdict
from typing import Dict, List, Literal, Set, Tuple
from typing import Literal, Tuple
ATTR_DEVICES: str = "devices"
ATTR_GATEWAY_ID: str = "gateway_id"
@ -21,7 +23,7 @@ ConfGatewayType = Literal["Serial", "TCP", "MQTT"]
CONF_GATEWAY_TYPE_SERIAL: ConfGatewayType = "Serial"
CONF_GATEWAY_TYPE_TCP: ConfGatewayType = "TCP"
CONF_GATEWAY_TYPE_MQTT: ConfGatewayType = "MQTT"
CONF_GATEWAY_TYPE_ALL: List[str] = [
CONF_GATEWAY_TYPE_ALL: list[str] = [
CONF_GATEWAY_TYPE_MQTT,
CONF_GATEWAY_TYPE_SERIAL,
CONF_GATEWAY_TYPE_TCP,
@ -62,7 +64,7 @@ DevId = Tuple[GatewayId, int, int, int]
# The MySensors integration brings these together by creating an entity for every v_type of every child_id of every node.
# The DevId tuple perfectly captures this.
BINARY_SENSOR_TYPES: Dict[SensorType, Set[ValueType]] = {
BINARY_SENSOR_TYPES: dict[SensorType, set[ValueType]] = {
"S_DOOR": {"V_TRIPPED"},
"S_MOTION": {"V_TRIPPED"},
"S_SMOKE": {"V_TRIPPED"},
@ -73,23 +75,23 @@ BINARY_SENSOR_TYPES: Dict[SensorType, Set[ValueType]] = {
"S_MOISTURE": {"V_TRIPPED"},
}
CLIMATE_TYPES: Dict[SensorType, Set[ValueType]] = {"S_HVAC": {"V_HVAC_FLOW_STATE"}}
CLIMATE_TYPES: dict[SensorType, set[ValueType]] = {"S_HVAC": {"V_HVAC_FLOW_STATE"}}
COVER_TYPES: Dict[SensorType, Set[ValueType]] = {
COVER_TYPES: dict[SensorType, set[ValueType]] = {
"S_COVER": {"V_DIMMER", "V_PERCENTAGE", "V_LIGHT", "V_STATUS"}
}
DEVICE_TRACKER_TYPES: Dict[SensorType, Set[ValueType]] = {"S_GPS": {"V_POSITION"}}
DEVICE_TRACKER_TYPES: dict[SensorType, set[ValueType]] = {"S_GPS": {"V_POSITION"}}
LIGHT_TYPES: Dict[SensorType, Set[ValueType]] = {
LIGHT_TYPES: dict[SensorType, set[ValueType]] = {
"S_DIMMER": {"V_DIMMER", "V_PERCENTAGE"},
"S_RGB_LIGHT": {"V_RGB"},
"S_RGBW_LIGHT": {"V_RGBW"},
}
NOTIFY_TYPES: Dict[SensorType, Set[ValueType]] = {"S_INFO": {"V_TEXT"}}
NOTIFY_TYPES: dict[SensorType, set[ValueType]] = {"S_INFO": {"V_TEXT"}}
SENSOR_TYPES: Dict[SensorType, Set[ValueType]] = {
SENSOR_TYPES: dict[SensorType, set[ValueType]] = {
"S_SOUND": {"V_LEVEL"},
"S_VIBRATION": {"V_LEVEL"},
"S_MOISTURE": {"V_LEVEL"},
@ -117,7 +119,7 @@ SENSOR_TYPES: Dict[SensorType, Set[ValueType]] = {
"S_DUST": {"V_DUST_LEVEL", "V_LEVEL"},
}
SWITCH_TYPES: Dict[SensorType, Set[ValueType]] = {
SWITCH_TYPES: dict[SensorType, set[ValueType]] = {
"S_LIGHT": {"V_LIGHT"},
"S_BINARY": {"V_STATUS"},
"S_DOOR": {"V_ARMED"},
@ -134,7 +136,7 @@ SWITCH_TYPES: Dict[SensorType, Set[ValueType]] = {
}
PLATFORM_TYPES: Dict[str, Dict[SensorType, Set[ValueType]]] = {
PLATFORM_TYPES: dict[str, dict[SensorType, set[ValueType]]] = {
"binary_sensor": BINARY_SENSOR_TYPES,
"climate": CLIMATE_TYPES,
"cover": COVER_TYPES,
@ -145,13 +147,13 @@ PLATFORM_TYPES: Dict[str, Dict[SensorType, Set[ValueType]]] = {
"switch": SWITCH_TYPES,
}
FLAT_PLATFORM_TYPES: Dict[Tuple[str, SensorType], Set[ValueType]] = {
FLAT_PLATFORM_TYPES: dict[tuple[str, SensorType], set[ValueType]] = {
(platform, s_type_name): v_type_name
for platform, platform_types in PLATFORM_TYPES.items()
for s_type_name, v_type_name in platform_types.items()
}
TYPE_TO_PLATFORMS: Dict[SensorType, List[str]] = defaultdict(list)
TYPE_TO_PLATFORMS: dict[SensorType, list[str]] = defaultdict(list)
for platform, platform_types in PLATFORM_TYPES.items():
for s_type_name in platform_types: