Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace in-place sets with tuples #53686

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/broadlink/config_flow.py
Expand Up @@ -97,7 +97,7 @@ async def async_step_user(self, user_input=None):
err_msg = "Device not found"

except OSError as err:
if err.errno in {errno.EINVAL, socket.EAI_NONAME}:
if err.errno in (errno.EINVAL, socket.EAI_NONAME):
errors["base"] = "invalid_host"
err_msg = "Invalid hostname or IP address"
elif err.errno == errno.ENETUNREACH:
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/broadlink/switch.py
Expand Up @@ -109,7 +109,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Broadlink switch."""
device = hass.data[DOMAIN].devices[config_entry.entry_id]

if device.api.type in {"RM4MINI", "RM4PRO", "RMMINI", "RMMINIB", "RMPRO"}:
if device.api.type in ("RM4MINI", "RM4PRO", "RMMINI", "RMMINIB", "RMPRO"):
platform_data = hass.data[DOMAIN].platforms.get(SWITCH_DOMAIN, {})
user_defined_switches = platform_data.get(device.api.mac, {})
switches = [
Expand All @@ -119,7 +119,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
elif device.api.type == "SP1":
switches = [BroadlinkSP1Switch(device)]

elif device.api.type in {"SP2", "SP2S", "SP3", "SP3S", "SP4", "SP4B"}:
elif device.api.type in ("SP2", "SP2S", "SP3", "SP3S", "SP4", "SP4B"):
switches = [BroadlinkSP2Switch(device)]

elif device.api.type == "BG1":
Expand Down
20 changes: 10 additions & 10 deletions homeassistant/components/homekit_controller/climate.py
Expand Up @@ -400,8 +400,8 @@ def current_temperature(self):
def target_temperature(self):
"""Return the temperature we try to reach."""
value = self.service.value(CharacteristicsTypes.HEATING_COOLING_TARGET)
if (MODE_HOMEKIT_TO_HASS.get(value) in {HVAC_MODE_HEAT, HVAC_MODE_COOL}) or (
(MODE_HOMEKIT_TO_HASS.get(value) in {HVAC_MODE_HEAT_COOL})
if (MODE_HOMEKIT_TO_HASS.get(value) in (HVAC_MODE_HEAT, HVAC_MODE_COOL)) or (
(MODE_HOMEKIT_TO_HASS.get(value) in (HVAC_MODE_HEAT_COOL,))
and not (SUPPORT_TARGET_TEMPERATURE_RANGE & self.supported_features)
):
return self.service.value(CharacteristicsTypes.TEMPERATURE_TARGET)
Expand All @@ -411,7 +411,7 @@ def target_temperature(self):
def target_temperature_high(self):
"""Return the highbound target temperature we try to reach."""
value = self.service.value(CharacteristicsTypes.HEATING_COOLING_TARGET)
if (MODE_HOMEKIT_TO_HASS.get(value) in {HVAC_MODE_HEAT_COOL}) and (
if (MODE_HOMEKIT_TO_HASS.get(value) in (HVAC_MODE_HEAT_COOL,)) and (
SUPPORT_TARGET_TEMPERATURE_RANGE & self.supported_features
):
return self.service.value(
Expand All @@ -423,7 +423,7 @@ def target_temperature_high(self):
def target_temperature_low(self):
"""Return the lowbound target temperature we try to reach."""
value = self.service.value(CharacteristicsTypes.HEATING_COOLING_TARGET)
if (MODE_HOMEKIT_TO_HASS.get(value) in {HVAC_MODE_HEAT_COOL}) and (
if (MODE_HOMEKIT_TO_HASS.get(value) in (HVAC_MODE_HEAT_COOL,)) and (
SUPPORT_TARGET_TEMPERATURE_RANGE & self.supported_features
):
return self.service.value(
Expand All @@ -435,19 +435,19 @@ def target_temperature_low(self):
def min_temp(self):
"""Return the minimum target temp."""
value = self.service.value(CharacteristicsTypes.HEATING_COOLING_TARGET)
if (MODE_HOMEKIT_TO_HASS.get(value) in {HVAC_MODE_HEAT_COOL}) and (
if (MODE_HOMEKIT_TO_HASS.get(value) in (HVAC_MODE_HEAT_COOL,)) and (
SUPPORT_TARGET_TEMPERATURE_RANGE & self.supported_features
):
min_temp = self.service[
CharacteristicsTypes.TEMPERATURE_HEATING_THRESHOLD
].minValue
if min_temp is not None:
return min_temp
elif MODE_HOMEKIT_TO_HASS.get(value) in {
elif MODE_HOMEKIT_TO_HASS.get(value) in (
HVAC_MODE_HEAT,
HVAC_MODE_COOL,
HVAC_MODE_HEAT_COOL,
}:
):
min_temp = self.service[CharacteristicsTypes.TEMPERATURE_TARGET].minValue
if min_temp is not None:
return min_temp
Expand All @@ -457,19 +457,19 @@ def min_temp(self):
def max_temp(self):
"""Return the maximum target temp."""
value = self.service.value(CharacteristicsTypes.HEATING_COOLING_TARGET)
if (MODE_HOMEKIT_TO_HASS.get(value) in {HVAC_MODE_HEAT_COOL}) and (
if (MODE_HOMEKIT_TO_HASS.get(value) in (HVAC_MODE_HEAT_COOL,)) and (
SUPPORT_TARGET_TEMPERATURE_RANGE & self.supported_features
):
max_temp = self.service[
CharacteristicsTypes.TEMPERATURE_COOLING_THRESHOLD
].maxValue
if max_temp is not None:
return max_temp
elif MODE_HOMEKIT_TO_HASS.get(value) in {
elif MODE_HOMEKIT_TO_HASS.get(value) in (
HVAC_MODE_HEAT,
HVAC_MODE_COOL,
HVAC_MODE_HEAT_COOL,
}:
):
max_temp = self.service[CharacteristicsTypes.TEMPERATURE_TARGET].maxValue
if max_temp is not None:
return max_temp
Expand Down
7 changes: 1 addition & 6 deletions homeassistant/components/huawei_lte/device_tracker.py
Expand Up @@ -242,10 +242,5 @@ async def async_update(self) -> None:
self._extra_state_attributes = {
_better_snakecase(k): v
for k, v in host.items()
if k
in {
"AddressSource",
"AssociatedSsid",
"InterfaceType",
}
if k in ("AddressSource", "AssociatedSsid", "InterfaceType")
}
4 changes: 2 additions & 2 deletions homeassistant/components/lock/reproduce_state.py
Expand Up @@ -50,9 +50,9 @@ async def _async_reproduce_state(

service_data = {ATTR_ENTITY_ID: state.entity_id}

if state.state in {STATE_LOCKED, STATE_LOCKING}:
if state.state in (STATE_LOCKED, STATE_LOCKING):
service = SERVICE_LOCK
elif state.state in {STATE_UNLOCKED, STATE_UNLOCKING}:
elif state.state in (STATE_UNLOCKED, STATE_UNLOCKING):
service = SERVICE_UNLOCK

await hass.services.async_call(
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/netatmo/sensor.py
Expand Up @@ -507,11 +507,11 @@ def async_update_callback(self) -> None:

try:
state = data[self.entity_description.netatmo_name]
if self.entity_description.key in {"temperature", "pressure", "sum_rain_1"}:
if self.entity_description.key in ("temperature", "pressure", "sum_rain_1"):
self._attr_state = round(state, 1)
elif self.entity_description.key in {"windangle_value", "gustangle_value"}:
elif self.entity_description.key in ("windangle_value", "gustangle_value"):
self._attr_state = fix_angle(state)
elif self.entity_description.key in {"windangle", "gustangle"}:
elif self.entity_description.key in ("windangle", "gustangle"):
self._attr_state = process_angle(fix_angle(state))
elif self.entity_description.key == "rf_status":
self._attr_state = process_rf(state)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/stream/worker.py
Expand Up @@ -326,7 +326,7 @@ def stream_worker(
audio_stream = None
# These formats need aac_adtstoasc bitstream filter, but auto_bsf not
# compatible with empty_moov and manual bitstream filters not in PyAV
if container.format.name in {"hls", "mpegts"}:
if container.format.name in ("hls", "mpegts"):
audio_stream = None
# Some audio streams do not have a profile and throw errors when remuxing
if audio_stream and audio_stream.profile is None:
Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/tahoma/cover.py
Expand Up @@ -237,22 +237,22 @@ def stop_cover(self, **kwargs):
== "io:RollerShutterWithLowSpeedManagementIOComponent"
):
self.apply_action("setPosition", "secured")
elif self.tahoma_device.type in {
elif self.tahoma_device.type in (
"io:ExteriorVenetianBlindIOComponent",
"rts:BlindRTSComponent",
"rts:DualCurtainRTSComponent",
"rts:ExteriorVenetianBlindRTSComponent",
"rts:VenetianBlindRTSComponent",
}:
):
self.apply_action("my")
elif self.tahoma_device.type in {
elif self.tahoma_device.type in (
HORIZONTAL_AWNING,
"io:AwningValanceIOComponent",
"io:RollerShutterGenericIOComponent",
"io:VerticalExteriorAwningIOComponent",
"io:VerticalInteriorBlindVeluxIOComponent",
"io:WindowOpenerVeluxIOComponent",
}:
):
self.apply_action("stop")
else:
self.apply_action("stopIdentify")
2 changes: 1 addition & 1 deletion homeassistant/components/twitter/notify.py
Expand Up @@ -206,7 +206,7 @@ def check_status_until_done(self, media_id, callback, *args):

_LOGGER.debug("media processing %s status: %s", media_id, processing_info)

if processing_info["state"] in {"succeeded", "failed"}:
if processing_info["state"] in ("succeeded", "failed"):
return callback(media_id)

check_after_secs = processing_info["check_after_secs"]
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/withings/common.py
Expand Up @@ -887,14 +887,14 @@ def set_value(field: GetSleepSummaryField, func: Callable) -> None:
async def async_webhook_data_updated(self, data_category: NotifyAppli) -> None:
"""Handle scenario when data is updated from a webook."""
_LOGGER.debug("Withings webhook triggered")
if data_category in {
if data_category in (
NotifyAppli.WEIGHT,
NotifyAppli.CIRCULATORY,
NotifyAppli.SLEEP,
}:
):
await self.poll_data_update_coordinator.async_request_refresh()

elif data_category in {NotifyAppli.BED_IN, NotifyAppli.BED_OUT}:
elif data_category in (NotifyAppli.BED_IN, NotifyAppli.BED_OUT):
self.webhook_update_coordinator.update_data(
Measurement.IN_BED, data_category == NotifyAppli.BED_IN
)
Expand Down