Use list literal without using dict.keys() (#42573)

This commit is contained in:
springstan 2020-10-30 15:19:13 +01:00 committed by GitHub
parent 2dc5c4dd69
commit 92379ad8d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 27 additions and 27 deletions

View File

@ -207,7 +207,7 @@ class LoginFlow(data_entry_flow.FlowHandler):
errors["base"] = "invalid_auth_module"
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 self.async_show_form(

View File

@ -35,7 +35,7 @@ class AsusWrtDeviceScanner(DeviceScanner):
async def async_scan_devices(self):
"""Scan for new devices and return a list with found device IDs."""
await self.async_update_info()
return list(self.last_results.keys())
return list(self.last_results)
async def async_get_device_name(self, device):
"""Return the name of the given device or None if we don't know."""

View File

@ -66,7 +66,7 @@ class BlinkSyncModule(AlarmControlPanelEntity):
"""Return the state attributes."""
attr = self.sync.attributes
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
return attr

View File

@ -230,7 +230,7 @@ class DenonDevice(MediaPlayerEntity):
@property
def source_list(self):
"""Return the list of available input sources."""
return sorted(list(self._source_list.keys()))
return sorted(list(self._source_list))
@property
def media_title(self):

View File

@ -61,7 +61,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
lon = config.get(CONF_LONGITUDE, hass.config.longitude)
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)

View File

@ -136,7 +136,7 @@ class EQ3BTSmartThermostat(ClimateEntity):
@property
def hvac_modes(self):
"""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):
"""Set operation mode."""
@ -181,7 +181,7 @@ class EQ3BTSmartThermostat(ClimateEntity):
Requires SUPPORT_PRESET_MODE.
"""
return list(HA_TO_EQ_PRESET.keys())
return list(HA_TO_EQ_PRESET)
def set_preset_mode(self, preset_mode):
"""Set new preset mode."""

View File

@ -357,7 +357,7 @@ class HomeKitSpeedMapping:
for state, speed_range in reversed(self.speed_ranges.items()):
if speed_range.start <= speed:
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):

View File

@ -202,12 +202,12 @@ class InsteonClimateEntity(InsteonEntity, ClimateEntity):
async def async_set_fan_mode(self, fan_mode: str) -> None:
"""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)
async def async_set_hvac_mode(self, hvac_mode: str) -> None:
"""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)
async def async_set_humidity(self, humidity):

View File

@ -509,7 +509,7 @@ class ZoneDevice(ClimateEntity):
@property
def hvac_modes(self):
"""Return the list of available operation modes."""
return list(self._state_to_pizone.keys())
return list(self._state_to_pizone)
@property
def current_temperature(self):

View File

@ -102,14 +102,14 @@ async def async_start(
payload = MQTTConfig(payload)
for key in list(payload.keys()):
for key in list(payload):
abbreviated_key = key
key = ABBREVIATIONS.get(key, key)
payload[key] = payload.pop(abbreviated_key)
if CONF_DEVICE in payload:
device = payload[CONF_DEVICE]
for key in list(device.keys()):
for key in list(device):
abbreviated_key = key
key = DEVICE_ABBREVIATIONS.get(key, key)
device[key] = device.pop(abbreviated_key)

View File

@ -163,7 +163,7 @@ class NAD(MediaPlayerEntity):
@property
def source_list(self):
"""List of available input sources."""
return sorted(list(self._reverse_mapping.keys()))
return sorted(list(self._reverse_mapping))
@property
def available(self):

View File

@ -203,7 +203,7 @@ class PioneerDevice(MediaPlayerEntity):
@property
def source_list(self):
"""List of available input sources."""
return list(self._source_name_to_number.keys())
return list(self._source_name_to_number)
@property
def media_title(self):

View File

@ -85,12 +85,12 @@ _VOLUME_MON_COND = {
}
_MONITORED_CONDITIONS = (
list(_SYSTEM_MON_COND.keys())
+ list(_CPU_MON_COND.keys())
+ list(_MEMORY_MON_COND.keys())
+ list(_NETWORK_MON_COND.keys())
+ list(_DRIVE_MON_COND.keys())
+ list(_VOLUME_MON_COND.keys())
list(_SYSTEM_MON_COND)
+ list(_CPU_MON_COND)
+ list(_MEMORY_MON_COND)
+ list(_NETWORK_MON_COND)
+ list(_DRIVE_MON_COND)
+ list(_VOLUME_MON_COND)
)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(

View File

@ -40,7 +40,7 @@ def _check_sensor_schema(conf):
except (ImportError, AttributeError):
return conf
customs = list(conf[CONF_CUSTOM].keys())
customs = list(conf[CONF_CUSTOM])
for sensor in conf[CONF_SENSORS]:
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 not config_sensors: # Use all sensors by default
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:
hass_sensors.append(SMAsensor(sensor_def[sensor], []))

View File

@ -88,7 +88,7 @@ async def async_setup_entry(
udn = data[CONFIG_ENTRY_UDN]
else:
# 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]

View File

@ -271,7 +271,7 @@ class LgWebOSMediaPlayerEntity(MediaPlayerEntity):
@property
def source_list(self):
"""List of available input sources."""
return sorted(self._source_list.keys())
return sorted(list(self._source_list))
@property
def media_content_type(self):

View File

@ -471,7 +471,7 @@ class YeelightGenericLight(YeelightEntity, LightEntity):
@property
def custom_effects_names(self):
"""Return list with custom effects names."""
return list(self.custom_effects.keys())
return list(self.custom_effects)
@property
def light_type(self):

View File

@ -233,7 +233,7 @@ class AbstractOAuth2FlowHandler(config_entries.ConfigFlow, metaclass=ABCMeta):
data_schema=vol.Schema(
{
vol.Required(
"implementation", default=list(implementations.keys())[0]
"implementation", default=list(implementations)[0]
): vol.In({key: impl.name for key, impl in implementations.items()})
}
),