diff --git a/homeassistant/components/asuswrt/__init__.py b/homeassistant/components/asuswrt/__init__.py index af7f3b05e3395c..b354d67f7469f6 100644 --- a/homeassistant/components/asuswrt/__init__.py +++ b/homeassistant/components/asuswrt/__init__.py @@ -81,7 +81,7 @@ async def async_setup(hass, config): options = {} mode = conf.get(CONF_MODE, MODE_ROUTER) for name, value in conf.items(): - if name in ([CONF_DNSMASQ, CONF_INTERFACE, CONF_REQUIRE_IP]): + if name in (CONF_DNSMASQ, CONF_INTERFACE, CONF_REQUIRE_IP): if name == CONF_REQUIRE_IP and mode != MODE_AP: continue options[name] = value diff --git a/homeassistant/components/bmw_connected_drive/binary_sensor.py b/homeassistant/components/bmw_connected_drive/binary_sensor.py index d7f0d1501931ca..f9f9c0180c1adc 100644 --- a/homeassistant/components/bmw_connected_drive/binary_sensor.py +++ b/homeassistant/components/bmw_connected_drive/binary_sensor.py @@ -109,7 +109,9 @@ def update(self): self._attr_state = vehicle_state.has_check_control_messages # device class power: On means power detected, Off means no power if self._attribute == "charging_status": - self._attr_state = vehicle_state.charging_status in [ChargingState.CHARGING] + self._attr_state = vehicle_state.charging_status in ( + ChargingState.CHARGING, + ) # device class plug: On means device is plugged in, # Off means device is unplugged if self._attribute == "connection_status": diff --git a/homeassistant/components/bmw_connected_drive/lock.py b/homeassistant/components/bmw_connected_drive/lock.py index 3d27cf833b6fa3..36630040745fce 100644 --- a/homeassistant/components/bmw_connected_drive/lock.py +++ b/homeassistant/components/bmw_connected_drive/lock.py @@ -58,7 +58,7 @@ def unlock(self, **kwargs): def update(self): """Update state of the lock.""" _LOGGER.debug("%s: updating data for %s", self._vehicle.name, self._attribute) - if self._vehicle.state.door_lock_state in [LockState.LOCKED, LockState.SECURED]: + if self._vehicle.state.door_lock_state in (LockState.LOCKED, LockState.SECURED): self._attr_is_locked = True else: self._attr_is_locked = False diff --git a/homeassistant/components/bmw_connected_drive/sensor.py b/homeassistant/components/bmw_connected_drive/sensor.py index df899496339fe0..f553707a0f061b 100644 --- a/homeassistant/components/bmw_connected_drive/sensor.py +++ b/homeassistant/components/bmw_connected_drive/sensor.py @@ -564,7 +564,7 @@ def update(self) -> None: self._attr_state = getattr(vehicle_all_trips, self._attribute) vehicle_state = self._vehicle.state - charging_state = vehicle_state.charging_status in [ChargingState.CHARGING] + charging_state = vehicle_state.charging_status in (ChargingState.CHARGING,) if self._attribute == "charging_level_hv": self._attr_icon = icon_for_battery_level( diff --git a/homeassistant/components/braviatv/config_flow.py b/homeassistant/components/braviatv/config_flow.py index 159f3806d61ba7..fc9246337dabef 100644 --- a/homeassistant/components/braviatv/config_flow.py +++ b/homeassistant/components/braviatv/config_flow.py @@ -31,7 +31,7 @@ def host_valid(host: str) -> bool: """Return True if hostname or IP address is valid.""" with suppress(ValueError): - if ipaddress.ip_address(host).version in [4, 6]: + if ipaddress.ip_address(host).version in (4, 6): return True disallowed = re.compile(r"[^a-zA-Z\d\-]") return all(x and not disallowed.search(x) for x in host.split(".")) diff --git a/homeassistant/components/brother/config_flow.py b/homeassistant/components/brother/config_flow.py index 08daf0155a1bd0..4aa282533eb518 100644 --- a/homeassistant/components/brother/config_flow.py +++ b/homeassistant/components/brother/config_flow.py @@ -27,7 +27,7 @@ def host_valid(host: str) -> bool: """Return True if hostname or IP address is valid.""" try: - if ipaddress.ip_address(host).version in [4, 6]: + if ipaddress.ip_address(host).version in (4, 6): return True except ValueError: pass diff --git a/homeassistant/components/buienradar/sensor.py b/homeassistant/components/buienradar/sensor.py index 7af84f48af738c..d9da66ca93291c 100644 --- a/homeassistant/components/buienradar/sensor.py +++ b/homeassistant/components/buienradar/sensor.py @@ -493,7 +493,7 @@ def _load_data(self, data): # noqa: C901 self._attr_state = nested.get(self.type[len(PRECIPITATION_FORECAST) + 1 :]) return True - if self.type in [WINDSPEED, WINDGUST]: + if self.type in (WINDSPEED, WINDGUST): # hass wants windspeeds in km/h not m/s, so convert: self._attr_state = data.get(self.type) if self.state is not None: diff --git a/homeassistant/components/cmus/media_player.py b/homeassistant/components/cmus/media_player.py index 651c584bc4c62a..590990861970ac 100644 --- a/homeassistant/components/cmus/media_player.py +++ b/homeassistant/components/cmus/media_player.py @@ -185,7 +185,7 @@ def volume_down(self): def play_media(self, media_type, media_id, **kwargs): """Send the play command.""" - if media_type in [MEDIA_TYPE_MUSIC, MEDIA_TYPE_PLAYLIST]: + if media_type in (MEDIA_TYPE_MUSIC, MEDIA_TYPE_PLAYLIST): self._remote.cmus.player_play_file(media_id) else: _LOGGER.error( diff --git a/homeassistant/components/cover/reproduce_state.py b/homeassistant/components/cover/reproduce_state.py index c96b9ec5acc676..8b88ef8997f2ec 100644 --- a/homeassistant/components/cover/reproduce_state.py +++ b/homeassistant/components/cover/reproduce_state.py @@ -73,9 +73,9 @@ async def _async_reproduce_state( == state.attributes.get(ATTR_CURRENT_POSITION) ): # Open/Close - if state.state in [STATE_CLOSED, STATE_CLOSING]: + if state.state in (STATE_CLOSED, STATE_CLOSING): service = SERVICE_CLOSE_COVER - elif state.state in [STATE_OPEN, STATE_OPENING]: + elif state.state in (STATE_OPEN, STATE_OPENING): if ( ATTR_CURRENT_POSITION in cur_state.attributes and ATTR_CURRENT_POSITION in state.attributes diff --git a/homeassistant/components/darksky/sensor.py b/homeassistant/components/darksky/sensor.py index 058969d96f9574..b2aa106d077e6f 100644 --- a/homeassistant/components/darksky/sensor.py +++ b/homeassistant/components/darksky/sensor.py @@ -687,10 +687,10 @@ def get_state(self, data): # Some state data needs to be rounded to whole values or converted to # percentages - if self.type in ["precip_probability", "cloud_cover", "humidity"]: + if self.type in ("precip_probability", "cloud_cover", "humidity"): return round(state * 100, 1) - if self.type in [ + if self.type in ( "dew_point", "temperature", "apparent_temperature", @@ -706,7 +706,7 @@ def get_state(self, data): "pressure", "ozone", "uvIndex", - ]: + ): return round(state, 1) return state diff --git a/homeassistant/components/deconz/sensor.py b/homeassistant/components/deconz/sensor.py index e0f123039460f1..c7ae4882d41523 100644 --- a/homeassistant/components/deconz/sensor.py +++ b/homeassistant/components/deconz/sensor.py @@ -267,12 +267,12 @@ def unique_id(self): Normally there should only be one battery sensor per device from deCONZ. With specific Danfoss devices each endpoint can report its own battery state. """ - if self._device.manufacturer == "Danfoss" and self._device.modelid in [ + if self._device.manufacturer == "Danfoss" and self._device.modelid in ( "0x8030", "0x8031", "0x8034", "0x8035", - ]: + ): return f"{super().unique_id}-battery" return f"{self.serial}-battery" diff --git a/homeassistant/components/dovado/sensor.py b/homeassistant/components/dovado/sensor.py index e7b3dbdd363084..e76a414b3e4579 100644 --- a/homeassistant/components/dovado/sensor.py +++ b/homeassistant/components/dovado/sensor.py @@ -74,7 +74,7 @@ def _compute_state(self): return None if self._sensor == SENSOR_SMS_UNREAD: return int(state) - if self._sensor in [SENSOR_UPLOAD, SENSOR_DOWNLOAD]: + if self._sensor in (SENSOR_UPLOAD, SENSOR_DOWNLOAD): return round(float(state) / 1e6, 1) return state diff --git a/homeassistant/components/dyson/fan.py b/homeassistant/components/dyson/fan.py index 38b4b511df47b1..0b46ef28ccba15 100644 --- a/homeassistant/components/dyson/fan.py +++ b/homeassistant/components/dyson/fan.py @@ -293,7 +293,7 @@ def oscillating(self): @property def is_on(self): """Return true if the entity is on.""" - return self._device.state.fan_mode in ["FAN", "AUTO"] + return self._device.state.fan_mode in ("FAN", "AUTO") def set_night_mode(self, night_mode: bool) -> None: """Turn fan in night mode.""" diff --git a/homeassistant/components/dyson/vacuum.py b/homeassistant/components/dyson/vacuum.py index f4035d33cf3af5..65563cef6329c2 100644 --- a/homeassistant/components/dyson/vacuum.py +++ b/homeassistant/components/dyson/vacuum.py @@ -102,11 +102,11 @@ def extra_state_attributes(self): @property def is_on(self) -> bool: """Return True if entity is on.""" - return self._device.state.state in [ + return self._device.state.state in ( Dyson360EyeMode.FULL_CLEAN_INITIATED, Dyson360EyeMode.FULL_CLEAN_ABORTED, Dyson360EyeMode.FULL_CLEAN_RUNNING, - ] + ) @property def available(self) -> bool: @@ -121,7 +121,7 @@ def supported_features(self): @property def battery_icon(self): """Return the battery icon for the vacuum cleaner.""" - charging = self._device.state.state in [Dyson360EyeMode.INACTIVE_CHARGING] + charging = self._device.state.state in (Dyson360EyeMode.INACTIVE_CHARGING,) return icon_for_battery_level( battery_level=self.battery_level, charging=charging ) @@ -129,7 +129,7 @@ def battery_icon(self): def turn_on(self, **kwargs): """Turn the vacuum on.""" _LOGGER.debug("Turn on device %s", self.name) - if self._device.state.state in [Dyson360EyeMode.FULL_CLEAN_PAUSED]: + if self._device.state.state in (Dyson360EyeMode.FULL_CLEAN_PAUSED,): self._device.resume() else: self._device.start() @@ -152,13 +152,13 @@ def set_fan_speed(self, fan_speed, **kwargs): def start_pause(self, **kwargs): """Start, pause or resume the cleaning task.""" - if self._device.state.state in [Dyson360EyeMode.FULL_CLEAN_PAUSED]: + if self._device.state.state in (Dyson360EyeMode.FULL_CLEAN_PAUSED,): _LOGGER.debug("Resume device %s", self.name) self._device.resume() - elif self._device.state.state in [ + elif self._device.state.state in ( Dyson360EyeMode.INACTIVE_CHARGED, Dyson360EyeMode.INACTIVE_CHARGING, - ]: + ): _LOGGER.debug("Start device %s", self.name) self._device.start() else: diff --git a/homeassistant/components/econet/climate.py b/homeassistant/components/econet/climate.py index fe50855d559366..f60d36b8c734a8 100644 --- a/homeassistant/components/econet/climate.py +++ b/homeassistant/components/econet/climate.py @@ -185,7 +185,7 @@ def fan_mode(self): econet_fan_mode = self._econet.fan_mode # Remove this after we figure out how to handle med lo and med hi - if econet_fan_mode in [ThermostatFanMode.MEDHI, ThermostatFanMode.MEDLO]: + if econet_fan_mode in (ThermostatFanMode.MEDHI, ThermostatFanMode.MEDLO): econet_fan_mode = ThermostatFanMode.MEDIUM _current_fan_mode = FAN_AUTO diff --git a/homeassistant/components/emulated_hue/hue_api.py b/homeassistant/components/emulated_hue/hue_api.py index bbd899b559b104..16ae0c3ca1f3af 100644 --- a/homeassistant/components/emulated_hue/hue_api.py +++ b/homeassistant/components/emulated_hue/hue_api.py @@ -409,14 +409,14 @@ async def put(self, request, username, entity_number): # noqa: C901 parsed[STATE_BRIGHTNESS] = None parsed[STATE_ON] = True - elif entity.domain in [ + elif entity.domain in ( script.DOMAIN, media_player.DOMAIN, fan.DOMAIN, cover.DOMAIN, climate.DOMAIN, humidifier.DOMAIN, - ]: + ): # Convert 0-254 to 0-100 level = (parsed[STATE_BRIGHTNESS] / HUE_API_STATE_BRI_MAX) * 100 parsed[STATE_BRIGHTNESS] = round(level) diff --git a/homeassistant/components/hdmi_cec/__init__.py b/homeassistant/components/hdmi_cec/__init__.py index 7182642904045a..73ad092087cd7b 100644 --- a/homeassistant/components/hdmi_cec/__init__.py +++ b/homeassistant/components/hdmi_cec/__init__.py @@ -389,7 +389,7 @@ def _hdmi_cec_unavailable(self, callback_event): def update(self): """Update device status.""" device = self._device - if device.power_status in [POWER_OFF, 3]: + if device.power_status in (POWER_OFF, 3): self._state = STATE_OFF elif device.status == STATUS_PLAY: self._state = STATE_PLAYING @@ -397,7 +397,7 @@ def update(self): self._state = STATE_IDLE elif device.status == STATUS_STILL: self._state = STATE_PAUSED - elif device.power_status in [POWER_ON, 4]: + elif device.power_status in (POWER_ON, 4): self._state = STATE_ON else: _LOGGER.warning("Unknown state: %d", device.power_status) diff --git a/homeassistant/components/hdmi_cec/media_player.py b/homeassistant/components/hdmi_cec/media_player.py index c3cab6a8f981e1..a213737a8f0d0d 100644 --- a/homeassistant/components/hdmi_cec/media_player.py +++ b/homeassistant/components/hdmi_cec/media_player.py @@ -156,10 +156,10 @@ def state(self) -> str: def update(self): """Update device status.""" device = self._device - if device.power_status in [POWER_OFF, 3]: + if device.power_status in (POWER_OFF, 3): self._state = STATE_OFF elif not self.support_pause: - if device.power_status in [POWER_ON, 4]: + if device.power_status in (POWER_ON, 4): self._state = STATE_ON elif device.status == STATUS_PLAY: self._state = STATE_PLAYING diff --git a/homeassistant/components/home_connect/switch.py b/homeassistant/components/home_connect/switch.py index 5e12d724a5e3ce..f8f3f6b41caafb 100644 --- a/homeassistant/components/home_connect/switch.py +++ b/homeassistant/components/home_connect/switch.py @@ -140,7 +140,7 @@ async def async_update(self): self._state = False elif self.device.appliance.status.get(BSH_OPERATION_STATE, {}).get( ATTR_VALUE, None - ) in [ + ) in ( "BSH.Common.EnumType.OperationState.Ready", "BSH.Common.EnumType.OperationState.DelayedStart", "BSH.Common.EnumType.OperationState.Run", @@ -148,7 +148,7 @@ async def async_update(self): "BSH.Common.EnumType.OperationState.ActionRequired", "BSH.Common.EnumType.OperationState.Aborting", "BSH.Common.EnumType.OperationState.Finished", - ]: + ): self._state = True elif ( self.device.appliance.status.get(BSH_OPERATION_STATE, {}).get(ATTR_VALUE) diff --git a/homeassistant/components/homematicip_cloud/climate.py b/homeassistant/components/homematicip_cloud/climate.py index 7ba90e0a9e4bc9..19467cdcc00b0a 100644 --- a/homeassistant/components/homematicip_cloud/climate.py +++ b/homeassistant/components/homematicip_cloud/climate.py @@ -163,11 +163,11 @@ def preset_mode(self) -> str | None: if self._device.controlMode == HMIP_ECO_CM: if self._indoor_climate.absenceType == AbsenceType.VACATION: return PRESET_AWAY - if self._indoor_climate.absenceType in [ + if self._indoor_climate.absenceType in ( AbsenceType.PARTY, AbsenceType.PERIOD, AbsenceType.PERMANENT, - ]: + ): return PRESET_ECO return ( @@ -245,11 +245,11 @@ def extra_state_attributes(self) -> dict[str, Any]: state_attr = super().extra_state_attributes if self._device.controlMode == HMIP_ECO_CM: - if self._indoor_climate.absenceType in [ + if self._indoor_climate.absenceType in ( AbsenceType.PARTY, AbsenceType.PERIOD, AbsenceType.VACATION, - ]: + ): state_attr[ATTR_PRESET_END_TIME] = self._indoor_climate.absenceEndTime elif self._indoor_climate.absenceType == AbsenceType.PERMANENT: state_attr[ATTR_PRESET_END_TIME] = PERMANENT_END_TIME diff --git a/homeassistant/components/honeywell/climate.py b/homeassistant/components/honeywell/climate.py index 36fe16aeaa2145..b9ed8f75c36b4c 100644 --- a/homeassistant/components/honeywell/climate.py +++ b/homeassistant/components/honeywell/climate.py @@ -205,7 +205,7 @@ def extra_state_attributes(self) -> dict[str, Any]: @property def min_temp(self) -> float: """Return the minimum temperature.""" - if self.hvac_mode in [HVAC_MODE_COOL, HVAC_MODE_HEAT_COOL]: + if self.hvac_mode in (HVAC_MODE_COOL, HVAC_MODE_HEAT_COOL): return self._device.raw_ui_data["CoolLowerSetptLimit"] if self.hvac_mode == HVAC_MODE_HEAT: return self._device.raw_ui_data["HeatLowerSetptLimit"] @@ -216,7 +216,7 @@ def max_temp(self) -> float: """Return the maximum temperature.""" if self.hvac_mode == HVAC_MODE_COOL: return self._device.raw_ui_data["CoolUpperSetptLimit"] - if self.hvac_mode in [HVAC_MODE_HEAT, HVAC_MODE_HEAT_COOL]: + if self.hvac_mode in (HVAC_MODE_HEAT, HVAC_MODE_HEAT_COOL): return self._device.raw_ui_data["HeatUpperSetptLimit"] return None diff --git a/homeassistant/components/insteon/utils.py b/homeassistant/components/insteon/utils.py index ace24644523d29..995aae80566bff 100644 --- a/homeassistant/components/insteon/utils.py +++ b/homeassistant/components/insteon/utils.py @@ -116,12 +116,12 @@ def async_fire_group_on_off_event(name, address, group, button): for group in device.events: if isinstance(group, int): for event in device.events[group]: - if event in [ + if event in ( OFF_EVENT, ON_EVENT, OFF_FAST_EVENT, ON_FAST_EVENT, - ]: + ): _LOGGER.debug( "Registering on/off event for %s %d %s", str(device.address), diff --git a/homeassistant/components/itunes/media_player.py b/homeassistant/components/itunes/media_player.py index 2b531773d55317..b4d3bce80a7dde 100644 --- a/homeassistant/components/itunes/media_player.py +++ b/homeassistant/components/itunes/media_player.py @@ -154,7 +154,7 @@ def play_playlist(self, playlist_id_or_name): found_playlists = [ playlist for playlist in playlists - if (playlist_id_or_name in [playlist["name"], playlist["id"]]) + if (playlist_id_or_name in (playlist["name"], playlist["id"])) ] if found_playlists: diff --git a/homeassistant/components/kodi/media_player.py b/homeassistant/components/kodi/media_player.py index 42943cffb136f9..544e834aedf7cd 100644 --- a/homeassistant/components/kodi/media_player.py +++ b/homeassistant/components/kodi/media_player.py @@ -695,20 +695,20 @@ async def async_play_media(self, media_type, media_id, **kwargs): await self._kodi.play_playlist(int(media_id)) elif media_type_lower == "directory": await self._kodi.play_directory(str(media_id)) - elif media_type_lower in [ + elif media_type_lower in ( MEDIA_TYPE_ARTIST, MEDIA_TYPE_ALBUM, MEDIA_TYPE_TRACK, - ]: + ): await self.async_clear_playlist() await self.async_add_to_playlist(media_type_lower, media_id) await self._kodi.play_playlist(0) - elif media_type_lower in [ + elif media_type_lower in ( MEDIA_TYPE_MOVIE, MEDIA_TYPE_EPISODE, MEDIA_TYPE_SEASON, MEDIA_TYPE_TVSHOW, - ]: + ): await self._kodi.play_item( {MAP_KODI_MEDIA_TYPES[media_type_lower]: int(media_id)} ) @@ -891,7 +891,7 @@ async def _get_thumbnail_url( media_image_id, ) - if media_content_type in [None, "library"]: + if media_content_type in (None, "library"): return await library_payload() payload = { diff --git a/homeassistant/components/konnected/panel.py b/homeassistant/components/konnected/panel.py index cf2f33de33292b..d142b5ae34ed0f 100644 --- a/homeassistant/components/konnected/panel.py +++ b/homeassistant/components/konnected/panel.py @@ -284,7 +284,7 @@ def async_actuator_configuration(self): return [ self.format_zone( data[CONF_ZONE], - {"trigger": (0 if data.get(CONF_ACTIVATION) in [0, STATE_LOW] else 1)}, + {"trigger": (0 if data.get(CONF_ACTIVATION) in (0, STATE_LOW) else 1)}, ) for data in self.stored_configuration[CONF_SWITCHES] ] diff --git a/homeassistant/components/min_max/sensor.py b/homeassistant/components/min_max/sensor.py index d103ff8eaa68ee..ffccd38557bf2d 100644 --- a/homeassistant/components/min_max/sensor.py +++ b/homeassistant/components/min_max/sensor.py @@ -212,10 +212,10 @@ def _async_min_max_sensor_state_listener(self, event): new_state = event.data.get("new_state") entity = event.data.get("entity_id") - if new_state.state is None or new_state.state in [ + if new_state.state is None or new_state.state in ( STATE_UNKNOWN, STATE_UNAVAILABLE, - ]: + ): self.states[entity] = STATE_UNKNOWN self._calc_values() self.async_write_ha_state() diff --git a/homeassistant/components/onewire/onewire_entities.py b/homeassistant/components/onewire/onewire_entities.py index b60d06739e83c9..28308cfe18beba 100644 --- a/homeassistant/components/onewire/onewire_entities.py +++ b/homeassistant/components/onewire/onewire_entities.py @@ -120,11 +120,11 @@ def update(self) -> None: else: if self._entity_type == SENSOR_TYPE_COUNT: self._state = int(self._value_raw) - elif self._entity_type in [ + elif self._entity_type in ( SENSOR_TYPE_SENSED, SWITCH_TYPE_LATCH, SWITCH_TYPE_PIO, - ]: + ): self._state = int(self._value_raw) == 1 else: self._state = round(self._value_raw, 1) diff --git a/homeassistant/components/opengarage/cover.py b/homeassistant/components/opengarage/cover.py index 154cb4df3ae09f..3e27cf2ebc009c 100644 --- a/homeassistant/components/opengarage/cover.py +++ b/homeassistant/components/opengarage/cover.py @@ -116,11 +116,11 @@ def is_closed(self): """Return if the cover is closed.""" if self._state is None: return None - return self._state in [STATE_CLOSED, STATE_OPENING] + return self._state in (STATE_CLOSED, STATE_OPENING) async def async_close_cover(self, **kwargs): """Close the cover.""" - if self._state in [STATE_CLOSED, STATE_CLOSING]: + if self._state in (STATE_CLOSED, STATE_CLOSING): return self._state_before_move = self._state self._state = STATE_CLOSING @@ -128,7 +128,7 @@ async def async_close_cover(self, **kwargs): async def async_open_cover(self, **kwargs): """Open the cover.""" - if self._state in [STATE_OPEN, STATE_OPENING]: + if self._state in (STATE_OPEN, STATE_OPENING): return self._state_before_move = self._state self._state = STATE_OPENING diff --git a/homeassistant/components/panasonic_bluray/media_player.py b/homeassistant/components/panasonic_bluray/media_player.py index 792ee644bd9e9d..5ccb700da1f450 100644 --- a/homeassistant/components/panasonic_bluray/media_player.py +++ b/homeassistant/components/panasonic_bluray/media_player.py @@ -100,12 +100,12 @@ def update(self): if state[0] == "error": self._state = None - elif state[0] in ["off", "standby"]: + elif state[0] in ("off", "standby"): # We map both of these to off. If it's really off we can't # turn it on, but from standby we can go to idle by pressing # POWER. self._state = STATE_OFF - elif state[0] in ["paused", "stopped"]: + elif state[0] in ("paused", "stopped"): self._state = STATE_IDLE elif state[0] == "playing": self._state = STATE_PLAYING diff --git a/homeassistant/components/philips_js/light.py b/homeassistant/components/philips_js/light.py index 3dbca7611ab884..cb26a499ecf2a9 100644 --- a/homeassistant/components/philips_js/light.py +++ b/homeassistant/components/philips_js/light.py @@ -219,7 +219,7 @@ def color_mode(self): if current and current["isExpert"]: return COLOR_MODE_HS - if self._tv.ambilight_mode in ["manual", "expert"]: + if self._tv.ambilight_mode in ("manual", "expert"): return COLOR_MODE_HS return COLOR_MODE_ONOFF diff --git a/homeassistant/components/rachio/switch.py b/homeassistant/components/rachio/switch.py index de897cb7f07e3a..00e2b1a672f859 100644 --- a/homeassistant/components/rachio/switch.py +++ b/homeassistant/components/rachio/switch.py @@ -446,11 +446,11 @@ def _async_handle_update(self, *args, **kwargs) -> None: if args[0][KEY_SUBTYPE] == SUBTYPE_ZONE_STARTED: self._state = True - elif args[0][KEY_SUBTYPE] in [ + elif args[0][KEY_SUBTYPE] in ( SUBTYPE_ZONE_STOPPED, SUBTYPE_ZONE_COMPLETED, SUBTYPE_ZONE_PAUSED, - ]: + ): self._state = False self.async_write_ha_state() @@ -529,12 +529,12 @@ def _async_handle_update(self, *args, **kwargs) -> None: # Schedule ID not passed when running individual zones, so we catch that error with suppress(KeyError): if args[0][KEY_SCHEDULE_ID] == self._schedule_id: - if args[0][KEY_SUBTYPE] in [SUBTYPE_SCHEDULE_STARTED]: + if args[0][KEY_SUBTYPE] in (SUBTYPE_SCHEDULE_STARTED,): self._state = True - elif args[0][KEY_SUBTYPE] in [ + elif args[0][KEY_SUBTYPE] in ( SUBTYPE_SCHEDULE_STOPPED, SUBTYPE_SCHEDULE_COMPLETED, - ]: + ): self._state = False self.async_write_ha_state() diff --git a/homeassistant/components/recorder/models.py b/homeassistant/components/recorder/models.py index 929115bdf25540..318ad19dc887bd 100644 --- a/homeassistant/components/recorder/models.py +++ b/homeassistant/components/recorder/models.py @@ -489,7 +489,7 @@ def as_dict(self): def __eq__(self, other): """Return the comparison.""" return ( - other.__class__ in [self.__class__, State] + other.__class__ in (self.__class__, State) and self.entity_id == other.entity_id and self.state == other.state and self.attributes == other.attributes diff --git a/homeassistant/components/recorder/util.py b/homeassistant/components/recorder/util.py index 225eee6867fbad..ad835ad0c28d35 100644 --- a/homeassistant/components/recorder/util.py +++ b/homeassistant/components/recorder/util.py @@ -182,7 +182,7 @@ def basic_sanity_check(cursor): """Check tables to make sure select does not fail.""" for table in ALL_TABLES: - if table in [TABLE_STATISTICS, TABLE_STATISTICS_META]: + if table in (TABLE_STATISTICS, TABLE_STATISTICS_META): continue if table in (TABLE_RECORDER_RUNS, TABLE_SCHEMA_CHANGES): cursor.execute(f"SELECT * FROM {table};") # nosec # not injection diff --git a/homeassistant/components/rflink/__init__.py b/homeassistant/components/rflink/__init__.py index 9cff8377c3533e..be03f016a19d17 100644 --- a/homeassistant/components/rflink/__init__.py +++ b/homeassistant/components/rflink/__init__.py @@ -516,7 +516,7 @@ async def _async_handle_command(self, command, *args): cmd = "on" # if the state is unknown or false, it gets set as true # if the state is true, it gets set as false - self._state = self._state in [None, False] + self._state = self._state in (None, False) # Cover options for RFlink elif command == "close_cover": @@ -590,9 +590,9 @@ def _handle_event(self, event): self.cancel_queued_send_commands() command = event["command"] - if command in ["on", "allon"]: + if command in ("on", "allon"): self._state = True - elif command in ["off", "alloff"]: + elif command in ("off", "alloff"): self._state = False async def async_turn_on(self, **kwargs): diff --git a/homeassistant/components/rflink/binary_sensor.py b/homeassistant/components/rflink/binary_sensor.py index 77a8a522f6594b..fcce8214842900 100644 --- a/homeassistant/components/rflink/binary_sensor.py +++ b/homeassistant/components/rflink/binary_sensor.py @@ -74,9 +74,9 @@ def __init__( def _handle_event(self, event): """Domain specific event handler.""" command = event["command"] - if command in ["on", "allon"]: + if command in ("on", "allon"): self._state = True - elif command in ["off", "alloff"]: + elif command in ("off", "alloff"): self._state = False if self._state and self._off_delay is not None: diff --git a/homeassistant/components/rflink/cover.py b/homeassistant/components/rflink/cover.py index 2e6837d21ea6e2..8cbddf961981df 100644 --- a/homeassistant/components/rflink/cover.py +++ b/homeassistant/components/rflink/cover.py @@ -127,9 +127,9 @@ def _handle_event(self, event): self.cancel_queued_send_commands() command = event["command"] - if command in ["on", "allon", "up"]: + if command in ("on", "allon", "up"): self._state = True - elif command in ["off", "alloff", "down"]: + elif command in ("off", "alloff", "down"): self._state = False @property diff --git a/homeassistant/components/rflink/light.py b/homeassistant/components/rflink/light.py index 5a0d67661797c5..1a21d7ee792955 100644 --- a/homeassistant/components/rflink/light.py +++ b/homeassistant/components/rflink/light.py @@ -197,9 +197,9 @@ def _handle_event(self, event): self.cancel_queued_send_commands() command = event["command"] - if command in ["on", "allon"]: + if command in ("on", "allon"): self._state = True - elif command in ["off", "alloff"]: + elif command in ("off", "alloff"): self._state = False # dimmable device accept 'set_level=(0-15)' commands elif re.search("^set_level=(0?[0-9]|1[0-5])$", command, re.IGNORECASE): @@ -258,7 +258,7 @@ def _handle_event(self, event): if command == "on": # if the state is unknown or false, it gets set as true # if the state is true, it gets set as false - self._state = self._state in [None, False] + self._state = self._state in (None, False) async def async_turn_on(self, **kwargs): """Turn the device on.""" diff --git a/homeassistant/components/roku/media_player.py b/homeassistant/components/roku/media_player.py index bb9b4bfa37fef1..4736c789c82877 100644 --- a/homeassistant/components/roku/media_player.py +++ b/homeassistant/components/roku/media_player.py @@ -268,7 +268,7 @@ def _get_thumbnail_url( media_content_type, media_content_id, media_image_id ) - if media_content_type in [None, "library"]: + if media_content_type in (None, "library"): return library_payload(self.coordinator, _get_thumbnail_url) payload = { diff --git a/homeassistant/components/roon/media_browser.py b/homeassistant/components/roon/media_browser.py index 0d744befb5c04d..7d998b1d3743da 100644 --- a/homeassistant/components/roon/media_browser.py +++ b/homeassistant/components/roon/media_browser.py @@ -42,7 +42,7 @@ def browse_media(zone_id, roon_server, media_content_type=None, media_content_id """Implement the websocket media browsing helper.""" try: _LOGGER.debug("browse_media: %s: %s", media_content_type, media_content_id) - if media_content_type in [None, "library"]: + if media_content_type in (None, "library"): return library_payload(roon_server, zone_id, media_content_id) except UnknownMediaType as err: diff --git a/homeassistant/components/roon/media_player.py b/homeassistant/components/roon/media_player.py index dd8d9e83c2d606..d465755fe5d68d 100644 --- a/homeassistant/components/roon/media_player.py +++ b/homeassistant/components/roon/media_player.py @@ -261,7 +261,7 @@ def update_state(self): for source in self.player_data["source_controls"]: if source["supports_standby"] and source["status"] != "indeterminate": self._supports_standby = True - if source["status"] in ["standby", "deselected"]: + if source["status"] in ("standby", "deselected"): new_state = STATE_OFF break # determine player state diff --git a/homeassistant/components/shelly/binary_sensor.py b/homeassistant/components/shelly/binary_sensor.py index dd1b3a9d66d532..1d87c03e4c6c18 100644 --- a/homeassistant/components/shelly/binary_sensor.py +++ b/homeassistant/components/shelly/binary_sensor.py @@ -53,7 +53,7 @@ ("sensor", "gas"): BlockAttributeDescription( name="Gas", device_class=DEVICE_CLASS_GAS, - value=lambda value: value in ["mild", "heavy"], + value=lambda value: value in ("mild", "heavy"), extra_state_attributes=lambda block: {"detected": block.gas}, ), ("sensor", "smoke"): BlockAttributeDescription( diff --git a/homeassistant/components/shelly/switch.py b/homeassistant/components/shelly/switch.py index 3e35ba878e4a8a..d97086c93b807b 100644 --- a/homeassistant/components/shelly/switch.py +++ b/homeassistant/components/shelly/switch.py @@ -26,7 +26,7 @@ async def async_setup_entry( # In roller mode the relay blocks exist but do not contain required info if ( - wrapper.model in ["SHSW-21", "SHSW-25"] + wrapper.model in ("SHSW-21", "SHSW-25") and wrapper.device.settings["mode"] != "relay" ): return diff --git a/homeassistant/components/shelly/utils.py b/homeassistant/components/shelly/utils.py index d8ce5ae9e4577b..c63070af1a7c59 100644 --- a/homeassistant/components/shelly/utils.py +++ b/homeassistant/components/shelly/utils.py @@ -56,15 +56,15 @@ def get_number_of_channels(device: aioshelly.Device, block: aioshelly.Block) -> if block.type == "input": # Shelly Dimmer/1L has two input channels and missing "num_inputs" - if device.settings["device"]["type"] in ["SHDM-1", "SHDM-2", "SHSW-L"]: + if device.settings["device"]["type"] in ("SHDM-1", "SHDM-2", "SHSW-L"): channels = 2 else: channels = device.shelly.get("num_inputs") elif block.type == "emeter": channels = device.shelly.get("num_emeters") - elif block.type in ["relay", "light"]: + elif block.type in ("relay", "light"): channels = device.shelly.get("num_outputs") - elif block.type in ["roller", "device"]: + elif block.type in ("roller", "device"): channels = 1 return channels or 1 @@ -133,7 +133,7 @@ def is_momentary_input(settings: dict[str, Any], block: aioshelly.Block) -> bool channel = min(int(block.channel or 0), len(button) - 1) button_type = button[channel].get("btn_type") - return button_type in ["momentary", "momentary_on_release"] + return button_type in ("momentary", "momentary_on_release") def get_device_uptime(status: dict[str, Any], last_uptime: str) -> str: diff --git a/homeassistant/components/sisyphus/media_player.py b/homeassistant/components/sisyphus/media_player.py index 21e50b19a1b0db..9af59f97ddf5b0 100644 --- a/homeassistant/components/sisyphus/media_player.py +++ b/homeassistant/components/sisyphus/media_player.py @@ -87,7 +87,7 @@ def name(self): @property def state(self): """Return the current state of the table; sleeping maps to off.""" - if self._table.state in ["homing", "playing"]: + if self._table.state in ("homing", "playing"): return STATE_PLAYING if self._table.state == "paused": if self._table.is_sleeping: diff --git a/homeassistant/components/solaredge/coordinator.py b/homeassistant/components/solaredge/coordinator.py index b2fe27db808073..54da1f7fc694cd 100644 --- a/homeassistant/components/solaredge/coordinator.py +++ b/homeassistant/components/solaredge/coordinator.py @@ -78,9 +78,9 @@ def update(self) -> None: self.data = {} for key, value in overview.items(): - if key in ["lifeTimeData", "lastYearData", "lastMonthData", "lastDayData"]: + if key in ("lifeTimeData", "lastYearData", "lastMonthData", "lastDayData"): data = value["energy"] - elif key in ["currentPower"]: + elif key in ("currentPower",): data = value["power"] else: data = value @@ -118,16 +118,16 @@ def update(self) -> None: for key, value in details.items(): key = snakecase(key) - if key in ["primary_module"]: + if key in ("primary_module",): for module_key, module_value in value.items(): self.attributes[snakecase(module_key)] = module_value - elif key in [ + elif key in ( "peak_power", "type", "name", "last_update_time", "installation_date", - ]: + ): self.attributes[key] = value elif key == "status": self.data = value @@ -262,16 +262,16 @@ def update(self) -> None: self.unit = power_flow["unit"] for key, value in power_flow.items(): - if key in ["LOAD", "PV", "GRID", "STORAGE"]: + if key in ("LOAD", "PV", "GRID", "STORAGE"): self.data[key] = value["currentPower"] self.attributes[key] = {"status": value["status"]} - if key in ["GRID"]: + if key in ("GRID",): export = key.lower() in power_to self.data[key] *= -1 if export else 1 self.attributes[key]["flow"] = "export" if export else "import" - if key in ["STORAGE"]: + if key in ("STORAGE",): charge = key.lower() in power_to self.data[key] *= -1 if charge else 1 self.attributes[key]["flow"] = "charge" if charge else "discharge" diff --git a/homeassistant/components/sonos/media_browser.py b/homeassistant/components/sonos/media_browser.py index 179fc62e0cc195..76e60466e39edf 100644 --- a/homeassistant/components/sonos/media_browser.py +++ b/homeassistant/components/sonos/media_browser.py @@ -157,10 +157,10 @@ def get_media_type(item): if ( item.item_class == "object.container.album.musicAlbum" and SONOS_TYPES_MAPPING.get(item.item_id.split("/")[0]) - in [ + in ( SONOS_ALBUM_ARTIST, SONOS_GENRE, - ] + ) ): return SONOS_TYPES_MAPPING[item.item_class] diff --git a/homeassistant/components/sonos/media_player.py b/homeassistant/components/sonos/media_player.py index 0948e971baffac..cf50e35061effa 100644 --- a/homeassistant/components/sonos/media_player.py +++ b/homeassistant/components/sonos/media_player.py @@ -451,10 +451,10 @@ def select_source(self, source: str) -> None: if len(fav) == 1: src = fav.pop() uri = src.reference.get_uri() - if soco.music_source_from_uri(uri) in [ + if soco.music_source_from_uri(uri) in ( MUSIC_SRC_RADIO, MUSIC_SRC_LINE_IN, - ]: + ): soco.play_uri(uri, title=source) else: soco.clear_queue() @@ -668,7 +668,7 @@ async def async_get_browse_image( ) -> tuple[None | str, None | str]: """Fetch media browser image to serve via proxy.""" if ( - media_content_type in [MEDIA_TYPE_ALBUM, MEDIA_TYPE_ARTIST] + media_content_type in (MEDIA_TYPE_ALBUM, MEDIA_TYPE_ARTIST) and media_content_id ): item = await self.hass.async_add_executor_job( @@ -709,7 +709,7 @@ def _get_thumbnail_url( media_image_id, ) - if media_content_type in [None, "library"]: + if media_content_type in (None, "library"): return await self.hass.async_add_executor_job( library_payload, self.media.library, _get_thumbnail_url ) diff --git a/homeassistant/components/squeezebox/media_player.py b/homeassistant/components/squeezebox/media_player.py index baf8a011c650ee..b1e5e35e865dd1 100644 --- a/homeassistant/components/squeezebox/media_player.py +++ b/homeassistant/components/squeezebox/media_player.py @@ -580,7 +580,7 @@ async def async_browse_media(self, media_content_type=None, media_content_id=Non media_content_id, ) - if media_content_type in [None, "library"]: + if media_content_type in (None, "library"): return await library_payload(self._player) payload = { diff --git a/homeassistant/components/surepetcare/binary_sensor.py b/homeassistant/components/surepetcare/binary_sensor.py index ca7b73781276c0..7b068503bab0e3 100644 --- a/homeassistant/components/surepetcare/binary_sensor.py +++ b/homeassistant/components/surepetcare/binary_sensor.py @@ -35,12 +35,12 @@ async def async_setup_platform( for surepy_entity in spc.states.values(): # connectivity - if surepy_entity.type in [ + if surepy_entity.type in ( EntityType.CAT_FLAP, EntityType.PET_FLAP, EntityType.FEEDER, EntityType.FELAQUA, - ]: + ): entities.append(DeviceConnectivity(surepy_entity.id, spc)) if surepy_entity.type == EntityType.PET: diff --git a/homeassistant/components/surepetcare/sensor.py b/homeassistant/components/surepetcare/sensor.py index fbc8222f292134..8c4ac72d4d801f 100644 --- a/homeassistant/components/surepetcare/sensor.py +++ b/homeassistant/components/surepetcare/sensor.py @@ -34,12 +34,12 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= for surepy_entity in spc.states.values(): - if surepy_entity.type in [ + if surepy_entity.type in ( EntityType.CAT_FLAP, EntityType.PET_FLAP, EntityType.FEEDER, EntityType.FELAQUA, - ]: + ): entities.append(SureBattery(surepy_entity.id, spc)) async_add_entities(entities) diff --git a/homeassistant/components/tado/climate.py b/homeassistant/components/tado/climate.py index aa9852f643f263..dea1fce54dd9fd 100644 --- a/homeassistant/components/tado/climate.py +++ b/homeassistant/components/tado/climate.py @@ -103,7 +103,7 @@ def _generate_entities(tado): """Create all climate entities.""" entities = [] for zone in tado.zones: - if zone["type"] in [TYPE_HEATING, TYPE_AIR_CONDITIONING]: + if zone["type"] in (TYPE_HEATING, TYPE_AIR_CONDITIONING): entity = create_climate_entity( tado, zone["name"], zone["id"], zone["devices"][0] ) diff --git a/homeassistant/components/tado/sensor.py b/homeassistant/components/tado/sensor.py index e1219b5620bf5e..48d77aa3e263ce 100644 --- a/homeassistant/components/tado/sensor.py +++ b/homeassistant/components/tado/sensor.py @@ -139,7 +139,7 @@ def extra_state_attributes(self): @property def unit_of_measurement(self): """Return the unit of measurement.""" - if self.home_variable in ["temperature", "outdoor temperature"]: + if self.home_variable in ("temperature", "outdoor temperature"): return TEMP_CELSIUS if self.home_variable == "solar percentage": return PERCENTAGE diff --git a/homeassistant/components/tasmota/light.py b/homeassistant/components/tasmota/light.py index de25a25fd4ff82..405ecf4a706685 100644 --- a/homeassistant/components/tasmota/light.py +++ b/homeassistant/components/tasmota/light.py @@ -129,7 +129,7 @@ def _setup_from_entity(self) -> None: supported_features = 0 light_type = self._tasmota_entity.light_type - if light_type in [LIGHT_TYPE_RGB, LIGHT_TYPE_RGBW, LIGHT_TYPE_RGBCW]: + if light_type in (LIGHT_TYPE_RGB, LIGHT_TYPE_RGBW, LIGHT_TYPE_RGBCW): # Mark HS support for RGBW light because we don't have direct control over the # white channel, so the base component's RGB->RGBW translation does not work self._supported_color_modes.add(COLOR_MODE_HS) @@ -138,7 +138,7 @@ def _setup_from_entity(self) -> None: if light_type == LIGHT_TYPE_RGBW: self._supported_color_modes.add(COLOR_MODE_WHITE) - if light_type in [LIGHT_TYPE_COLDWARM, LIGHT_TYPE_RGBCW]: + if light_type in (LIGHT_TYPE_COLDWARM, LIGHT_TYPE_RGBCW): self._supported_color_modes.add(COLOR_MODE_COLOR_TEMP) self._color_mode = COLOR_MODE_COLOR_TEMP @@ -150,7 +150,7 @@ def _setup_from_entity(self) -> None: self._supported_color_modes.add(COLOR_MODE_ONOFF) self._color_mode = COLOR_MODE_ONOFF - if light_type in [LIGHT_TYPE_RGB, LIGHT_TYPE_RGBW, LIGHT_TYPE_RGBCW]: + if light_type in (LIGHT_TYPE_RGB, LIGHT_TYPE_RGBW, LIGHT_TYPE_RGBCW): supported_features |= SUPPORT_EFFECT if self._tasmota_entity.supports_transition: diff --git a/homeassistant/components/telegram_bot/__init__.py b/homeassistant/components/telegram_bot/__init__.py index c3f07e5269d2ad..8339c99e4f7a17 100644 --- a/homeassistant/components/telegram_bot/__init__.py +++ b/homeassistant/components/telegram_bot/__init__.py @@ -368,14 +368,14 @@ def _render_template_attr(data, attribute): await hass.async_add_executor_job( partial(notify_service.send_message, **kwargs) ) - elif msgtype in [ + elif msgtype in ( SERVICE_SEND_PHOTO, SERVICE_SEND_STICKER, SERVICE_SEND_ANIMATION, SERVICE_SEND_VIDEO, SERVICE_SEND_VOICE, SERVICE_SEND_DOCUMENT, - ]: + ): await hass.async_add_executor_job( partial(notify_service.send_file, msgtype, **kwargs) ) diff --git a/homeassistant/components/threshold/binary_sensor.py b/homeassistant/components/threshold/binary_sensor.py index 1a53a599394486..2ad3822e6b1d17 100644 --- a/homeassistant/components/threshold/binary_sensor.py +++ b/homeassistant/components/threshold/binary_sensor.py @@ -102,7 +102,7 @@ def async_threshold_sensor_state_listener(event): try: self.sensor_value = ( None - if new_state.state in [STATE_UNKNOWN, STATE_UNAVAILABLE] + if new_state.state in (STATE_UNKNOWN, STATE_UNAVAILABLE) else float(new_state.state) ) except (ValueError, TypeError): diff --git a/homeassistant/components/universal/media_player.py b/homeassistant/components/universal/media_player.py index a2981852dc173b..2ad5ed60e311d4 100644 --- a/homeassistant/components/universal/media_player.py +++ b/homeassistant/components/universal/media_player.py @@ -323,7 +323,7 @@ def volume_level(self): @property def is_volume_muted(self): """Boolean if volume is muted.""" - return self._override_or_child_attr(ATTR_MEDIA_VOLUME_MUTED) in [True, STATE_ON] + return self._override_or_child_attr(ATTR_MEDIA_VOLUME_MUTED) in (True, STATE_ON) @property def media_content_id(self): diff --git a/homeassistant/components/utility_meter/sensor.py b/homeassistant/components/utility_meter/sensor.py index 509c0562f97800..75ee21029ec824 100644 --- a/homeassistant/components/utility_meter/sensor.py +++ b/homeassistant/components/utility_meter/sensor.py @@ -152,8 +152,8 @@ def async_reading(self, event): if ( old_state is None or new_state is None - or old_state.state in [STATE_UNKNOWN, STATE_UNAVAILABLE] - or new_state.state in [STATE_UNKNOWN, STATE_UNAVAILABLE] + or old_state.state in (STATE_UNKNOWN, STATE_UNAVAILABLE) + or new_state.state in (STATE_UNKNOWN, STATE_UNAVAILABLE) ): return @@ -268,7 +268,7 @@ async def async_added_to_hass(self): minute=self._period_offset.seconds // 60, second=self._period_offset.seconds % 60, ) - elif self._period in [DAILY, WEEKLY, MONTHLY, BIMONTHLY, QUARTERLY, YEARLY]: + elif self._period in (DAILY, WEEKLY, MONTHLY, BIMONTHLY, QUARTERLY, YEARLY): async_track_time_change( self.hass, self._async_reset_meter, diff --git a/homeassistant/components/vacuum/reproduce_state.py b/homeassistant/components/vacuum/reproduce_state.py index f8d718c99795e0..29639735a23ae8 100644 --- a/homeassistant/components/vacuum/reproduce_state.py +++ b/homeassistant/components/vacuum/reproduce_state.py @@ -78,7 +78,7 @@ async def _async_reproduce_state( service = SERVICE_TURN_OFF elif state.state == STATE_CLEANING: service = SERVICE_START - elif state.state in [STATE_DOCKED, STATE_RETURNING]: + elif state.state in (STATE_DOCKED, STATE_RETURNING): service = SERVICE_RETURN_TO_BASE elif state.state == STATE_IDLE: service = SERVICE_STOP diff --git a/homeassistant/components/version/sensor.py b/homeassistant/components/version/sensor.py index 04165ec9db1215..75252d24027b71 100644 --- a/homeassistant/components/version/sensor.py +++ b/homeassistant/components/version/sensor.py @@ -80,13 +80,13 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= haversion = VersionData( HaVersion(session, source=HaVersionSource.PYPI, channel=channel) ) - elif source in ["hassio", "supervisor"]: + elif source in ("hassio", "supervisor"): haversion = VersionData( HaVersion( session, source=HaVersionSource.SUPERVISOR, channel=channel, image=image ) ) - elif source in ["docker", "container"]: + elif source in ("docker", "container"): if image is not None and image != DEFAULT_IMAGE: image = f"{image}-homeassistant" haversion = VersionData( diff --git a/homeassistant/components/xiaomi_miio/fan.py b/homeassistant/components/xiaomi_miio/fan.py index c58d9ad0c6680d..602dce21735dbd 100644 --- a/homeassistant/components/xiaomi_miio/fan.py +++ b/homeassistant/components/xiaomi_miio/fan.py @@ -732,7 +732,7 @@ def __init__(self, name, device, entry, unique_id, allowed_failures=0): self._speed_count = 1 # the speed_list attribute is deprecated, support will end with release 2021.7 self._speed_list = OPERATION_MODES_AIRPURIFIER_PRO_V7 - elif self._model in [MODEL_AIRPURIFIER_2S, MODEL_AIRPURIFIER_2H]: + elif self._model in (MODEL_AIRPURIFIER_2S, MODEL_AIRPURIFIER_2H): self._device_features = FEATURE_FLAGS_AIRPURIFIER_2S self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_2S # SUPPORT_SET_SPEED was disabled diff --git a/homeassistant/components/xiaomi_miio/humidifier.py b/homeassistant/components/xiaomi_miio/humidifier.py index 9d9f49229d1779..cad60980a9da8c 100644 --- a/homeassistant/components/xiaomi_miio/humidifier.py +++ b/homeassistant/components/xiaomi_miio/humidifier.py @@ -170,7 +170,7 @@ class XiaomiAirHumidifier(XiaomiGenericHumidifier, HumidifierEntity): def __init__(self, name, device, entry, unique_id, coordinator): """Initialize the plug switch.""" super().__init__(name, device, entry, unique_id, coordinator) - if self._model in [MODEL_AIRHUMIDIFIER_CA1, MODEL_AIRHUMIDIFIER_CB1]: + if self._model in (MODEL_AIRHUMIDIFIER_CA1, MODEL_AIRHUMIDIFIER_CB1): self._available_modes = [] self._available_modes = [ mode.name @@ -180,7 +180,7 @@ def __init__(self, name, device, entry, unique_id, coordinator): self._min_humidity = 30 self._max_humidity = 80 self._humidity_steps = 10 - elif self._model in [MODEL_AIRHUMIDIFIER_CA4]: + elif self._model in (MODEL_AIRHUMIDIFIER_CA4,): self._available_modes = [ mode.name for mode in AirhumidifierMiotOperationMode ] diff --git a/homeassistant/components/xiaomi_miio/select.py b/homeassistant/components/xiaomi_miio/select.py index 055d8073739599..6772f8ba02da52 100644 --- a/homeassistant/components/xiaomi_miio/select.py +++ b/homeassistant/components/xiaomi_miio/select.py @@ -72,9 +72,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities): else: name = config_entry.title - if model in [MODEL_AIRHUMIDIFIER_CA1, MODEL_AIRHUMIDIFIER_CB1]: + if model in (MODEL_AIRHUMIDIFIER_CA1, MODEL_AIRHUMIDIFIER_CB1): entity_class = XiaomiAirHumidifierSelector - elif model in [MODEL_AIRHUMIDIFIER_CA4]: + elif model in (MODEL_AIRHUMIDIFIER_CA4,): entity_class = XiaomiAirHumidifierMiotSelector elif model in MODELS_HUMIDIFIER: entity_class = XiaomiAirHumidifierSelector diff --git a/homeassistant/components/xiaomi_miio/switch.py b/homeassistant/components/xiaomi_miio/switch.py index 35ac4c7da4f92b..3db27f3ac466b1 100644 --- a/homeassistant/components/xiaomi_miio/switch.py +++ b/homeassistant/components/xiaomi_miio/switch.py @@ -245,9 +245,9 @@ async def async_setup_coordinated_entry(hass, config_entry, async_add_entities): device_features = 0 - if model in [MODEL_AIRHUMIDIFIER_CA1, MODEL_AIRHUMIDIFIER_CB1]: + if model in (MODEL_AIRHUMIDIFIER_CA1, MODEL_AIRHUMIDIFIER_CB1): device_features = FEATURE_FLAGS_AIRHUMIDIFIER_CA_AND_CB - elif model in [MODEL_AIRHUMIDIFIER_CA4]: + elif model in (MODEL_AIRHUMIDIFIER_CA4,): device_features = FEATURE_FLAGS_AIRHUMIDIFIER_CA4 elif model in MODELS_HUMIDIFIER: device_features = FEATURE_FLAGS_AIRHUMIDIFIER @@ -304,7 +304,7 @@ async def async_setup_other_entry(hass, config_entry, async_add_entities): _LOGGER.debug("Initializing with host %s (token %s...)", host, token[:5]) - if model in ["chuangmi.plug.v1", "chuangmi.plug.v3", "chuangmi.plug.hmi208"]: + if model in ("chuangmi.plug.v1", "chuangmi.plug.v3", "chuangmi.plug.hmi208"): plug = ChuangmiPlug(host, token, model=model) # The device has two switchable channels (mains and a USB port). @@ -319,23 +319,23 @@ async def async_setup_other_entry(hass, config_entry, async_add_entities): ) entities.append(device) hass.data[DATA_KEY][host] = device - elif model in ["qmi.powerstrip.v1", "zimi.powerstrip.v2"]: + elif model in ("qmi.powerstrip.v1", "zimi.powerstrip.v2"): plug = PowerStrip(host, token, model=model) device = XiaomiPowerStripSwitch(name, plug, config_entry, unique_id) entities.append(device) hass.data[DATA_KEY][host] = device - elif model in [ + elif model in ( "chuangmi.plug.m1", "chuangmi.plug.m3", "chuangmi.plug.v2", "chuangmi.plug.hmi205", "chuangmi.plug.hmi206", - ]: + ): plug = ChuangmiPlug(host, token, model=model) device = XiaomiPlugGenericSwitch(name, plug, config_entry, unique_id) entities.append(device) hass.data[DATA_KEY][host] = device - elif model in ["lumi.acpartner.v3"]: + elif model in ("lumi.acpartner.v3",): plug = AirConditioningCompanionV3(host, token) device = XiaomiAirConditioningCompanionSwitch( name, plug, config_entry, unique_id @@ -586,7 +586,7 @@ async def _try_command(self, mask_error, func, *args, **kwargs): _LOGGER.debug("Response received from plug: %s", result) # The Chuangmi Plug V3 returns 0 on success on usb_on/usb_off. - if func in ["usb_on", "usb_off"] and result == 0: + if func in ("usb_on", "usb_off") and result == 0: return True return result == SUCCESS diff --git a/homeassistant/components/zwave/sensor.py b/homeassistant/components/zwave/sensor.py index d973e52ff92aeb..3df3794e341e78 100644 --- a/homeassistant/components/zwave/sensor.py +++ b/homeassistant/components/zwave/sensor.py @@ -82,7 +82,7 @@ def state(self): @property def device_class(self): """Return the class of this device.""" - if self._units in ["C", "F"]: + if self._units in ("C", "F"): return DEVICE_CLASS_TEMPERATURE return None diff --git a/homeassistant/core.py b/homeassistant/core.py index e24183215928f9..8389912ffdd40b 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -516,7 +516,7 @@ async def async_stop(self, exit_code: int = 0, *, force: bool = False) -> None: # regardless of the state of the loop. if self.state == CoreState.not_running: # just ignore return - if self.state in [CoreState.stopping, CoreState.final_write]: + if self.state in (CoreState.stopping, CoreState.final_write): _LOGGER.info("Additional call to async_stop was ignored") return if self.state == CoreState.starting: diff --git a/homeassistant/helpers/config_validation.py b/homeassistant/helpers/config_validation.py index 66d1c01d6d38df..331149f0627212 100644 --- a/homeassistant/helpers/config_validation.py +++ b/homeassistant/helpers/config_validation.py @@ -643,7 +643,7 @@ def url(value: Any) -> str: """Validate an URL.""" url_in = str(value) - if urlparse(url_in).scheme in ["http", "https"]: + if urlparse(url_in).scheme in ("http", "https"): return cast(str, vol.Schema(vol.Url())(url_in)) raise vol.Invalid("invalid url") diff --git a/homeassistant/helpers/script.py b/homeassistant/helpers/script.py index e5e8ef4fd52998..3857802f569105 100644 --- a/homeassistant/helpers/script.py +++ b/homeassistant/helpers/script.py @@ -727,7 +727,7 @@ async def async_run_sequence(iteration, extra_msg=""): try: if self._stop.is_set(): break - if self._test_conditions(conditions, "until") in [True, None]: + if self._test_conditions(conditions, "until") in (True, None): break except exceptions.ConditionError as ex: _LOGGER.warning("Error in 'until' evaluation:\n%s", ex)