Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/auth/providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/asuswrt/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/blink/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/denon/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/environment_canada/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/eq3btsmart/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/homekit/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/insteon/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare Oct 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note for a future clean up: It's better to define a reverse dict constant at the module level and look up. This is inefficient.

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):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/izone/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/mqtt/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/nad/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/pioneer/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
12 changes: 6 additions & 6 deletions homeassistant/components/qnap/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/sma/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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], []))

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/upnp/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/webostv/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/yeelight/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/helpers/config_entry_oauth2_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()})
}
),
Expand Down