Use list literal without using dict.keys() (#42573)
This commit is contained in:
parent
2dc5c4dd69
commit
92379ad8d2
18 changed files with 27 additions and 27 deletions
|
@ -207,7 +207,7 @@ class LoginFlow(data_entry_flow.FlowHandler):
|
||||||
errors["base"] = "invalid_auth_module"
|
errors["base"] = "invalid_auth_module"
|
||||||
|
|
||||||
if len(self.available_mfa_modules) == 1:
|
if len(self.available_mfa_modules) == 1:
|
||||||
self._auth_module_id = list(self.available_mfa_modules.keys())[0]
|
self._auth_module_id = list(self.available_mfa_modules)[0]
|
||||||
return await self.async_step_mfa()
|
return await self.async_step_mfa()
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
|
|
|
@ -35,7 +35,7 @@ class AsusWrtDeviceScanner(DeviceScanner):
|
||||||
async def async_scan_devices(self):
|
async def async_scan_devices(self):
|
||||||
"""Scan for new devices and return a list with found device IDs."""
|
"""Scan for new devices and return a list with found device IDs."""
|
||||||
await self.async_update_info()
|
await self.async_update_info()
|
||||||
return list(self.last_results.keys())
|
return list(self.last_results)
|
||||||
|
|
||||||
async def async_get_device_name(self, device):
|
async def async_get_device_name(self, device):
|
||||||
"""Return the name of the given device or None if we don't know."""
|
"""Return the name of the given device or None if we don't know."""
|
||||||
|
|
|
@ -66,7 +66,7 @@ class BlinkSyncModule(AlarmControlPanelEntity):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
attr = self.sync.attributes
|
attr = self.sync.attributes
|
||||||
attr["network_info"] = self.data.networks
|
attr["network_info"] = self.data.networks
|
||||||
attr["associated_cameras"] = list(self.sync.cameras.keys())
|
attr["associated_cameras"] = list(self.sync.cameras)
|
||||||
attr[ATTR_ATTRIBUTION] = DEFAULT_ATTRIBUTION
|
attr[ATTR_ATTRIBUTION] = DEFAULT_ATTRIBUTION
|
||||||
return attr
|
return attr
|
||||||
|
|
||||||
|
|
|
@ -230,7 +230,7 @@ class DenonDevice(MediaPlayerEntity):
|
||||||
@property
|
@property
|
||||||
def source_list(self):
|
def source_list(self):
|
||||||
"""Return the list of available input sources."""
|
"""Return the list of available input sources."""
|
||||||
return sorted(list(self._source_list.keys()))
|
return sorted(list(self._source_list))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_title(self):
|
def media_title(self):
|
||||||
|
|
|
@ -61,7 +61,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
lon = config.get(CONF_LONGITUDE, hass.config.longitude)
|
lon = config.get(CONF_LONGITUDE, hass.config.longitude)
|
||||||
ec_data = ECData(coordinates=(lat, lon), language=config.get(CONF_LANGUAGE))
|
ec_data = ECData(coordinates=(lat, lon), language=config.get(CONF_LANGUAGE))
|
||||||
|
|
||||||
sensor_list = list(ec_data.conditions.keys()) + list(ec_data.alerts.keys())
|
sensor_list = list(ec_data.conditions) + list(ec_data.alerts)
|
||||||
add_entities([ECSensor(sensor_type, ec_data) for sensor_type in sensor_list], True)
|
add_entities([ECSensor(sensor_type, ec_data) for sensor_type in sensor_list], True)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ class EQ3BTSmartThermostat(ClimateEntity):
|
||||||
@property
|
@property
|
||||||
def hvac_modes(self):
|
def hvac_modes(self):
|
||||||
"""Return the list of available operation modes."""
|
"""Return the list of available operation modes."""
|
||||||
return list(HA_TO_EQ_HVAC.keys())
|
return list(HA_TO_EQ_HVAC)
|
||||||
|
|
||||||
def set_hvac_mode(self, hvac_mode):
|
def set_hvac_mode(self, hvac_mode):
|
||||||
"""Set operation mode."""
|
"""Set operation mode."""
|
||||||
|
@ -181,7 +181,7 @@ class EQ3BTSmartThermostat(ClimateEntity):
|
||||||
|
|
||||||
Requires SUPPORT_PRESET_MODE.
|
Requires SUPPORT_PRESET_MODE.
|
||||||
"""
|
"""
|
||||||
return list(HA_TO_EQ_PRESET.keys())
|
return list(HA_TO_EQ_PRESET)
|
||||||
|
|
||||||
def set_preset_mode(self, preset_mode):
|
def set_preset_mode(self, preset_mode):
|
||||||
"""Set new preset mode."""
|
"""Set new preset mode."""
|
||||||
|
|
|
@ -357,7 +357,7 @@ class HomeKitSpeedMapping:
|
||||||
for state, speed_range in reversed(self.speed_ranges.items()):
|
for state, speed_range in reversed(self.speed_ranges.items()):
|
||||||
if speed_range.start <= speed:
|
if speed_range.start <= speed:
|
||||||
return state
|
return state
|
||||||
return list(self.speed_ranges.keys())[0]
|
return list(self.speed_ranges)[0]
|
||||||
|
|
||||||
|
|
||||||
def show_setup_message(hass, entry_id, bridge_name, pincode, uri):
|
def show_setup_message(hass, entry_id, bridge_name, pincode, uri):
|
||||||
|
|
|
@ -202,12 +202,12 @@ class InsteonClimateEntity(InsteonEntity, ClimateEntity):
|
||||||
|
|
||||||
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
||||||
"""Set new target fan mode."""
|
"""Set new target fan mode."""
|
||||||
mode = list(FAN_MODES.keys())[list(FAN_MODES.values()).index(fan_mode)]
|
mode = list(FAN_MODES)[list(FAN_MODES.values()).index(fan_mode)]
|
||||||
await self._insteon_device.async_set_mode(mode)
|
await self._insteon_device.async_set_mode(mode)
|
||||||
|
|
||||||
async def async_set_hvac_mode(self, hvac_mode: str) -> None:
|
async def async_set_hvac_mode(self, hvac_mode: str) -> None:
|
||||||
"""Set new target hvac mode."""
|
"""Set new target hvac mode."""
|
||||||
mode = list(HVAC_MODES.keys())[list(HVAC_MODES.values()).index(hvac_mode)]
|
mode = list(HVAC_MODES)[list(HVAC_MODES.values()).index(hvac_mode)]
|
||||||
await self._insteon_device.async_set_mode(mode)
|
await self._insteon_device.async_set_mode(mode)
|
||||||
|
|
||||||
async def async_set_humidity(self, humidity):
|
async def async_set_humidity(self, humidity):
|
||||||
|
|
|
@ -509,7 +509,7 @@ class ZoneDevice(ClimateEntity):
|
||||||
@property
|
@property
|
||||||
def hvac_modes(self):
|
def hvac_modes(self):
|
||||||
"""Return the list of available operation modes."""
|
"""Return the list of available operation modes."""
|
||||||
return list(self._state_to_pizone.keys())
|
return list(self._state_to_pizone)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_temperature(self):
|
def current_temperature(self):
|
||||||
|
|
|
@ -102,14 +102,14 @@ async def async_start(
|
||||||
|
|
||||||
payload = MQTTConfig(payload)
|
payload = MQTTConfig(payload)
|
||||||
|
|
||||||
for key in list(payload.keys()):
|
for key in list(payload):
|
||||||
abbreviated_key = key
|
abbreviated_key = key
|
||||||
key = ABBREVIATIONS.get(key, key)
|
key = ABBREVIATIONS.get(key, key)
|
||||||
payload[key] = payload.pop(abbreviated_key)
|
payload[key] = payload.pop(abbreviated_key)
|
||||||
|
|
||||||
if CONF_DEVICE in payload:
|
if CONF_DEVICE in payload:
|
||||||
device = payload[CONF_DEVICE]
|
device = payload[CONF_DEVICE]
|
||||||
for key in list(device.keys()):
|
for key in list(device):
|
||||||
abbreviated_key = key
|
abbreviated_key = key
|
||||||
key = DEVICE_ABBREVIATIONS.get(key, key)
|
key = DEVICE_ABBREVIATIONS.get(key, key)
|
||||||
device[key] = device.pop(abbreviated_key)
|
device[key] = device.pop(abbreviated_key)
|
||||||
|
|
|
@ -163,7 +163,7 @@ class NAD(MediaPlayerEntity):
|
||||||
@property
|
@property
|
||||||
def source_list(self):
|
def source_list(self):
|
||||||
"""List of available input sources."""
|
"""List of available input sources."""
|
||||||
return sorted(list(self._reverse_mapping.keys()))
|
return sorted(list(self._reverse_mapping))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self):
|
def available(self):
|
||||||
|
|
|
@ -203,7 +203,7 @@ class PioneerDevice(MediaPlayerEntity):
|
||||||
@property
|
@property
|
||||||
def source_list(self):
|
def source_list(self):
|
||||||
"""List of available input sources."""
|
"""List of available input sources."""
|
||||||
return list(self._source_name_to_number.keys())
|
return list(self._source_name_to_number)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_title(self):
|
def media_title(self):
|
||||||
|
|
|
@ -85,12 +85,12 @@ _VOLUME_MON_COND = {
|
||||||
}
|
}
|
||||||
|
|
||||||
_MONITORED_CONDITIONS = (
|
_MONITORED_CONDITIONS = (
|
||||||
list(_SYSTEM_MON_COND.keys())
|
list(_SYSTEM_MON_COND)
|
||||||
+ list(_CPU_MON_COND.keys())
|
+ list(_CPU_MON_COND)
|
||||||
+ list(_MEMORY_MON_COND.keys())
|
+ list(_MEMORY_MON_COND)
|
||||||
+ list(_NETWORK_MON_COND.keys())
|
+ list(_NETWORK_MON_COND)
|
||||||
+ list(_DRIVE_MON_COND.keys())
|
+ list(_DRIVE_MON_COND)
|
||||||
+ list(_VOLUME_MON_COND.keys())
|
+ list(_VOLUME_MON_COND)
|
||||||
)
|
)
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
|
|
|
@ -40,7 +40,7 @@ def _check_sensor_schema(conf):
|
||||||
except (ImportError, AttributeError):
|
except (ImportError, AttributeError):
|
||||||
return conf
|
return conf
|
||||||
|
|
||||||
customs = list(conf[CONF_CUSTOM].keys())
|
customs = list(conf[CONF_CUSTOM])
|
||||||
|
|
||||||
for sensor in conf[CONF_SENSORS]:
|
for sensor in conf[CONF_SENSORS]:
|
||||||
if sensor in customs:
|
if sensor in customs:
|
||||||
|
@ -120,7 +120,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||||
if isinstance(config_sensors, list):
|
if isinstance(config_sensors, list):
|
||||||
if not config_sensors: # Use all sensors by default
|
if not config_sensors: # Use all sensors by default
|
||||||
config_sensors = [s.name for s in sensor_def]
|
config_sensors = [s.name for s in sensor_def]
|
||||||
used_sensors = list(set(config_sensors + list(config[CONF_CUSTOM].keys())))
|
used_sensors = list(set(config_sensors + list(config[CONF_CUSTOM])))
|
||||||
for sensor in used_sensors:
|
for sensor in used_sensors:
|
||||||
hass_sensors.append(SMAsensor(sensor_def[sensor], []))
|
hass_sensors.append(SMAsensor(sensor_def[sensor], []))
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ async def async_setup_entry(
|
||||||
udn = data[CONFIG_ENTRY_UDN]
|
udn = data[CONFIG_ENTRY_UDN]
|
||||||
else:
|
else:
|
||||||
# any device will do
|
# any device will do
|
||||||
udn = list(hass.data[DOMAIN][DOMAIN_DEVICES].keys())[0]
|
udn = list(hass.data[DOMAIN][DOMAIN_DEVICES])[0]
|
||||||
|
|
||||||
device: Device = hass.data[DOMAIN][DOMAIN_DEVICES][udn]
|
device: Device = hass.data[DOMAIN][DOMAIN_DEVICES][udn]
|
||||||
|
|
||||||
|
|
|
@ -271,7 +271,7 @@ class LgWebOSMediaPlayerEntity(MediaPlayerEntity):
|
||||||
@property
|
@property
|
||||||
def source_list(self):
|
def source_list(self):
|
||||||
"""List of available input sources."""
|
"""List of available input sources."""
|
||||||
return sorted(self._source_list.keys())
|
return sorted(list(self._source_list))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_content_type(self):
|
def media_content_type(self):
|
||||||
|
|
|
@ -471,7 +471,7 @@ class YeelightGenericLight(YeelightEntity, LightEntity):
|
||||||
@property
|
@property
|
||||||
def custom_effects_names(self):
|
def custom_effects_names(self):
|
||||||
"""Return list with custom effects names."""
|
"""Return list with custom effects names."""
|
||||||
return list(self.custom_effects.keys())
|
return list(self.custom_effects)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def light_type(self):
|
def light_type(self):
|
||||||
|
|
|
@ -233,7 +233,7 @@ class AbstractOAuth2FlowHandler(config_entries.ConfigFlow, metaclass=ABCMeta):
|
||||||
data_schema=vol.Schema(
|
data_schema=vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(
|
vol.Required(
|
||||||
"implementation", default=list(implementations.keys())[0]
|
"implementation", default=list(implementations)[0]
|
||||||
): vol.In({key: impl.name for key, impl in implementations.items()})
|
): vol.In({key: impl.name for key, impl in implementations.items()})
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue