Upgrade pyupgrade to 2.21.2, apply its changes (#52987)

This commit is contained in:
Ville Skyttä 2021-07-19 11:46:09 +03:00 committed by GitHub
parent c96f01df1f
commit 470f2dd73f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
73 changed files with 152 additions and 162 deletions

View File

@ -1,6 +1,6 @@
repos: repos:
- repo: https://github.com/asottile/pyupgrade - repo: https://github.com/asottile/pyupgrade
rev: v2.16.0 rev: v2.21.2
hooks: hooks:
- id: pyupgrade - id: pyupgrade
args: [--py38-plus] args: [--py38-plus]

View File

@ -171,10 +171,10 @@ class Analytics:
ATTR_STATISTICS, False ATTR_STATISTICS, False
): ):
configured_integrations = await asyncio.gather( configured_integrations = await asyncio.gather(
*[ *(
async_get_integration(self.hass, domain) async_get_integration(self.hass, domain)
for domain in async_get_loaded_integrations(self.hass) for domain in async_get_loaded_integrations(self.hass)
], ),
return_exceptions=True, return_exceptions=True,
) )
@ -201,10 +201,10 @@ class Analytics:
if supervisor_info is not None: if supervisor_info is not None:
installed_addons = await asyncio.gather( installed_addons = await asyncio.gather(
*[ *(
hassio.async_get_addon_info(self.hass, addon[ATTR_SLUG]) hassio.async_get_addon_info(self.hass, addon[ATTR_SLUG])
for addon in supervisor_info[ATTR_ADDONS] for addon in supervisor_info[ATTR_ADDONS]
] )
) )
for addon in installed_addons: for addon in installed_addons:
addons.append( addons.append(

View File

@ -57,10 +57,10 @@ async def async_setup_entry(hass, entry):
async def setup_platforms(): async def setup_platforms():
"""Set up platforms and initiate connection.""" """Set up platforms and initiate connection."""
await asyncio.gather( await asyncio.gather(
*[ *(
hass.config_entries.async_forward_entry_setup(entry, platform) hass.config_entries.async_forward_entry_setup(entry, platform)
for platform in PLATFORMS for platform in PLATFORMS
] )
) )
await manager.init() await manager.init()

View File

@ -43,7 +43,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType):
async def _stop(_): async def _stop(_):
asyncio.gather( asyncio.gather(
*[_await_cancel(task) for task in hass.data[DOMAIN_DATA_TASKS].values()] *(_await_cancel(task) for task in hass.data[DOMAIN_DATA_TASKS].values())
) )
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _stop) hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _stop)

View File

@ -173,10 +173,10 @@ class AugustData(AugustSubscriberMixin):
async def _async_refresh_device_detail_by_ids(self, device_ids_list): async def _async_refresh_device_detail_by_ids(self, device_ids_list):
await asyncio.gather( await asyncio.gather(
*[ *(
self._async_refresh_device_detail_by_id(device_id) self._async_refresh_device_detail_by_id(device_id)
for device_id in device_ids_list for device_id in device_ids_list
] )
) )
async def _async_refresh_device_detail_by_id(self, device_id): async def _async_refresh_device_detail_by_id(self, device_id):

View File

@ -98,10 +98,10 @@ class ActivityStream(AugustSubscriberMixin):
async def _async_update_device_activities(self, time): async def _async_update_device_activities(self, time):
_LOGGER.debug("Start retrieving device activities") _LOGGER.debug("Start retrieving device activities")
await asyncio.gather( await asyncio.gather(
*[ *(
self._update_debounce[house_id].async_call() self._update_debounce[house_id].async_call()
for house_id in self._house_ids for house_id in self._house_ids
] )
) )
self._last_update_time = time self._last_update_time = time

View File

@ -75,10 +75,10 @@ async def async_validate_config_item(hass, config, full_config=None):
if CONF_CONDITION in config: if CONF_CONDITION in config:
config[CONF_CONDITION] = await asyncio.gather( config[CONF_CONDITION] = await asyncio.gather(
*[ *(
async_validate_condition_config(hass, cond) async_validate_condition_config(hass, cond)
for cond in config[CONF_CONDITION] for cond in config[CONF_CONDITION]
] )
) )
config[CONF_ACTION] = await script.async_validate_actions_config( config[CONF_ACTION] = await script.async_validate_actions_config(

View File

@ -64,7 +64,7 @@ class AwairDataUpdateCoordinator(DataUpdateCoordinator):
user = await self._awair.user() user = await self._awair.user()
devices = await user.devices() devices = await user.devices()
results = await gather( results = await gather(
*[self._fetch_air_data(device) for device in devices] *(self._fetch_air_data(device) for device in devices)
) )
return {result.device.uuid: result for result in results} return {result.device.uuid: result for result in results}
except AuthError as err: except AuthError as err:

View File

@ -226,12 +226,12 @@ class AxisNetworkDevice:
async def start_platforms(): async def start_platforms():
await asyncio.gather( await asyncio.gather(
*[ *(
self.hass.config_entries.async_forward_entry_setup( self.hass.config_entries.async_forward_entry_setup(
self.config_entry, platform self.config_entry, platform
) )
for platform in PLATFORMS for platform in PLATFORMS
] )
) )
if self.option_events: if self.option_events:
self.api.stream.connection_status_callback.append( self.api.stream.connection_status_callback.append(

View File

@ -223,10 +223,10 @@ class ClimaCellDataUpdateCoordinator(DataUpdateCoordinator):
CC_V3_ATTR_WIND_GUST, CC_V3_ATTR_WIND_GUST,
CC_V3_ATTR_CLOUD_COVER, CC_V3_ATTR_CLOUD_COVER,
CC_V3_ATTR_PRECIPITATION_TYPE, CC_V3_ATTR_PRECIPITATION_TYPE,
*[ *(
sensor_type[ATTR_FIELD] sensor_type[ATTR_FIELD]
for sensor_type in CC_V3_SENSOR_TYPES for sensor_type in CC_V3_SENSOR_TYPES
], ),
] ]
) )
data[FORECASTS][HOURLY] = await self._api.forecast_hourly( data[FORECASTS][HOURLY] = await self._api.forecast_hourly(
@ -283,7 +283,7 @@ class ClimaCellDataUpdateCoordinator(DataUpdateCoordinator):
CC_ATTR_WIND_GUST, CC_ATTR_WIND_GUST,
CC_ATTR_CLOUD_COVER, CC_ATTR_CLOUD_COVER,
CC_ATTR_PRECIPITATION_TYPE, CC_ATTR_PRECIPITATION_TYPE,
*[sensor_type[ATTR_FIELD] for sensor_type in CC_SENSOR_TYPES], *(sensor_type[ATTR_FIELD] for sensor_type in CC_SENSOR_TYPES),
], ],
[ [
CC_ATTR_TEMPERATURE_LOW, CC_ATTR_TEMPERATURE_LOW,

View File

@ -148,7 +148,7 @@ class CloudClient(Interface):
tasks.append(enable_google) tasks.append(enable_google)
if tasks: if tasks:
await asyncio.gather(*[task(None) for task in tasks]) await asyncio.gather(*(task(None) for task in tasks))
async def cleanups(self) -> None: async def cleanups(self) -> None:
"""Cleanup some stuff after logout.""" """Cleanup some stuff after logout."""

View File

@ -82,10 +82,10 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry.""" """Unload a config entry."""
unload = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) unload = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
await asyncio.gather( await asyncio.gather(
*[ *(
hass.async_add_executor_job(gateway.websocket_disconnect) hass.async_add_executor_job(gateway.websocket_disconnect)
for gateway in hass.data[DOMAIN][entry.entry_id]["gateways"] for gateway in hass.data[DOMAIN][entry.entry_id]["gateways"]
] )
) )
hass.data[DOMAIN][entry.entry_id]["listener"]() hass.data[DOMAIN][entry.entry_id]["listener"]()
hass.data[DOMAIN].pop(entry.entry_id) hass.data[DOMAIN].pop(entry.entry_id)

View File

@ -212,10 +212,10 @@ class AbstractConfig(ABC):
async def async_sync_entities_all(self): async def async_sync_entities_all(self):
"""Sync all entities to Google for all registered agents.""" """Sync all entities to Google for all registered agents."""
res = await gather( res = await gather(
*[ *(
self.async_sync_entities(agent_user_id) self.async_sync_entities(agent_user_id)
for agent_user_id in self._store.agent_user_ids for agent_user_id in self._store.agent_user_ids
] )
) )
return max(res, default=204) return max(res, default=204)

View File

@ -213,10 +213,10 @@ async def handle_devices_execute(hass, data, payload):
executions[entity_id] = [execution] executions[entity_id] = [execution]
execute_results = await asyncio.gather( execute_results = await asyncio.gather(
*[ *(
_entity_execute(entities[entity_id], data, execution) _entity_execute(entities[entity_id], data, execution)
for entity_id, execution in executions.items() for entity_id, execution in executions.items()
] )
) )
for entity_id, result in zip(executions, execute_results): for entity_id, result in zip(executions, execute_results):

View File

@ -140,10 +140,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def start_platforms(): async def start_platforms():
"""Continue setting up the platforms.""" """Continue setting up the platforms."""
await asyncio.gather( await asyncio.gather(
*[ *(
hass.config_entries.async_forward_entry_setup(entry, platform) hass.config_entries.async_forward_entry_setup(entry, platform)
for platform in PLATFORMS for platform in PLATFORMS
] )
) )
# Only refresh the coordinator after all platforms are loaded. # Only refresh the coordinator after all platforms are loaded.
await coordinator.async_refresh() await coordinator.async_refresh()

View File

@ -248,10 +248,10 @@ async def async_setup(hass: ha.HomeAssistant, config: dict) -> bool: # noqa: C9
if not reload_entries: if not reload_entries:
raise ValueError("There were no matching config entries to reload") raise ValueError("There were no matching config entries to reload")
await asyncio.gather( await asyncio.gather(
*[ *(
hass.config_entries.async_reload(config_entry_id) hass.config_entries.async_reload(config_entry_id)
for config_entry_id in reload_entries for config_entry_id in reload_entries
] )
) )
hass.helpers.service.async_register_admin_service( hass.helpers.service.async_register_admin_service(

View File

@ -228,10 +228,10 @@ async def async_setup(hass, config):
async def _async_stop_homekit_controller(event): async def _async_stop_homekit_controller(event):
await asyncio.gather( await asyncio.gather(
*[ *(
connection.async_unload() connection.async_unload()
for connection in hass.data[KNOWN_DEVICES].values() for connection in hass.data[KNOWN_DEVICES].values()
] )
) )
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _async_stop_homekit_controller) hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _async_stop_homekit_controller)

View File

@ -273,10 +273,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def setup_then_listen() -> None: async def setup_then_listen() -> None:
await asyncio.gather( await asyncio.gather(
*[ *(
hass.config_entries.async_forward_entry_setup(entry, platform) hass.config_entries.async_forward_entry_setup(entry, platform)
for platform in PLATFORMS for platform in PLATFORMS
] )
) )
assert hyperion_client assert hyperion_client
if hyperion_client.instances is not None: if hyperion_client.instances is not None:
@ -306,12 +306,12 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
# Disconnect the shared instance clients. # Disconnect the shared instance clients.
await asyncio.gather( await asyncio.gather(
*[ *(
config_data[CONF_INSTANCE_CLIENTS][ config_data[CONF_INSTANCE_CLIENTS][
instance_num instance_num
].async_client_disconnect() ].async_client_disconnect()
for instance_num in config_data[CONF_INSTANCE_CLIENTS] for instance_num in config_data[CONF_INSTANCE_CLIENTS]
] )
) )
# Disconnect the root client. # Disconnect the root client.

View File

@ -245,7 +245,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
await knx_module.xknx.stop() await knx_module.xknx.stop()
await asyncio.gather( await asyncio.gather(
*[platform.async_reset() for platform in async_get_platforms(hass, DOMAIN)] *(platform.async_reset() for platform in async_get_platforms(hass, DOMAIN))
) )
await async_setup(hass, config) await async_setup(hass, config)

View File

@ -71,7 +71,7 @@ async def build_item_response(media_library, payload, get_thumbnail_url=None):
return None return None
children = await asyncio.gather( children = await asyncio.gather(
*[item_payload(item, get_thumbnail_url) for item in media] *(item_payload(item, get_thumbnail_url) for item in media)
) )
if search_type in (MEDIA_TYPE_TVSHOW, MEDIA_TYPE_MOVIE) and search_id == "": if search_type in (MEDIA_TYPE_TVSHOW, MEDIA_TYPE_MOVIE) and search_id == "":
@ -209,7 +209,7 @@ async def library_payload():
} }
library_info.children = await asyncio.gather( library_info.children = await asyncio.gather(
*[ *(
item_payload( item_payload(
{ {
"label": item["label"], "label": item["label"],
@ -220,7 +220,7 @@ async def library_payload():
for item in [ for item in [
{"label": name, "type": type_} for type_, name in library.items() {"label": name, "type": type_} for type_, name in library.items()
] ]
] )
) )
return library_info return library_info

View File

@ -574,10 +574,10 @@ def _apply_event_types_filter(hass, query, event_types):
def _apply_event_entity_id_matchers(events_query, entity_ids): def _apply_event_entity_id_matchers(events_query, entity_ids):
return events_query.filter( return events_query.filter(
sqlalchemy.or_( sqlalchemy.or_(
*[ *(
Events.event_data.contains(ENTITY_ID_JSON_TEMPLATE.format(entity_id)) Events.event_data.contains(ENTITY_ID_JSON_TEMPLATE.format(entity_id))
for entity_id in entity_ids for entity_id in entity_ids
] )
) )
) )

View File

@ -22,10 +22,10 @@ async def system_health_info(hass):
health_info.update(await hass.data[DOMAIN]["resources"].async_get_info()) health_info.update(await hass.data[DOMAIN]["resources"].async_get_info())
dashboards_info = await asyncio.gather( dashboards_info = await asyncio.gather(
*[ *(
hass.data[DOMAIN]["dashboards"][dashboard].async_get_info() hass.data[DOMAIN]["dashboards"][dashboard].async_get_info()
for dashboard in hass.data[DOMAIN]["dashboards"] for dashboard in hass.data[DOMAIN]["dashboards"]
] )
) )
modes = set() modes = set()

View File

@ -352,10 +352,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def setup_then_listen() -> None: async def setup_then_listen() -> None:
await asyncio.gather( await asyncio.gather(
*[ *(
hass.config_entries.async_forward_entry_setup(entry, platform) hass.config_entries.async_forward_entry_setup(entry, platform)
for platform in PLATFORMS for platform in PLATFORMS
] )
) )
entry.async_on_unload( entry.async_on_unload(
coordinator.async_add_listener(_async_process_motioneye_cameras) coordinator.async_add_listener(_async_process_motioneye_cameras)

View File

@ -231,10 +231,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def finish() -> None: async def finish() -> None:
await asyncio.gather( await asyncio.gather(
*[ *(
hass.config_entries.async_forward_entry_setup(entry, platform) hass.config_entries.async_forward_entry_setup(entry, platform)
for platform in PLATFORMS_WITH_ENTRY_SUPPORT for platform in PLATFORMS_WITH_ENTRY_SUPPORT
] )
) )
await finish_setup(hass, entry, gateway) await finish_setup(hass, entry, gateway)

View File

@ -252,7 +252,7 @@ class NiluSensor(AirQualityEntity):
sensors = self._api.data.sensors.values() sensors = self._api.data.sensors.values()
if sensors: if sensors:
max_index = max([s.pollution_index for s in sensors]) max_index = max(s.pollution_index for s in sensors)
self._max_aqi = max_index self._max_aqi = max_index
self._attrs[ATTR_POLLUTION_INDEX] = POLLUTION_INDEX[self._max_aqi] self._attrs[ATTR_POLLUTION_INDEX] = POLLUTION_INDEX[self._max_aqi]

View File

@ -60,7 +60,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
password = config[DOMAIN].get(CONF_PASSWORD) password = config[DOMAIN].get(CONF_PASSWORD)
timeout = config[DOMAIN].get(CONF_TIMEOUT) timeout = config[DOMAIN].get(CONF_TIMEOUT)
auth_str = base64.b64encode(f"{user}:{password}".encode("utf-8")) auth_str = base64.b64encode(f"{user}:{password}".encode())
session = hass.helpers.aiohttp_client.async_get_clientsession() session = hass.helpers.aiohttp_client.async_get_clientsession()

View File

@ -53,10 +53,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Start platforms and cleanup devices.""" """Start platforms and cleanup devices."""
# wait until all required platforms are ready # wait until all required platforms are ready
await asyncio.gather( await asyncio.gather(
*[ *(
hass.config_entries.async_forward_entry_setup(entry, platform) hass.config_entries.async_forward_entry_setup(entry, platform)
for platform in PLATFORMS for platform in PLATFORMS
] )
) )
await cleanup_registry() await cleanup_registry()

View File

@ -264,10 +264,10 @@ async def async_setup_entry( # noqa: C901
async def start_platforms(): async def start_platforms():
await asyncio.gather( await asyncio.gather(
*[ *(
hass.config_entries.async_forward_entry_setup(entry, platform) hass.config_entries.async_forward_entry_setup(entry, platform)
for platform in PLATFORMS for platform in PLATFORMS
] )
) )
if entry.data.get(CONF_USE_ADDON): if entry.data.get(CONF_USE_ADDON):
mqtt_client_task = asyncio.create_task(mqtt_client.start_client(manager)) mqtt_client_task = asyncio.create_task(mqtt_client.start_client(manager))

View File

@ -102,14 +102,14 @@ async def async_setup_scanner(hass, config, async_see, discovery_info=None):
"""Update all the hosts on every interval time.""" """Update all the hosts on every interval time."""
results = await gather_with_concurrency( results = await gather_with_concurrency(
CONCURRENT_PING_LIMIT, CONCURRENT_PING_LIMIT,
*[hass.async_add_executor_job(host.update) for host in hosts], *(hass.async_add_executor_job(host.update) for host in hosts),
) )
await asyncio.gather( await asyncio.gather(
*[ *(
async_see(dev_id=host.dev_id, source_type=SOURCE_TYPE_ROUTER) async_see(dev_id=host.dev_id, source_type=SOURCE_TYPE_ROUTER)
for idx, host in enumerate(hosts) for idx, host in enumerate(hosts)
if results[idx] if results[idx]
] )
) )
else: else:
@ -124,11 +124,11 @@ async def async_setup_scanner(hass, config, async_see, discovery_info=None):
) )
_LOGGER.debug("Multiping responses: %s", responses) _LOGGER.debug("Multiping responses: %s", responses)
await asyncio.gather( await asyncio.gather(
*[ *(
async_see(dev_id=dev_id, source_type=SOURCE_TYPE_ROUTER) async_see(dev_id=dev_id, source_type=SOURCE_TYPE_ROUTER)
for idx, dev_id in enumerate(ip_to_dev_id.values()) for idx, dev_id in enumerate(ip_to_dev_id.values())
if responses[idx].is_alive if responses[idx].is_alive
] )
) )
async def _async_update_interval(now): async def _async_update_interval(now):

View File

@ -207,7 +207,7 @@ class RadarrSensor(SensorEntity):
filter(lambda x: x["path"] in self.included, res.json()) filter(lambda x: x["path"] in self.included, res.json())
) )
self._state = "{:.2f}".format( self._state = "{:.2f}".format(
to_unit(sum([data["freeSpace"] for data in self.data]), self._unit) to_unit(sum(data["freeSpace"] for data in self.data), self._unit)
) )
elif self.type == "status": elif self.type == "status":
self.data = res.json() self.data = res.json()

View File

@ -304,7 +304,7 @@ def _update_states_table_with_foreign_key_options(connection, engine):
states_key_constraints = Base.metadata.tables[TABLE_STATES].foreign_key_constraints states_key_constraints = Base.metadata.tables[TABLE_STATES].foreign_key_constraints
old_states_table = Table( # noqa: F841 pylint: disable=unused-variable old_states_table = Table( # noqa: F841 pylint: disable=unused-variable
TABLE_STATES, MetaData(), *[alter["old_fk"] for alter in alters] TABLE_STATES, MetaData(), *(alter["old_fk"] for alter in alters)
) )
for alter in alters: for alter in alters:

View File

@ -57,10 +57,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def start_platforms(): async def start_platforms():
await asyncio.gather( await asyncio.gather(
*[ *(
hass.config_entries.async_forward_entry_setup(entry, platform) hass.config_entries.async_forward_entry_setup(entry, platform)
for platform in PLATFORMS for platform in PLATFORMS
] )
) )
await events_coordinator.async_refresh() await events_coordinator.async_refresh()

View File

@ -71,10 +71,10 @@ async def async_validate_config_item(hass, config, full_config=None):
config = SCRIPT_ENTITY_SCHEMA(config) config = SCRIPT_ENTITY_SCHEMA(config)
config[CONF_SEQUENCE] = await asyncio.gather( config[CONF_SEQUENCE] = await asyncio.gather(
*[ *(
async_validate_action_config(hass, action) async_validate_action_config(hass, action)
for action in config[CONF_SEQUENCE] for action in config[CONF_SEQUENCE]
] )
) )
return config return config

View File

@ -69,7 +69,7 @@ class SharkIqUpdateCoordinator(DataUpdateCoordinator):
_LOGGER.debug("Updating sharkiq data") _LOGGER.debug("Updating sharkiq data")
online_vacs = (self.shark_vacs[dsn] for dsn in self.online_dsns) online_vacs = (self.shark_vacs[dsn] for dsn in self.online_dsns)
await asyncio.gather(*[self._async_update_vacuum(v) for v in online_vacs]) await asyncio.gather(*(self._async_update_vacuum(v) for v in online_vacs))
except ( except (
SharkIqAuthError, SharkIqAuthError,
SharkIqNotAuthedError, SharkIqNotAuthedError,

View File

@ -162,7 +162,7 @@ class SonarrDiskspaceSensor(SonarrSensor):
"""Update entity.""" """Update entity."""
app = await self.sonarr.update() app = await self.sonarr.update()
self._disks = app.disks self._disks = app.disks
self._total_free = sum([disk.free for disk in self._disks]) self._total_free = sum(disk.free for disk in self._disks)
@property @property
def extra_state_attributes(self) -> dict[str, Any] | None: def extra_state_attributes(self) -> dict[str, Any] | None:

View File

@ -172,7 +172,7 @@ class SonosDiscoveryManager:
async def _async_stop_event_listener(self, event: Event) -> None: async def _async_stop_event_listener(self, event: Event) -> None:
await asyncio.gather( await asyncio.gather(
*[speaker.async_unsubscribe() for speaker in self.data.discovered.values()], *(speaker.async_unsubscribe() for speaker in self.data.discovered.values()),
return_exceptions=True, return_exceptions=True,
) )
if events_asyncio.event_listener: if events_asyncio.event_listener:
@ -285,10 +285,10 @@ class SonosDiscoveryManager:
async def setup_platforms_and_discovery(self): async def setup_platforms_and_discovery(self):
"""Set up platforms and discovery.""" """Set up platforms and discovery."""
await asyncio.gather( await asyncio.gather(
*[ *(
self.hass.config_entries.async_forward_entry_setup(self.entry, platform) self.hass.config_entries.async_forward_entry_setup(self.entry, platform)
for platform in PLATFORMS for platform in PLATFORMS
] )
) )
self.entry.async_on_unload( self.entry.async_on_unload(
self.hass.bus.async_listen_once( self.hass.bus.async_listen_once(

View File

@ -352,7 +352,7 @@ class SonosSpeaker:
"""Cancel all subscriptions.""" """Cancel all subscriptions."""
_LOGGER.debug("Unsubscribing from events for %s", self.zone_name) _LOGGER.debug("Unsubscribing from events for %s", self.zone_name)
await asyncio.gather( await asyncio.gather(
*[subscription.unsubscribe() for subscription in self._subscriptions], *(subscription.unsubscribe() for subscription in self._subscriptions),
return_exceptions=True, return_exceptions=True,
) )
self._subscriptions = [] self._subscriptions = []

View File

@ -257,7 +257,7 @@ class Scanner:
EVENT_HOMEASSISTANT_STARTED, self.flow_dispatcher.async_start EVENT_HOMEASSISTANT_STARTED, self.flow_dispatcher.async_start
) )
await asyncio.gather( await asyncio.gather(
*[listener.async_start() for listener in self._ssdp_listeners] *(listener.async_start() for listener in self._ssdp_listeners)
) )
self._cancel_scan = async_track_time_interval( self._cancel_scan = async_track_time_interval(
self.hass, self.async_scan, SCAN_INTERVAL self.hass, self.async_scan, SCAN_INTERVAL

View File

@ -48,10 +48,10 @@ async def async_setup_entry(
BridgeCpuSpeedSensor(coordinator, bridge), BridgeCpuSpeedSensor(coordinator, bridge),
BridgeCpuTemperatureSensor(coordinator, bridge), BridgeCpuTemperatureSensor(coordinator, bridge),
BridgeCpuVoltageSensor(coordinator, bridge), BridgeCpuVoltageSensor(coordinator, bridge),
*[ *(
BridgeFilesystemSensor(coordinator, bridge, key) BridgeFilesystemSensor(coordinator, bridge, key)
for key, _ in bridge.filesystem.fsSize.items() for key, _ in bridge.filesystem.fsSize.items()
], ),
BridgeMemoryFreeSensor(coordinator, bridge), BridgeMemoryFreeSensor(coordinator, bridge),
BridgeMemoryUsedSensor(coordinator, bridge), BridgeMemoryUsedSensor(coordinator, bridge),
BridgeMemoryUsedPercentageSensor(coordinator, bridge), BridgeMemoryUsedPercentageSensor(coordinator, bridge),

View File

@ -96,10 +96,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def start_platforms() -> None: async def start_platforms() -> None:
await device_automation.async_setup_entry(hass, entry) await device_automation.async_setup_entry(hass, entry)
await asyncio.gather( await asyncio.gather(
*[ *(
hass.config_entries.async_forward_entry_setup(entry, platform) hass.config_entries.async_forward_entry_setup(entry, platform)
for platform in PLATFORMS for platform in PLATFORMS
] )
) )
discovery_prefix = entry.data[CONF_DISCOVERY_PREFIX] discovery_prefix = entry.data[CONF_DISCOVERY_PREFIX]

View File

@ -159,10 +159,10 @@ class VizioOptionsConfigFlow(config_entries.OptionsFlow):
): cv.multi_select( ): cv.multi_select(
[ [
APP_HOME["name"], APP_HOME["name"],
*[ *(
app["name"] app["name"]
for app in self.hass.data[DOMAIN][CONF_APPS].data for app in self.hass.data[DOMAIN][CONF_APPS].data
], ),
] ]
), ),
} }

View File

@ -381,17 +381,17 @@ class VizioDevice(MediaPlayerEntity):
# show the combination with , otherwise just return inputs # show the combination with , otherwise just return inputs
if self._available_apps: if self._available_apps:
return [ return [
*[ *(
_input _input
for _input in self._available_inputs for _input in self._available_inputs
if _input not in INPUT_APPS if _input not in INPUT_APPS
], ),
*self._available_apps, *self._available_apps,
*[ *(
app app
for app in self._get_additional_app_names() for app in self._get_additional_app_names()
if app not in self._available_apps if app not in self._available_apps
], ),
] ]
return self._available_inputs return self._available_inputs

View File

@ -268,7 +268,7 @@ async def handle_manifest_list(
"""Handle integrations command.""" """Handle integrations command."""
loaded_integrations = async_get_loaded_integrations(hass) loaded_integrations = async_get_loaded_integrations(hass)
integrations = await asyncio.gather( integrations = await asyncio.gather(
*[async_get_integration(hass, domain) for domain in loaded_integrations] *(async_get_integration(hass, domain) for domain in loaded_integrations)
) )
connection.send_result( connection.send_result(
msg["id"], [integration.manifest for integration in integrations] msg["id"], [integration.manifest for integration in integrations]

View File

@ -235,12 +235,12 @@ class WemoDiscovery:
_LOGGER.debug("Adding statically configured WeMo devices") _LOGGER.debug("Adding statically configured WeMo devices")
for device in await gather_with_concurrency( for device in await gather_with_concurrency(
MAX_CONCURRENCY, MAX_CONCURRENCY,
*[ *(
self._hass.async_add_executor_job( self._hass.async_add_executor_job(
validate_static_config, host, port validate_static_config, host, port
) )
for host, port in self._static_config for host, port in self._static_config
], ),
): ):
if device: if device:
await self._wemo_dispatcher.async_add_unique_device( await self._wemo_dispatcher.async_add_unique_device(

View File

@ -21,10 +21,10 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_dispatcher_connect(hass, f"{WEMO_DOMAIN}.binary_sensor", _discovered_wemo) async_dispatcher_connect(hass, f"{WEMO_DOMAIN}.binary_sensor", _discovered_wemo)
await asyncio.gather( await asyncio.gather(
*[ *(
_discovered_wemo(device) _discovered_wemo(device)
for device in hass.data[WEMO_DOMAIN]["pending"].pop("binary_sensor") for device in hass.data[WEMO_DOMAIN]["pending"].pop("binary_sensor")
] )
) )

View File

@ -75,10 +75,10 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_dispatcher_connect(hass, f"{WEMO_DOMAIN}.fan", _discovered_wemo) async_dispatcher_connect(hass, f"{WEMO_DOMAIN}.fan", _discovered_wemo)
await asyncio.gather( await asyncio.gather(
*[ *(
_discovered_wemo(device) _discovered_wemo(device)
for device in hass.data[WEMO_DOMAIN]["pending"].pop("fan") for device in hass.data[WEMO_DOMAIN]["pending"].pop("fan")
] )
) )
platform = entity_platform.async_get_current_platform() platform = entity_platform.async_get_current_platform()

View File

@ -50,10 +50,10 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_dispatcher_connect(hass, f"{WEMO_DOMAIN}.light", _discovered_wemo) async_dispatcher_connect(hass, f"{WEMO_DOMAIN}.light", _discovered_wemo)
await asyncio.gather( await asyncio.gather(
*[ *(
_discovered_wemo(device) _discovered_wemo(device)
for device in hass.data[WEMO_DOMAIN]["pending"].pop("light") for device in hass.data[WEMO_DOMAIN]["pending"].pop("light")
] )
) )

View File

@ -40,10 +40,10 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_dispatcher_connect(hass, f"{WEMO_DOMAIN}.switch", _discovered_wemo) async_dispatcher_connect(hass, f"{WEMO_DOMAIN}.switch", _discovered_wemo)
await asyncio.gather( await asyncio.gather(
*[ *(
_discovered_wemo(device) _discovered_wemo(device)
for device in hass.data[WEMO_DOMAIN]["pending"].pop("switch") for device in hass.data[WEMO_DOMAIN]["pending"].pop("switch")
] )
) )

View File

@ -673,21 +673,17 @@ class DataManager:
response = await self._hass.async_add_executor_job(self._api.notify_list) response = await self._hass.async_add_executor_job(self._api.notify_list)
subscribed_applis = frozenset( subscribed_applis = frozenset(
[ profile.appli
profile.appli for profile in response.profiles
for profile in response.profiles if profile.callbackurl == self._webhook_config.url
if profile.callbackurl == self._webhook_config.url
]
) )
# Determine what subscriptions need to be created. # Determine what subscriptions need to be created.
ignored_applis = frozenset({NotifyAppli.USER, NotifyAppli.UNKNOWN}) ignored_applis = frozenset({NotifyAppli.USER, NotifyAppli.UNKNOWN})
to_add_applis = frozenset( to_add_applis = frozenset(
[ appli
appli for appli in NotifyAppli
for appli in NotifyAppli if appli not in subscribed_applis and appli not in ignored_applis
if appli not in subscribed_applis and appli not in ignored_applis
]
) )
# Subscribe to each one. # Subscribe to each one.

View File

@ -509,10 +509,8 @@ class MusicCastMediaPlayer(MusicCastDeviceEntity, MediaPlayerEntity):
def get_distribution_num(self) -> int: def get_distribution_num(self) -> int:
"""Return the distribution_num (number of clients in the whole musiccast system).""" """Return the distribution_num (number of clients in the whole musiccast system)."""
return sum( return sum(
[ len(server.coordinator.data.group_client_list)
len(server.coordinator.data.group_client_list) for server in self.get_all_server_entities()
for server in self.get_all_server_entities()
]
) )
def is_part_of_group(self, group_server) -> bool: def is_part_of_group(self, group_server) -> bool:

View File

@ -145,10 +145,10 @@ async def async_unload_entry(hass, config_entry):
# our components don't have unload methods so no need to look at return values # our components don't have unload methods so no need to look at return values
await asyncio.gather( await asyncio.gather(
*[ *(
hass.config_entries.async_forward_entry_unload(config_entry, platform) hass.config_entries.async_forward_entry_unload(config_entry, platform)
for platform in PLATFORMS for platform in PLATFORMS
] )
) )
hass.data[DATA_ZHA][DATA_ZHA_SHUTDOWN_TASK]() hass.data[DATA_ZHA][DATA_ZHA_SHUTDOWN_TASK]()

View File

@ -217,20 +217,20 @@ class ZHAGateway:
_LOGGER.debug("Loading battery powered devices") _LOGGER.debug("Loading battery powered devices")
await asyncio.gather( await asyncio.gather(
*[ *(
_throttle(dev, cached=True) _throttle(dev, cached=True)
for dev in self.devices.values() for dev in self.devices.values()
if not dev.is_mains_powered if not dev.is_mains_powered
] )
) )
_LOGGER.debug("Loading mains powered devices") _LOGGER.debug("Loading mains powered devices")
await asyncio.gather( await asyncio.gather(
*[ *(
_throttle(dev, cached=False) _throttle(dev, cached=False)
for dev in self.devices.values() for dev in self.devices.values()
if dev.is_mains_powered if dev.is_mains_powered
] )
) )
def device_joined(self, device): def device_joined(self, device):

View File

@ -419,7 +419,7 @@ class Light(BaseLight, ZhaEntity):
self.async_accept_signal( self.async_accept_signal(
self._level_channel, SIGNAL_SET_LEVEL, self.set_level self._level_channel, SIGNAL_SET_LEVEL, self.set_level
) )
refresh_interval = random.randint(*[x * 60 for x in self._REFRESH_INTERVAL]) refresh_interval = random.randint(*(x * 60 for x in self._REFRESH_INTERVAL))
self._cancel_refresh_handle = async_track_time_interval( self._cancel_refresh_handle = async_track_time_interval(
self.hass, self._refresh, timedelta(seconds=refresh_interval) self.hass, self._refresh, timedelta(seconds=refresh_interval)
) )

View File

@ -426,10 +426,10 @@ async def async_setup_entry( # noqa: C901
# run discovery on all ready nodes # run discovery on all ready nodes
await asyncio.gather( await asyncio.gather(
*[ *(
async_on_node_added(node) async_on_node_added(node)
for node in client.driver.controller.nodes.values() for node in client.driver.controller.nodes.values()
] )
) )
# listen for new nodes being added to the mesh # listen for new nodes being added to the mesh

View File

@ -447,4 +447,4 @@ class ZWaveServices:
async def async_ping(self, service: ServiceCall) -> None: async def async_ping(self, service: ServiceCall) -> None:
"""Ping node(s).""" """Ping node(s)."""
nodes: set[ZwaveNode] = service.data[const.ATTR_NODES] nodes: set[ZwaveNode] = service.data[const.ATTR_NODES]
await asyncio.gather(*[node.async_ping() for node in nodes]) await asyncio.gather(*(node.async_ping() for node in nodes))

View File

@ -850,7 +850,7 @@ class ConfigEntries:
async def _async_shutdown(self, event: Event) -> None: async def _async_shutdown(self, event: Event) -> None:
"""Call when Home Assistant is stopping.""" """Call when Home Assistant is stopping."""
await asyncio.gather( await asyncio.gather(
*[entry.async_shutdown() for entry in self._entries.values()] *(entry.async_shutdown() for entry in self._entries.values())
) )
await self.flow.async_shutdown() await self.flow.async_shutdown()
@ -1082,10 +1082,10 @@ class ConfigEntries:
"""Forward the unloading of an entry to platforms.""" """Forward the unloading of an entry to platforms."""
return all( return all(
await asyncio.gather( await asyncio.gather(
*[ *(
self.async_forward_entry_unload(entry, platform) self.async_forward_entry_unload(entry, platform)
for platform in platforms for platform in platforms
] )
) )
) )
@ -1506,7 +1506,7 @@ class EntityRegistryDisabledHandler:
) )
await asyncio.gather( await asyncio.gather(
*[self.hass.config_entries.async_reload(entry_id) for entry_id in to_reload] *(self.hass.config_entries.async_reload(entry_id) for entry_id in to_reload)
) )

View File

@ -139,15 +139,15 @@ class ObservableCollection(ABC):
async def notify_changes(self, change_sets: Iterable[CollectionChangeSet]) -> None: async def notify_changes(self, change_sets: Iterable[CollectionChangeSet]) -> None:
"""Notify listeners of a change.""" """Notify listeners of a change."""
await asyncio.gather( await asyncio.gather(
*[ *(
listener(change_set.change_type, change_set.item_id, change_set.item) listener(change_set.change_type, change_set.item_id, change_set.item)
for listener in self.listeners for listener in self.listeners
for change_set in change_sets for change_set in change_sets
], ),
*[ *(
change_set_listener(change_sets) change_set_listener(change_sets)
for change_set_listener in self.change_set_listeners for change_set_listener in self.change_set_listeners
], ),
) )
@ -368,10 +368,10 @@ def sync_entity_lifecycle(
new_entities = [ new_entities = [
entity entity
for entity in await asyncio.gather( for entity in await asyncio.gather(
*[ *(
_func_map[change_set.change_type](change_set) _func_map[change_set.change_type](change_set)
for change_set in grouped for change_set in grouped
] )
) )
if entity is not None if entity is not None
] ]

View File

@ -331,5 +331,5 @@ class EntityComponent:
async def _async_shutdown(self, event: Event) -> None: async def _async_shutdown(self, event: Event) -> None:
"""Call when Home Assistant is stopping.""" """Call when Home Assistant is stopping."""
await asyncio.gather( await asyncio.gather(
*[platform.async_shutdown() for platform in chain(self._platforms.values())] *(platform.async_shutdown() for platform in chain(self._platforms.values()))
) )

View File

@ -239,7 +239,7 @@ async def async_validate_actions_config(
) -> list[ConfigType]: ) -> list[ConfigType]:
"""Validate a list of actions.""" """Validate a list of actions."""
return await asyncio.gather( return await asyncio.gather(
*[async_validate_action_config(hass, action) for action in actions] *(async_validate_action_config(hass, action) for action in actions)
) )
@ -880,10 +880,10 @@ async def _async_stop_scripts_after_shutdown(hass, point_in_time):
names = ", ".join([script["instance"].name for script in running_scripts]) names = ", ".join([script["instance"].name for script in running_scripts])
_LOGGER.warning("Stopping scripts running too long after shutdown: %s", names) _LOGGER.warning("Stopping scripts running too long after shutdown: %s", names)
await asyncio.gather( await asyncio.gather(
*[ *(
script["instance"].async_stop(update_state=False) script["instance"].async_stop(update_state=False)
for script in running_scripts for script in running_scripts
] )
) )
@ -902,7 +902,7 @@ async def _async_stop_scripts_at_shutdown(hass, event):
names = ", ".join([script["instance"].name for script in running_scripts]) names = ", ".join([script["instance"].name for script in running_scripts])
_LOGGER.debug("Stopping scripts running at shutdown: %s", names) _LOGGER.debug("Stopping scripts running at shutdown: %s", names)
await asyncio.gather( await asyncio.gather(
*[script["instance"].async_stop() for script in running_scripts] *(script["instance"].async_stop() for script in running_scripts)
) )

View File

@ -155,7 +155,7 @@ async def async_get_component_strings(
domains, domains,
await gather_with_concurrency( await gather_with_concurrency(
MAX_LOAD_CONCURRENTLY, MAX_LOAD_CONCURRENTLY,
*[async_get_integration(hass, domain) for domain in domains], *(async_get_integration(hass, domain) for domain in domains),
), ),
) )
) )
@ -234,10 +234,10 @@ class _TranslationCache:
# Fetch the English resources, as a fallback for missing keys # Fetch the English resources, as a fallback for missing keys
languages = [LOCALE_EN] if language == LOCALE_EN else [LOCALE_EN, language] languages = [LOCALE_EN] if language == LOCALE_EN else [LOCALE_EN, language]
for translation_strings in await asyncio.gather( for translation_strings in await asyncio.gather(
*[ *(
async_get_component_strings(self.hass, lang, components) async_get_component_strings(self.hass, lang, components)
for lang in languages for lang in languages
] )
): ):
self._build_category_cache(language, components, translation_strings) self._build_category_cache(language, components, translation_strings)

View File

@ -118,10 +118,10 @@ async def _async_process_integration(
return return
results = await asyncio.gather( results = await asyncio.gather(
*[ *(
async_get_integration_with_requirements(hass, dep, done) async_get_integration_with_requirements(hass, dep, done)
for dep in deps_to_check for dep in deps_to_check
], ),
return_exceptions=True, return_exceptions=True,
) )
for result in results: for result in results:

View File

@ -280,10 +280,10 @@ async def _async_setup_component(
await hass.config_entries.flow.async_wait_init_flow_finish(domain) await hass.config_entries.flow.async_wait_init_flow_finish(domain)
await asyncio.gather( await asyncio.gather(
*[ *(
entry.async_setup(hass, integration=integration) entry.async_setup(hass, integration=integration)
for entry in hass.config_entries.async_entries(domain) for entry in hass.config_entries.async_entries(domain)
] )
) )
hass.config.components.add(domain) hass.config.components.add(domain)

View File

@ -12,5 +12,5 @@ mccabe==0.6.1
pycodestyle==2.7.0 pycodestyle==2.7.0
pydocstyle==6.0.0 pydocstyle==6.0.0
pyflakes==2.3.1 pyflakes==2.3.1
pyupgrade==2.16.0 pyupgrade==2.21.2
yamllint==1.26.1 yamllint==1.26.1

View File

@ -199,9 +199,9 @@ async def test_sound_mode(player, state, mode, mode_sel, mode_2ch, mode_mch):
async def test_sound_mode_list(player, state): async def test_sound_mode_list(player, state):
"""Test sound mode list.""" """Test sound mode list."""
player._get_2ch = Mock(return_value=True) # pylint: disable=W0212 player._get_2ch = Mock(return_value=True) # pylint: disable=W0212
assert sorted(player.sound_mode_list) == sorted([x.name for x in DecodeMode2CH]) assert sorted(player.sound_mode_list) == sorted(x.name for x in DecodeMode2CH)
player._get_2ch = Mock(return_value=False) # pylint: disable=W0212 player._get_2ch = Mock(return_value=False) # pylint: disable=W0212
assert sorted(player.sound_mode_list) == sorted([x.name for x in DecodeModeMCH]) assert sorted(player.sound_mode_list) == sorted(x.name for x in DecodeModeMCH)
async def test_sound_mode_zone_x(player, state): async def test_sound_mode_zone_x(player, state):

View File

@ -42,7 +42,7 @@ async def test_list_devices(hass, client, registry):
await client.send_json({"id": 5, "type": "config/device_registry/list"}) await client.send_json({"id": 5, "type": "config/device_registry/list"})
msg = await client.receive_json() msg = await client.receive_json()
dev1, dev2 = [entry.pop("id") for entry in msg["result"]] dev1, dev2 = (entry.pop("id") for entry in msg["result"])
assert msg["result"] == [ assert msg["result"] == [
{ {

View File

@ -134,8 +134,8 @@ async def test_sync_request(hass_fixture, assistant_client, auth_header):
body = await result.json() body = await result.json()
assert body.get("requestId") == reqid assert body.get("requestId") == reqid
devices = body["payload"]["devices"] devices = body["payload"]["devices"]
assert sorted([dev["id"] for dev in devices]) == sorted( assert sorted(dev["id"] for dev in devices) == sorted(
[dev["id"] for dev in DEMO_DEVICES] dev["id"] for dev in DEMO_DEVICES
) )
for dev in devices: for dev in devices:

View File

@ -223,9 +223,7 @@ async def test_report_state_all(agents):
data = {} data = {}
with patch.object(config, "async_report_state") as mock: with patch.object(config, "async_report_state") as mock:
await config.async_report_state_all(data) await config.async_report_state_all(data)
assert sorted(mock.mock_calls) == sorted( assert sorted(mock.mock_calls) == sorted(call(data, agent) for agent in agents)
[call(data, agent) for agent in agents]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -241,7 +239,7 @@ async def test_sync_entities_all(agents, result):
side_effect=lambda agent_user_id: agents[agent_user_id], side_effect=lambda agent_user_id: agents[agent_user_id],
) as mock: ) as mock:
res = await config.async_sync_entities_all() res = await config.async_sync_entities_all()
assert sorted(mock.mock_calls) == sorted([call(agent) for agent in agents]) assert sorted(mock.mock_calls) == sorted(call(agent) for agent in agents)
assert res == result assert res == result

View File

@ -74,7 +74,7 @@ async def test_get_triggers(hass, mock_bridge, device_reg):
} }
expected_triggers = [ expected_triggers = [
trigger_batt, trigger_batt,
*[ *(
{ {
"platform": "device", "platform": "device",
"domain": hue.DOMAIN, "domain": hue.DOMAIN,
@ -83,7 +83,7 @@ async def test_get_triggers(hass, mock_bridge, device_reg):
"subtype": t_subtype, "subtype": t_subtype,
} }
for t_type, t_subtype in device_trigger.HUE_DIMMER_REMOTE.keys() for t_type, t_subtype in device_trigger.HUE_DIMMER_REMOTE.keys()
], ),
] ]
assert_lists_same(triggers, expected_triggers) assert_lists_same(triggers, expected_triggers)

View File

@ -187,7 +187,7 @@ async def test_onboarding_user(hass, hass_storage, aiohttp_client):
# Validate created areas # Validate created areas
area_registry = ar.async_get(hass) area_registry = ar.async_get(hass)
assert len(area_registry.areas) == 3 assert len(area_registry.areas) == 3
assert sorted([area.name for area in area_registry.async_list_areas()]) == [ assert sorted(area.name for area in area_registry.async_list_areas()) == [
"Bedroom", "Bedroom",
"Kitchen", "Kitchen",
"Living Room", "Living Room",

View File

@ -292,11 +292,9 @@ def get_config_entries_for_user_id(
) -> tuple[ConfigEntry]: ) -> tuple[ConfigEntry]:
"""Get a list of config entries that apply to a specific withings user.""" """Get a list of config entries that apply to a specific withings user."""
return tuple( return tuple(
[ config_entry
config_entry for config_entry in hass.config_entries.async_entries(const.DOMAIN)
for config_entry in hass.config_entries.async_entries(const.DOMAIN) if config_entry.data.get("token", {}).get("userid") == user_id
if config_entry.data.get("token", {}).get("userid") == user_id
]
) )

View File

@ -266,7 +266,7 @@ async def test_discover_endpoint(device_info, channels_mock, hass):
) )
assert device_info["event_channels"] == sorted( assert device_info["event_channels"] == sorted(
[ch.id for pool in channels.pools for ch in pool.client_channels.values()] ch.id for pool in channels.pools for ch in pool.client_channels.values()
) )
assert new_ent.call_count == len( assert new_ent.call_count == len(
[ [

View File

@ -315,9 +315,9 @@ def test_event_eq():
now = dt_util.utcnow() now = dt_util.utcnow()
data = {"some": "attr"} data = {"some": "attr"}
context = ha.Context() context = ha.Context()
event1, event2 = [ event1, event2 = (
ha.Event("some_type", data, time_fired=now, context=context) for _ in range(2) ha.Event("some_type", data, time_fired=now, context=context) for _ in range(2)
] )
assert event1 == event2 assert event1 == event2

View File

@ -165,7 +165,7 @@ async def test_gather_with_concurrency():
return runs return runs
results = await hasync.gather_with_concurrency( results = await hasync.gather_with_concurrency(
2, *[_increment_runs_if_in_time() for i in range(4)] 2, *(_increment_runs_if_in_time() for i in range(4))
) )
assert results == [2, 2, -1, -1] assert results == [2, 2, -1, -1]