diff --git a/homeassistant/auth/providers/__init__.py b/homeassistant/auth/providers/__init__.py index b60fa8eff9ce8..1fe59346b0080 100644 --- a/homeassistant/auth/providers/__init__.py +++ b/homeassistant/auth/providers/__init__.py @@ -207,7 +207,7 @@ async def async_step_select_mfa_module( 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( diff --git a/homeassistant/components/asuswrt/device_tracker.py b/homeassistant/components/asuswrt/device_tracker.py index a7c4f9a7a7c04..a3545183d2e59 100644 --- a/homeassistant/components/asuswrt/device_tracker.py +++ b/homeassistant/components/asuswrt/device_tracker.py @@ -35,7 +35,7 @@ async def async_connect(self): 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.""" diff --git a/homeassistant/components/blink/alarm_control_panel.py b/homeassistant/components/blink/alarm_control_panel.py index 1ca4c4beac9c4..dbcb6d30143a2 100644 --- a/homeassistant/components/blink/alarm_control_panel.py +++ b/homeassistant/components/blink/alarm_control_panel.py @@ -66,7 +66,7 @@ def device_state_attributes(self): """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 diff --git a/homeassistant/components/denon/media_player.py b/homeassistant/components/denon/media_player.py index ed90c2ddcb00d..b909dc7c07008 100644 --- a/homeassistant/components/denon/media_player.py +++ b/homeassistant/components/denon/media_player.py @@ -230,7 +230,7 @@ def is_volume_muted(self): @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): diff --git a/homeassistant/components/environment_canada/sensor.py b/homeassistant/components/environment_canada/sensor.py index afd75956a9f5c..a8772909f6837 100644 --- a/homeassistant/components/environment_canada/sensor.py +++ b/homeassistant/components/environment_canada/sensor.py @@ -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) diff --git a/homeassistant/components/eq3btsmart/climate.py b/homeassistant/components/eq3btsmart/climate.py index 6eb0276c31433..737b3fe357a4b 100644 --- a/homeassistant/components/eq3btsmart/climate.py +++ b/homeassistant/components/eq3btsmart/climate.py @@ -136,7 +136,7 @@ def hvac_mode(self): @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 @@ def preset_modes(self): 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.""" diff --git a/homeassistant/components/homekit/util.py b/homeassistant/components/homekit/util.py index 2ea4fcb551bbf..453ae13d846db 100644 --- a/homeassistant/components/homekit/util.py +++ b/homeassistant/components/homekit/util.py @@ -357,7 +357,7 @@ def speed_to_states(self, speed): 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): diff --git a/homeassistant/components/insteon/climate.py b/homeassistant/components/insteon/climate.py index f05cf9d29404e..7d4d9543c3fe6 100644 --- a/homeassistant/components/insteon/climate.py +++ b/homeassistant/components/insteon/climate.py @@ -202,12 +202,12 @@ async def async_set_temperature(self, **kwargs) -> None: 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): diff --git a/homeassistant/components/izone/climate.py b/homeassistant/components/izone/climate.py index cd14d1cadcf5f..443a80298f131 100644 --- a/homeassistant/components/izone/climate.py +++ b/homeassistant/components/izone/climate.py @@ -509,7 +509,7 @@ def hvac_mode(self): @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): diff --git a/homeassistant/components/mqtt/discovery.py b/homeassistant/components/mqtt/discovery.py index 7a478733826a1..7f9a6730285a6 100644 --- a/homeassistant/components/mqtt/discovery.py +++ b/homeassistant/components/mqtt/discovery.py @@ -102,14 +102,14 @@ async def async_entity_message_received(msg): 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) diff --git a/homeassistant/components/nad/media_player.py b/homeassistant/components/nad/media_player.py index 7d8537db6c624..782b8735e3ae2 100644 --- a/homeassistant/components/nad/media_player.py +++ b/homeassistant/components/nad/media_player.py @@ -163,7 +163,7 @@ def source(self): @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): diff --git a/homeassistant/components/pioneer/media_player.py b/homeassistant/components/pioneer/media_player.py index a04b79e31881d..e573bf0929c13 100644 --- a/homeassistant/components/pioneer/media_player.py +++ b/homeassistant/components/pioneer/media_player.py @@ -203,7 +203,7 @@ def source(self): @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): diff --git a/homeassistant/components/qnap/sensor.py b/homeassistant/components/qnap/sensor.py index fe4003a942390..11faba0f210ba 100644 --- a/homeassistant/components/qnap/sensor.py +++ b/homeassistant/components/qnap/sensor.py @@ -85,12 +85,12 @@ } _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( diff --git a/homeassistant/components/sma/sensor.py b/homeassistant/components/sma/sensor.py index ce61d4ff17b0d..119d9a366d6ef 100644 --- a/homeassistant/components/sma/sensor.py +++ b/homeassistant/components/sma/sensor.py @@ -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], [])) diff --git a/homeassistant/components/upnp/sensor.py b/homeassistant/components/upnp/sensor.py index 80a5ce7021c1f..a9906e535b92f 100644 --- a/homeassistant/components/upnp/sensor.py +++ b/homeassistant/components/upnp/sensor.py @@ -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] diff --git a/homeassistant/components/webostv/media_player.py b/homeassistant/components/webostv/media_player.py index 82950e4f7f8d2..4807d780a480d 100644 --- a/homeassistant/components/webostv/media_player.py +++ b/homeassistant/components/webostv/media_player.py @@ -271,7 +271,7 @@ def source(self): @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): diff --git a/homeassistant/components/yeelight/light.py b/homeassistant/components/yeelight/light.py index 06cf91faf27dc..90704a6edfba7 100644 --- a/homeassistant/components/yeelight/light.py +++ b/homeassistant/components/yeelight/light.py @@ -471,7 +471,7 @@ def custom_effects(self): @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): diff --git a/homeassistant/helpers/config_entry_oauth2_flow.py b/homeassistant/helpers/config_entry_oauth2_flow.py index ba43a057ca3a6..4d05ad7beabb1 100644 --- a/homeassistant/helpers/config_entry_oauth2_flow.py +++ b/homeassistant/helpers/config_entry_oauth2_flow.py @@ -233,7 +233,7 @@ async def async_step_pick_implementation( 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()}) } ),