Fix consider-using-tuple pylint warnings in core tests (#119463)

This commit is contained in:
epenet 2024-06-12 12:35:01 +02:00 committed by GitHub
parent 10b32e6a24
commit abb8c58b87
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
51 changed files with 128 additions and 128 deletions

View file

@ -174,7 +174,7 @@ async def test_get_actions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for action in ["disarm", "arm_away"] for action in ("disarm", "arm_away")
] ]
actions = await async_get_device_automations( actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id hass, DeviceAutomationType.ACTION, device_entry.id

View file

@ -167,7 +167,7 @@ async def test_get_conditions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for condition in ["is_disarmed", "is_triggered"] for condition in ("is_disarmed", "is_triggered")
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id

View file

@ -162,7 +162,7 @@ async def test_get_triggers_hidden_auxiliary(
"entity_id": entry.id, "entity_id": entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for trigger in ["triggered", "disarmed", "arming"] for trigger in ("triggered", "disarmed", "arming")
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id

View file

@ -122,7 +122,7 @@ async def test_get_conditions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for condition in ["is_on", "is_off"] for condition in ("is_on", "is_off")
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id

View file

@ -122,7 +122,7 @@ async def test_get_triggers_hidden_auxiliary(
"entity_id": entry.id, "entity_id": entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for trigger in ["turned_on", "turned_off"] for trigger in ("turned_on", "turned_off")
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id

View file

@ -88,7 +88,7 @@ async def test_get_actions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for action in ["press"] for action in ("press",)
] ]
actions = await async_get_device_automations( actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id hass, DeviceAutomationType.ACTION, device_entry.id

View file

@ -97,7 +97,7 @@ async def test_get_triggers_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for trigger in ["pressed"] for trigger in ("pressed",)
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id

View file

@ -86,13 +86,13 @@ async def async_set_temperature(
"""Set new target temperature.""" """Set new target temperature."""
kwargs = { kwargs = {
key: value key: value
for key, value in [ for key, value in (
(ATTR_TEMPERATURE, temperature), (ATTR_TEMPERATURE, temperature),
(ATTR_TARGET_TEMP_HIGH, target_temp_high), (ATTR_TARGET_TEMP_HIGH, target_temp_high),
(ATTR_TARGET_TEMP_LOW, target_temp_low), (ATTR_TARGET_TEMP_LOW, target_temp_low),
(ATTR_ENTITY_ID, entity_id), (ATTR_ENTITY_ID, entity_id),
(ATTR_HVAC_MODE, hvac_mode), (ATTR_HVAC_MODE, hvac_mode),
] )
if value is not None if value is not None
} }
_LOGGER.debug("set_temperature start data=%s", kwargs) _LOGGER.debug("set_temperature start data=%s", kwargs)
@ -113,13 +113,13 @@ def set_temperature(
"""Set new target temperature.""" """Set new target temperature."""
kwargs = { kwargs = {
key: value key: value
for key, value in [ for key, value in (
(ATTR_TEMPERATURE, temperature), (ATTR_TEMPERATURE, temperature),
(ATTR_TARGET_TEMP_HIGH, target_temp_high), (ATTR_TARGET_TEMP_HIGH, target_temp_high),
(ATTR_TARGET_TEMP_LOW, target_temp_low), (ATTR_TARGET_TEMP_LOW, target_temp_low),
(ATTR_ENTITY_ID, entity_id), (ATTR_ENTITY_ID, entity_id),
(ATTR_HVAC_MODE, hvac_mode), (ATTR_HVAC_MODE, hvac_mode),
] )
if value is not None if value is not None
} }
_LOGGER.debug("set_temperature start data=%s", kwargs) _LOGGER.debug("set_temperature start data=%s", kwargs)

View file

@ -136,7 +136,7 @@ async def test_get_actions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for action in ["set_hvac_mode"] for action in ("set_hvac_mode",)
] ]
actions = await async_get_device_automations( actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id hass, DeviceAutomationType.ACTION, device_entry.id

View file

@ -139,7 +139,7 @@ async def test_get_conditions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for condition in ["is_hvac_mode"] for condition in ("is_hvac_mode",)
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id

View file

@ -74,11 +74,11 @@ async def test_get_triggers(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for trigger in [ for trigger in (
"hvac_mode_changed", "hvac_mode_changed",
"current_temperature_changed", "current_temperature_changed",
"current_humidity_changed", "current_humidity_changed",
] )
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id
@ -135,11 +135,11 @@ async def test_get_triggers_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for trigger in [ for trigger in (
"hvac_mode_changed", "hvac_mode_changed",
"current_temperature_changed", "current_temperature_changed",
"current_humidity_changed", "current_humidity_changed",
] )
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id

View file

@ -136,7 +136,7 @@ async def test_get_actions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for action in ["close"] for action in ("close",)
] ]
actions = await async_get_device_automations( actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id hass, DeviceAutomationType.ACTION, device_entry.id

View file

@ -165,7 +165,7 @@ async def test_get_conditions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for condition in ["is_open", "is_closed", "is_opening", "is_closing"] for condition in ("is_open", "is_closed", "is_opening", "is_closing")
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id

View file

@ -166,7 +166,7 @@ async def test_get_triggers_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for trigger in ["opened", "closed", "opening", "closing"] for trigger in ("opened", "closed", "opening", "closing")
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id

View file

@ -54,7 +54,7 @@ async def test_get_conditions(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for condition in ["is_not_home", "is_home"] for condition in ("is_not_home", "is_home")
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id
@ -102,7 +102,7 @@ async def test_get_conditions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for condition in ["is_not_home", "is_home"] for condition in ("is_not_home", "is_home")
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id

View file

@ -85,7 +85,7 @@ async def test_get_triggers(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for trigger in ["leaves", "enters"] for trigger in ("leaves", "enters")
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id
@ -133,7 +133,7 @@ async def test_get_triggers_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for trigger in ["leaves", "enters"] for trigger in ("leaves", "enters")
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id

View file

@ -38,11 +38,11 @@ async def async_turn_on(
"""Turn all or specified fan on.""" """Turn all or specified fan on."""
data = { data = {
key: value key: value
for key, value in [ for key, value in (
(ATTR_ENTITY_ID, entity_id), (ATTR_ENTITY_ID, entity_id),
(ATTR_PERCENTAGE, percentage), (ATTR_PERCENTAGE, percentage),
(ATTR_PRESET_MODE, preset_mode), (ATTR_PRESET_MODE, preset_mode),
] )
if value is not None if value is not None
} }
@ -64,10 +64,10 @@ async def async_oscillate(
"""Set oscillation on all or specified fan.""" """Set oscillation on all or specified fan."""
data = { data = {
key: value key: value
for key, value in [ for key, value in (
(ATTR_ENTITY_ID, entity_id), (ATTR_ENTITY_ID, entity_id),
(ATTR_OSCILLATING, should_oscillate), (ATTR_OSCILLATING, should_oscillate),
] )
if value is not None if value is not None
} }
@ -81,7 +81,7 @@ async def async_set_preset_mode(
"""Set preset mode for all or specified fan.""" """Set preset mode for all or specified fan."""
data = { data = {
key: value key: value
for key, value in [(ATTR_ENTITY_ID, entity_id), (ATTR_PRESET_MODE, preset_mode)] for key, value in ((ATTR_ENTITY_ID, entity_id), (ATTR_PRESET_MODE, preset_mode))
if value is not None if value is not None
} }
@ -95,7 +95,7 @@ async def async_set_percentage(
"""Set percentage for all or specified fan.""" """Set percentage for all or specified fan."""
data = { data = {
key: value key: value
for key, value in [(ATTR_ENTITY_ID, entity_id), (ATTR_PERCENTAGE, percentage)] for key, value in ((ATTR_ENTITY_ID, entity_id), (ATTR_PERCENTAGE, percentage))
if value is not None if value is not None
} }
@ -109,10 +109,10 @@ async def async_increase_speed(
"""Increase speed for all or specified fan.""" """Increase speed for all or specified fan."""
data = { data = {
key: value key: value
for key, value in [ for key, value in (
(ATTR_ENTITY_ID, entity_id), (ATTR_ENTITY_ID, entity_id),
(ATTR_PERCENTAGE_STEP, percentage_step), (ATTR_PERCENTAGE_STEP, percentage_step),
] )
if value is not None if value is not None
} }
@ -126,10 +126,10 @@ async def async_decrease_speed(
"""Decrease speed for all or specified fan.""" """Decrease speed for all or specified fan."""
data = { data = {
key: value key: value
for key, value in [ for key, value in (
(ATTR_ENTITY_ID, entity_id), (ATTR_ENTITY_ID, entity_id),
(ATTR_PERCENTAGE_STEP, percentage_step), (ATTR_PERCENTAGE_STEP, percentage_step),
] )
if value is not None if value is not None
} }
@ -143,7 +143,7 @@ async def async_set_direction(
"""Set direction for all or specified fan.""" """Set direction for all or specified fan."""
data = { data = {
key: value key: value
for key, value in [(ATTR_ENTITY_ID, entity_id), (ATTR_DIRECTION, direction)] for key, value in ((ATTR_ENTITY_ID, entity_id), (ATTR_DIRECTION, direction))
if value is not None if value is not None
} }

View file

@ -48,7 +48,7 @@ async def test_get_actions(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for action in ["turn_on", "turn_off", "toggle"] for action in ("turn_on", "turn_off", "toggle")
] ]
actions = await async_get_device_automations( actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id hass, DeviceAutomationType.ACTION, device_entry.id
@ -96,7 +96,7 @@ async def test_get_actions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for action in ["turn_on", "turn_off", "toggle"] for action in ("turn_on", "turn_off", "toggle")
] ]
actions = await async_get_device_automations( actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id hass, DeviceAutomationType.ACTION, device_entry.id

View file

@ -54,7 +54,7 @@ async def test_get_conditions(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for condition in ["is_off", "is_on"] for condition in ("is_off", "is_on")
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id
@ -102,7 +102,7 @@ async def test_get_conditions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for condition in ["is_off", "is_on"] for condition in ("is_off", "is_on")
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id

View file

@ -59,7 +59,7 @@ async def test_get_triggers(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for trigger in ["turned_off", "turned_on", "changed_states"] for trigger in ("turned_off", "turned_on", "changed_states")
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id
@ -107,7 +107,7 @@ async def test_get_triggers_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for trigger in ["turned_off", "turned_on", "changed_states"] for trigger in ("turned_off", "turned_on", "changed_states")
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id

View file

@ -64,13 +64,13 @@ def async_set_group(
"""Create/Update a group.""" """Create/Update a group."""
data = { data = {
key: value key: value
for key, value in [ for key, value in (
(ATTR_OBJECT_ID, object_id), (ATTR_OBJECT_ID, object_id),
(ATTR_NAME, name), (ATTR_NAME, name),
(ATTR_ENTITIES, entity_ids), (ATTR_ENTITIES, entity_ids),
(ATTR_ICON, icon), (ATTR_ICON, icon),
(ATTR_ADD_ENTITIES, add), (ATTR_ADD_ENTITIES, add),
] )
if value is not None if value is not None
} }

View file

@ -1236,7 +1236,7 @@ async def test_group_mixed_domains_on(hass: HomeAssistant) -> None:
hass.states.async_set("binary_sensor.alexander_garage_side_door_open", "on") hass.states.async_set("binary_sensor.alexander_garage_side_door_open", "on")
hass.states.async_set("cover.small_garage_door", "open") hass.states.async_set("cover.small_garage_door", "open")
for domain in ["lock", "binary_sensor", "cover"]: for domain in ("lock", "binary_sensor", "cover"):
assert await async_setup_component(hass, domain, {}) assert await async_setup_component(hass, domain, {})
assert await async_setup_component( assert await async_setup_component(
hass, hass,
@ -1261,7 +1261,7 @@ async def test_group_mixed_domains_off(hass: HomeAssistant) -> None:
hass.states.async_set("binary_sensor.alexander_garage_side_door_open", "off") hass.states.async_set("binary_sensor.alexander_garage_side_door_open", "off")
hass.states.async_set("cover.small_garage_door", "closed") hass.states.async_set("cover.small_garage_door", "closed")
for domain in ["lock", "binary_sensor", "cover"]: for domain in ("lock", "binary_sensor", "cover"):
assert await async_setup_component(hass, domain, {}) assert await async_setup_component(hass, domain, {})
assert await async_setup_component( assert await async_setup_component(
hass, hass,

View file

@ -141,7 +141,7 @@ async def test_get_conditions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for condition in ["is_off", "is_on"] for condition in ("is_off", "is_on")
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id

View file

@ -101,7 +101,7 @@ async def async_turn_on(
"""Turn all or specified light on.""" """Turn all or specified light on."""
data = { data = {
key: value key: value
for key, value in [ for key, value in (
(ATTR_ENTITY_ID, entity_id), (ATTR_ENTITY_ID, entity_id),
(ATTR_PROFILE, profile), (ATTR_PROFILE, profile),
(ATTR_TRANSITION, transition), (ATTR_TRANSITION, transition),
@ -118,7 +118,7 @@ async def async_turn_on(
(ATTR_EFFECT, effect), (ATTR_EFFECT, effect),
(ATTR_COLOR_NAME, color_name), (ATTR_COLOR_NAME, color_name),
(ATTR_WHITE, white), (ATTR_WHITE, white),
] )
if value is not None if value is not None
} }
@ -135,11 +135,11 @@ async def async_turn_off(hass, entity_id=ENTITY_MATCH_ALL, transition=None, flas
"""Turn all or specified light off.""" """Turn all or specified light off."""
data = { data = {
key: value key: value
for key, value in [ for key, value in (
(ATTR_ENTITY_ID, entity_id), (ATTR_ENTITY_ID, entity_id),
(ATTR_TRANSITION, transition), (ATTR_TRANSITION, transition),
(ATTR_FLASH, flash), (ATTR_FLASH, flash),
] )
if value is not None if value is not None
} }
@ -202,7 +202,7 @@ async def async_toggle(
"""Turn all or specified light on.""" """Turn all or specified light on."""
data = { data = {
key: value key: value
for key, value in [ for key, value in (
(ATTR_ENTITY_ID, entity_id), (ATTR_ENTITY_ID, entity_id),
(ATTR_PROFILE, profile), (ATTR_PROFILE, profile),
(ATTR_TRANSITION, transition), (ATTR_TRANSITION, transition),
@ -216,7 +216,7 @@ async def async_toggle(
(ATTR_FLASH, flash), (ATTR_FLASH, flash),
(ATTR_EFFECT, effect), (ATTR_EFFECT, effect),
(ATTR_COLOR_NAME, color_name), (ATTR_COLOR_NAME, color_name),
] )
if value is not None if value is not None
} }

View file

@ -66,14 +66,14 @@ async def test_get_actions(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for action in [ for action in (
"brightness_decrease", "brightness_decrease",
"brightness_increase", "brightness_increase",
"flash", "flash",
"turn_off", "turn_off",
"turn_on", "turn_on",
"toggle", "toggle",
] )
] ]
actions = await async_get_device_automations( actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id hass, DeviceAutomationType.ACTION, device_entry.id
@ -123,7 +123,7 @@ async def test_get_actions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for action in ["turn_on", "turn_off", "toggle"] for action in ("turn_on", "turn_off", "toggle")
] ]
actions = await async_get_device_automations( actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id hass, DeviceAutomationType.ACTION, device_entry.id

View file

@ -62,7 +62,7 @@ async def test_get_conditions(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for condition in ["is_off", "is_on"] for condition in ("is_off", "is_on")
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id
@ -110,7 +110,7 @@ async def test_get_conditions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for condition in ["is_off", "is_on"] for condition in ("is_off", "is_on")
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id

View file

@ -67,7 +67,7 @@ async def test_get_triggers(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for trigger in ["changed_states", "turned_off", "turned_on"] for trigger in ("changed_states", "turned_off", "turned_on")
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id
@ -115,7 +115,7 @@ async def test_get_triggers_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for trigger in ["changed_states", "turned_off", "turned_on"] for trigger in ("changed_states", "turned_off", "turned_on")
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id

View file

@ -129,7 +129,7 @@ async def test_get_actions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for action in ["lock", "unlock"] for action in ("lock", "unlock")
] ]
actions = await async_get_device_automations( actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id hass, DeviceAutomationType.ACTION, device_entry.id

View file

@ -63,7 +63,7 @@ async def test_get_conditions(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for condition in [ for condition in (
"is_locked", "is_locked",
"is_unlocked", "is_unlocked",
"is_unlocking", "is_unlocking",
@ -71,7 +71,7 @@ async def test_get_conditions(
"is_jammed", "is_jammed",
"is_open", "is_open",
"is_opening", "is_opening",
] )
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id
@ -119,7 +119,7 @@ async def test_get_conditions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for condition in [ for condition in (
"is_locked", "is_locked",
"is_unlocked", "is_unlocked",
"is_unlocking", "is_unlocking",
@ -127,7 +127,7 @@ async def test_get_conditions_hidden_auxiliary(
"is_jammed", "is_jammed",
"is_open", "is_open",
"is_opening", "is_opening",
] )
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id

View file

@ -72,7 +72,7 @@ async def test_get_triggers(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for trigger in [ for trigger in (
"locked", "locked",
"unlocked", "unlocked",
"unlocking", "unlocking",
@ -80,7 +80,7 @@ async def test_get_triggers(
"jammed", "jammed",
"open", "open",
"opening", "opening",
] )
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id
@ -129,7 +129,7 @@ async def test_get_triggers_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for trigger in [ for trigger in (
"locked", "locked",
"unlocked", "unlocked",
"unlocking", "unlocking",
@ -137,7 +137,7 @@ async def test_get_triggers_hidden_auxiliary(
"jammed", "jammed",
"open", "open",
"opening", "opening",
] )
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id

View file

@ -53,7 +53,7 @@ async def test_get_actions(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for action in ["turn_off", "turn_on", "toggle"] for action in ("turn_off", "turn_on", "toggle")
] ]
actions = await async_get_device_automations( actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id hass, DeviceAutomationType.ACTION, device_entry.id
@ -101,7 +101,7 @@ async def test_get_actions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for action in ["turn_off", "turn_on", "toggle"] for action in ("turn_off", "turn_on", "toggle")
] ]
actions = await async_get_device_automations( actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id hass, DeviceAutomationType.ACTION, device_entry.id

View file

@ -59,7 +59,7 @@ async def test_get_conditions(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for condition in ["is_off", "is_on"] for condition in ("is_off", "is_on")
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id
@ -107,7 +107,7 @@ async def test_get_conditions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for condition in ["is_off", "is_on"] for condition in ("is_off", "is_on")
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id

View file

@ -59,7 +59,7 @@ async def test_get_triggers(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for trigger in ["changed_states", "turned_off", "turned_on"] for trigger in ("changed_states", "turned_off", "turned_on")
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id
@ -107,7 +107,7 @@ async def test_get_triggers_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for trigger in ["changed_states", "turned_off", "turned_on"] for trigger in ("changed_states", "turned_off", "turned_on")
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id

View file

@ -47,13 +47,13 @@ async def test_get_actions(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for action in [ for action in (
"select_first", "select_first",
"select_last", "select_last",
"select_next", "select_next",
"select_option", "select_option",
"select_previous", "select_previous",
] )
] ]
actions = await async_get_device_automations( actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id hass, DeviceAutomationType.ACTION, device_entry.id
@ -101,13 +101,13 @@ async def test_get_actions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for action in [ for action in (
"select_first", "select_first",
"select_last", "select_last",
"select_next", "select_next",
"select_option", "select_option",
"select_previous", "select_previous",
] )
] ]
actions = await async_get_device_automations( actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id hass, DeviceAutomationType.ACTION, device_entry.id

View file

@ -105,7 +105,7 @@ async def test_get_conditions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for condition in ["selected_option"] for condition in ("selected_option",)
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id

View file

@ -105,7 +105,7 @@ async def test_get_triggers_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for trigger in ["current_option_changed"] for trigger in ("current_option_changed",)
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id

View file

@ -171,7 +171,7 @@ async def test_get_conditions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for condition in ["is_value"] for condition in ("is_value",)
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id

View file

@ -173,7 +173,7 @@ async def test_get_triggers_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for trigger in ["value"] for trigger in ("value",)
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id

View file

@ -2413,7 +2413,7 @@ async def test_list_statistic_ids(
"unit_class": unit_class, "unit_class": unit_class,
}, },
] ]
for stat_type in ["mean", "sum", "dogs"]: for stat_type in ("mean", "sum", "dogs"):
statistic_ids = await async_list_statistic_ids(hass, statistic_type=stat_type) statistic_ids = await async_list_statistic_ids(hass, statistic_type=stat_type)
if statistic_type == stat_type: if statistic_type == stat_type:
assert statistic_ids == [ assert statistic_ids == [
@ -3887,12 +3887,12 @@ async def test_compile_statistics_hourly_daily_monthly_summary(
start = zero start = zero
end = zero + timedelta(minutes=5) end = zero + timedelta(minutes=5)
for i in range(24): for i in range(24):
for entity_id in [ for entity_id in (
"sensor.test1", "sensor.test1",
"sensor.test2", "sensor.test2",
"sensor.test3", "sensor.test3",
"sensor.test4", "sensor.test4",
]: ):
expected_average = ( expected_average = (
expected_averages[entity_id][i] expected_averages[entity_id][i]
if entity_id in expected_averages if entity_id in expected_averages
@ -3936,12 +3936,12 @@ async def test_compile_statistics_hourly_daily_monthly_summary(
start = zero start = zero
end = zero + timedelta(hours=1) end = zero + timedelta(hours=1)
for i in range(2): for i in range(2):
for entity_id in [ for entity_id in (
"sensor.test1", "sensor.test1",
"sensor.test2", "sensor.test2",
"sensor.test3", "sensor.test3",
"sensor.test4", "sensor.test4",
]: ):
expected_average = ( expected_average = (
mean(expected_averages[entity_id][i * 12 : (i + 1) * 12]) mean(expected_averages[entity_id][i * 12 : (i + 1) * 12])
if entity_id in expected_averages if entity_id in expected_averages
@ -3993,12 +3993,12 @@ async def test_compile_statistics_hourly_daily_monthly_summary(
start = dt_util.parse_datetime("2021-08-31T06:00:00+00:00") start = dt_util.parse_datetime("2021-08-31T06:00:00+00:00")
end = start + timedelta(days=1) end = start + timedelta(days=1)
for i in range(2): for i in range(2):
for entity_id in [ for entity_id in (
"sensor.test1", "sensor.test1",
"sensor.test2", "sensor.test2",
"sensor.test3", "sensor.test3",
"sensor.test4", "sensor.test4",
]: ):
expected_average = ( expected_average = (
mean(expected_averages[entity_id][i * 12 : (i + 1) * 12]) mean(expected_averages[entity_id][i * 12 : (i + 1) * 12])
if entity_id in expected_averages if entity_id in expected_averages
@ -4050,12 +4050,12 @@ async def test_compile_statistics_hourly_daily_monthly_summary(
start = dt_util.parse_datetime("2021-08-01T06:00:00+00:00") start = dt_util.parse_datetime("2021-08-01T06:00:00+00:00")
end = dt_util.parse_datetime("2021-09-01T06:00:00+00:00") end = dt_util.parse_datetime("2021-09-01T06:00:00+00:00")
for i in range(2): for i in range(2):
for entity_id in [ for entity_id in (
"sensor.test1", "sensor.test1",
"sensor.test2", "sensor.test2",
"sensor.test3", "sensor.test3",
"sensor.test4", "sensor.test4",
]: ):
expected_average = ( expected_average = (
mean(expected_averages[entity_id][i * 12 : (i + 1) * 12]) mean(expected_averages[entity_id][i * 12 : (i + 1) * 12])
if entity_id in expected_averages if entity_id in expected_averages

View file

@ -54,7 +54,7 @@ async def test_get_actions(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for action in ["turn_off", "turn_on", "toggle"] for action in ("turn_off", "turn_on", "toggle")
] ]
actions = await async_get_device_automations( actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id hass, DeviceAutomationType.ACTION, device_entry.id
@ -102,7 +102,7 @@ async def test_get_actions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for action in ["turn_off", "turn_on", "toggle"] for action in ("turn_off", "turn_on", "toggle")
] ]
actions = await async_get_device_automations( actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id hass, DeviceAutomationType.ACTION, device_entry.id

View file

@ -59,7 +59,7 @@ async def test_get_conditions(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for condition in ["is_off", "is_on"] for condition in ("is_off", "is_on")
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id
@ -107,7 +107,7 @@ async def test_get_conditions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for condition in ["is_off", "is_on"] for condition in ("is_off", "is_on")
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id

View file

@ -59,7 +59,7 @@ async def test_get_triggers(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for trigger in ["changed_states", "turned_off", "turned_on"] for trigger in ("changed_states", "turned_off", "turned_on")
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id
@ -107,7 +107,7 @@ async def test_get_triggers_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for trigger in ["changed_states", "turned_off", "turned_on"] for trigger in ("changed_states", "turned_off", "turned_on")
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id

View file

@ -47,7 +47,7 @@ async def test_get_actions(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for action in ["clean", "dock"] for action in ("clean", "dock")
] ]
actions = await async_get_device_automations( actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id hass, DeviceAutomationType.ACTION, device_entry.id
@ -95,7 +95,7 @@ async def test_get_actions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for action in ["clean", "dock"] for action in ("clean", "dock")
] ]
actions = await async_get_device_automations( actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id hass, DeviceAutomationType.ACTION, device_entry.id

View file

@ -59,7 +59,7 @@ async def test_get_conditions(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for condition in ["is_cleaning", "is_docked"] for condition in ("is_cleaning", "is_docked")
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id
@ -107,7 +107,7 @@ async def test_get_conditions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for condition in ["is_cleaning", "is_docked"] for condition in ("is_cleaning", "is_docked")
] ]
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id hass, DeviceAutomationType.CONDITION, device_entry.id

View file

@ -59,7 +59,7 @@ async def test_get_triggers(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for trigger in ["cleaning", "docked"] for trigger in ("cleaning", "docked")
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id
@ -107,7 +107,7 @@ async def test_get_triggers_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for trigger in ["cleaning", "docked"] for trigger in ("cleaning", "docked")
] ]
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id hass, DeviceAutomationType.TRIGGER, device_entry.id

View file

@ -35,11 +35,11 @@ async def async_set_temperature(
"""Set new target temperature.""" """Set new target temperature."""
kwargs = { kwargs = {
key: value key: value
for key, value in [ for key, value in (
(ATTR_TEMPERATURE, temperature), (ATTR_TEMPERATURE, temperature),
(ATTR_ENTITY_ID, entity_id), (ATTR_ENTITY_ID, entity_id),
(ATTR_OPERATION_MODE, operation_mode), (ATTR_OPERATION_MODE, operation_mode),
] )
if value is not None if value is not None
} }
_LOGGER.debug("set_temperature start data=%s", kwargs) _LOGGER.debug("set_temperature start data=%s", kwargs)

View file

@ -47,7 +47,7 @@ async def test_get_actions(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": False}, "metadata": {"secondary": False},
} }
for action in ["turn_on", "turn_off"] for action in ("turn_on", "turn_off")
] ]
actions = await async_get_device_automations( actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id hass, DeviceAutomationType.ACTION, device_entry.id
@ -95,7 +95,7 @@ async def test_get_actions_hidden_auxiliary(
"entity_id": entity_entry.id, "entity_id": entity_entry.id,
"metadata": {"secondary": True}, "metadata": {"secondary": True},
} }
for action in ["turn_on", "turn_off"] for action in ("turn_on", "turn_off")
] ]
actions = await async_get_device_automations( actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id hass, DeviceAutomationType.ACTION, device_entry.id

View file

@ -768,7 +768,7 @@ def test_date() -> None:
"""Test date validation.""" """Test date validation."""
schema = vol.Schema(cv.date) schema = vol.Schema(cv.date)
for value in ["Not a date", "23:42", "2016-11-23T18:59:08"]: for value in ("Not a date", "23:42", "2016-11-23T18:59:08"):
with pytest.raises(vol.Invalid): with pytest.raises(vol.Invalid):
schema(value) schema(value)
@ -780,7 +780,7 @@ def test_time() -> None:
"""Test date validation.""" """Test date validation."""
schema = vol.Schema(cv.time) schema = vol.Schema(cv.time)
for value in ["Not a time", "2016-11-23", "2016-11-23T18:59:08"]: for value in ("Not a time", "2016-11-23", "2016-11-23T18:59:08"):
with pytest.raises(vol.Invalid): with pytest.raises(vol.Invalid):
schema(value) schema(value)
@ -792,7 +792,7 @@ def test_time() -> None:
def test_datetime() -> None: def test_datetime() -> None:
"""Test date time validation.""" """Test date time validation."""
schema = vol.Schema(cv.datetime) schema = vol.Schema(cv.datetime)
for value in [date.today(), "Wrong DateTime"]: for value in (date.today(), "Wrong DateTime"):
with pytest.raises(vol.MultipleInvalid): with pytest.raises(vol.MultipleInvalid):
schema(value) schema(value)
@ -1307,7 +1307,7 @@ def test_uuid4_hex(caplog: pytest.LogCaptureFixture) -> None:
"""Test uuid validation.""" """Test uuid validation."""
schema = vol.Schema(cv.uuid4_hex) schema = vol.Schema(cv.uuid4_hex)
for value in ["Not a hex string", "0", 0]: for value in ("Not a hex string", "0", 0):
with pytest.raises(vol.Invalid): with pytest.raises(vol.Invalid):
schema(value) schema(value)

View file

@ -615,7 +615,7 @@ async def test_async_remove_with_platform_update_finishes(hass: HomeAssistant) -
# Add, remove, and make sure no updates # Add, remove, and make sure no updates
# cause the entity to reappear after removal and # cause the entity to reappear after removal and
# that we can add another entity with the same entity_id # that we can add another entity with the same entity_id
for entity in [entity1, entity2]: for entity in (entity1, entity2):
update_called = asyncio.Event() update_called = asyncio.Event()
update_done = asyncio.Event() update_done = asyncio.Event()
await component.async_add_entities([entity]) await component.async_add_entities([entity])

View file

@ -192,13 +192,13 @@ async def mock_non_adr_0007_integration_with_docs(hass: HomeAssistant) -> None:
async def mock_adr_0007_integrations(hass: HomeAssistant) -> list[Integration]: async def mock_adr_0007_integrations(hass: HomeAssistant) -> list[Integration]:
"""Mock ADR-0007 compliant integrations.""" """Mock ADR-0007 compliant integrations."""
integrations = [] integrations = []
for domain in [ for domain in (
"adr_0007_1", "adr_0007_1",
"adr_0007_2", "adr_0007_2",
"adr_0007_3", "adr_0007_3",
"adr_0007_4", "adr_0007_4",
"adr_0007_5", "adr_0007_5",
]: ):
adr_0007_config_schema = vol.Schema( adr_0007_config_schema = vol.Schema(
{ {
domain: vol.Schema( domain: vol.Schema(
@ -225,13 +225,13 @@ async def mock_adr_0007_integrations_with_docs(
) -> list[Integration]: ) -> list[Integration]:
"""Mock ADR-0007 compliant integrations.""" """Mock ADR-0007 compliant integrations."""
integrations = [] integrations = []
for domain in [ for domain in (
"adr_0007_1", "adr_0007_1",
"adr_0007_2", "adr_0007_2",
"adr_0007_3", "adr_0007_3",
"adr_0007_4", "adr_0007_4",
"adr_0007_5", "adr_0007_5",
]: ):
adr_0007_config_schema = vol.Schema( adr_0007_config_schema = vol.Schema(
{ {
domain: vol.Schema( domain: vol.Schema(
@ -293,10 +293,10 @@ async def mock_custom_validator_integrations(hass: HomeAssistant) -> list[Integr
Mock(async_validate_config=gen_async_validate_config(domain)), Mock(async_validate_config=gen_async_validate_config(domain)),
) )
for domain, exception in [ for domain, exception in (
("custom_validator_bad_1", HomeAssistantError("broken")), ("custom_validator_bad_1", HomeAssistantError("broken")),
("custom_validator_bad_2", ValueError("broken")), ("custom_validator_bad_2", ValueError("broken")),
]: ):
integrations.append(mock_integration(hass, MockModule(domain))) integrations.append(mock_integration(hass, MockModule(domain)))
mock_platform( mock_platform(
hass, hass,
@ -352,10 +352,10 @@ async def mock_custom_validator_integrations_with_docs(
Mock(async_validate_config=gen_async_validate_config(domain)), Mock(async_validate_config=gen_async_validate_config(domain)),
) )
for domain, exception in [ for domain, exception in (
("custom_validator_bad_1", HomeAssistantError("broken")), ("custom_validator_bad_1", HomeAssistantError("broken")),
("custom_validator_bad_2", ValueError("broken")), ("custom_validator_bad_2", ValueError("broken")),
]: ):
integrations.append( integrations.append(
mock_integration( mock_integration(
hass, hass,

View file

@ -2230,7 +2230,7 @@ async def test_async_run_job_starts_coro_eagerly(hass: HomeAssistant) -> None:
def test_valid_entity_id() -> None: def test_valid_entity_id() -> None:
"""Test valid entity ID.""" """Test valid entity ID."""
for invalid in [ for invalid in (
"_light.kitchen", "_light.kitchen",
".kitchen", ".kitchen",
".light.kitchen", ".light.kitchen",
@ -2243,10 +2243,10 @@ def test_valid_entity_id() -> None:
"Light.kitchen", "Light.kitchen",
"light.Kitchen", "light.Kitchen",
"lightkitchen", "lightkitchen",
]: ):
assert not ha.valid_entity_id(invalid), invalid assert not ha.valid_entity_id(invalid), invalid
for valid in [ for valid in (
"1.a", "1.a",
"1light.kitchen", "1light.kitchen",
"a.1", "a.1",
@ -2255,13 +2255,13 @@ def test_valid_entity_id() -> None:
"light.1kitchen", "light.1kitchen",
"light.kitchen", "light.kitchen",
"light.something_yoo", "light.something_yoo",
]: ):
assert ha.valid_entity_id(valid), valid assert ha.valid_entity_id(valid), valid
def test_valid_domain() -> None: def test_valid_domain() -> None:
"""Test valid domain.""" """Test valid domain."""
for invalid in [ for invalid in (
"_light", "_light",
".kitchen", ".kitchen",
".light.kitchen", ".light.kitchen",
@ -2272,16 +2272,16 @@ def test_valid_domain() -> None:
"light.kitchen_yo_", "light.kitchen_yo_",
"light.kitchen.", "light.kitchen.",
"Light", "Light",
]: ):
assert not ha.valid_domain(invalid), invalid assert not ha.valid_domain(invalid), invalid
for valid in [ for valid in (
"1", "1",
"1light", "1light",
"a", "a",
"input_boolean", "input_boolean",
"light", "light",
]: ):
assert ha.valid_domain(valid), valid assert ha.valid_domain(valid), valid