diff --git a/homeassistant/__main__.py b/homeassistant/__main__.py index 4ed80c27bf0..0c0d535753c 100644 --- a/homeassistant/__main__.py +++ b/homeassistant/__main__.py @@ -146,9 +146,7 @@ def get_arguments() -> argparse.Namespace: help="Skips validation of operating system", ) - arguments = parser.parse_args() - - return arguments + return parser.parse_args() def check_threads() -> None: diff --git a/homeassistant/components/accuweather/diagnostics.py b/homeassistant/components/accuweather/diagnostics.py index e7bc41eaaf2..c4f04b209cf 100644 --- a/homeassistant/components/accuweather/diagnostics.py +++ b/homeassistant/components/accuweather/diagnostics.py @@ -23,9 +23,7 @@ async def async_get_config_entry_diagnostics( config_entry.entry_id ] - diagnostics_data = { + return { "config_entry_data": async_redact_data(dict(config_entry.data), TO_REDACT), "coordinator_data": coordinator.data, } - - return diagnostics_data diff --git a/homeassistant/components/airly/diagnostics.py b/homeassistant/components/airly/diagnostics.py index 1d63fbc8277..d21d126c60e 100644 --- a/homeassistant/components/airly/diagnostics.py +++ b/homeassistant/components/airly/diagnostics.py @@ -26,9 +26,7 @@ async def async_get_config_entry_diagnostics( """Return diagnostics for a config entry.""" coordinator: AirlyDataUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id] - diagnostics_data = { + return { "config_entry": async_redact_data(config_entry.as_dict(), TO_REDACT), "coordinator_data": coordinator.data, } - - return diagnostics_data diff --git a/homeassistant/components/aladdin_connect/diagnostics.py b/homeassistant/components/aladdin_connect/diagnostics.py index b838ff79da3..67a31079f14 100644 --- a/homeassistant/components/aladdin_connect/diagnostics.py +++ b/homeassistant/components/aladdin_connect/diagnostics.py @@ -23,8 +23,6 @@ async def async_get_config_entry_diagnostics( acc: AladdinConnectClient = hass.data[DOMAIN][config_entry.entry_id] - diagnostics_data = { + return { "doors": async_redact_data(acc.doors, TO_REDACT), } - - return diagnostics_data diff --git a/homeassistant/components/alexa/capabilities.py b/homeassistant/components/alexa/capabilities.py index ecb7d5cb5a8..bc9b482109f 100644 --- a/homeassistant/components/alexa/capabilities.py +++ b/homeassistant/components/alexa/capabilities.py @@ -1764,10 +1764,7 @@ class AlexaRangeController(AlexaCapability): speed_list = self.entity.attributes.get(vacuum.ATTR_FAN_SPEED_LIST) speed = self.entity.attributes.get(vacuum.ATTR_FAN_SPEED) if speed_list is not None and speed is not None: - speed_index = next( - (i for i, v in enumerate(speed_list) if v == speed), None - ) - return speed_index + return next((i for i, v in enumerate(speed_list) if v == speed), None) # Valve Position if self.instance == f"{valve.DOMAIN}.{valve.ATTR_POSITION}": diff --git a/homeassistant/components/amcrest/__init__.py b/homeassistant/components/amcrest/__init__.py index cb6abff3f89..c12aa6d7916 100644 --- a/homeassistant/components/amcrest/__init__.py +++ b/homeassistant/components/amcrest/__init__.py @@ -203,8 +203,7 @@ class AmcrestChecker(ApiWrapper): async def async_command(self, *args: Any, **kwargs: Any) -> httpx.Response: """amcrest.ApiWrapper.command wrapper to catch errors.""" async with self._async_command_wrapper(): - ret = await super().async_command(*args, **kwargs) - return ret + return await super().async_command(*args, **kwargs) @asynccontextmanager async def async_stream_command( diff --git a/homeassistant/components/aprilaire/climate.py b/homeassistant/components/aprilaire/climate.py index 96c1e1ac981..2876d621aef 100644 --- a/homeassistant/components/aprilaire/climate.py +++ b/homeassistant/components/aprilaire/climate.py @@ -107,9 +107,7 @@ class AprilaireClimate(BaseAprilaireEntity, ClimateEntity): features = features | ClimateEntityFeature.PRESET_MODE - features = features | ClimateEntityFeature.FAN_MODE - - return features + return features | ClimateEntityFeature.FAN_MODE @property def current_humidity(self) -> int | None: diff --git a/homeassistant/components/arcam_fmj/media_player.py b/homeassistant/components/arcam_fmj/media_player.py index ac8d389304b..ca08a2b4d16 100644 --- a/homeassistant/components/arcam_fmj/media_player.py +++ b/homeassistant/components/arcam_fmj/media_player.py @@ -257,7 +257,7 @@ class ArcamFmj(MediaPlayerEntity): for preset in presets.values() ] - root = BrowseMedia( + return BrowseMedia( title="Arcam FMJ Receiver", media_class=MediaClass.DIRECTORY, media_content_id="root", @@ -267,8 +267,6 @@ class ArcamFmj(MediaPlayerEntity): children=radio, ) - return root - @convert_exception async def async_play_media( self, media_type: MediaType | str, media_id: str, **kwargs: Any diff --git a/homeassistant/components/arris_tg2492lg/device_tracker.py b/homeassistant/components/arris_tg2492lg/device_tracker.py index f9485636365..4f674a13c0e 100644 --- a/homeassistant/components/arris_tg2492lg/device_tracker.py +++ b/homeassistant/components/arris_tg2492lg/device_tracker.py @@ -49,11 +49,10 @@ class ArrisDeviceScanner(DeviceScanner): def get_device_name(self, device: str) -> str | None: """Return the name of the given device or None if we don't know.""" - name = next( + return next( (result.hostname for result in self.last_results if result.mac == device), None, ) - return name def _update_info(self) -> None: """Ensure the information from the Arris TG2492LG router is up to date.""" diff --git a/homeassistant/components/asuswrt/bridge.py b/homeassistant/components/asuswrt/bridge.py index 35f3a98251f..f255a3faad4 100644 --- a/homeassistant/components/asuswrt/bridge.py +++ b/homeassistant/components/asuswrt/bridge.py @@ -254,7 +254,7 @@ class AsusWrtLegacyBridge(AsusWrtBridge): async def async_get_available_sensors(self) -> dict[str, dict[str, Any]]: """Return a dictionary of available sensors for this bridge.""" sensors_temperatures = await self._get_available_temperature_sensors() - sensors_types = { + return { SENSORS_TYPE_BYTES: { KEY_SENSORS: SENSORS_BYTES, KEY_METHOD: self._get_bytes, @@ -272,7 +272,6 @@ class AsusWrtLegacyBridge(AsusWrtBridge): KEY_METHOD: self._get_temperatures, }, } - return sensors_types async def _get_available_temperature_sensors(self) -> list[str]: """Check which temperature information is available on the router.""" @@ -351,7 +350,7 @@ class AsusWrtHttpBridge(AsusWrtBridge): """Return a dictionary of available sensors for this bridge.""" sensors_temperatures = await self._get_available_temperature_sensors() sensors_loadavg = await self._get_loadavg_sensors_availability() - sensors_types = { + return { SENSORS_TYPE_BYTES: { KEY_SENSORS: SENSORS_BYTES, KEY_METHOD: self._get_bytes, @@ -369,7 +368,6 @@ class AsusWrtHttpBridge(AsusWrtBridge): KEY_METHOD: self._get_temperatures, }, } - return sensors_types async def _get_available_temperature_sensors(self) -> list[str]: """Check which temperature information is available on the router.""" diff --git a/homeassistant/components/auth/mfa_setup_flow.py b/homeassistant/components/auth/mfa_setup_flow.py index aee08186267..aaa1dbaedbf 100644 --- a/homeassistant/components/auth/mfa_setup_flow.py +++ b/homeassistant/components/auth/mfa_setup_flow.py @@ -147,8 +147,7 @@ def _prepare_result_json( ) -> data_entry_flow.FlowResult: """Convert result to JSON.""" if result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY: - data = result.copy() - return data + return result.copy() if result["type"] != data_entry_flow.FlowResultType.FORM: return result diff --git a/homeassistant/components/bluesound/media_player.py b/homeassistant/components/bluesound/media_player.py index 9377557d025..cb6f013dbf8 100644 --- a/homeassistant/components/bluesound/media_player.py +++ b/homeassistant/components/bluesound/media_player.py @@ -863,8 +863,6 @@ class BluesoundPlayer(MediaPlayerEntity): if self._group_name is None: return None - bluesound_group = [] - device_group = self._group_name.split("+") sorted_entities = sorted( @@ -872,14 +870,12 @@ class BluesoundPlayer(MediaPlayerEntity): key=lambda entity: entity.is_master, reverse=True, ) - bluesound_group = [ + return [ entity.name for entity in sorted_entities if entity.bluesound_device_name in device_group ] - return bluesound_group - async def async_unjoin(self): """Unjoin the player from a group.""" if self._master is None: diff --git a/homeassistant/components/braviatv/diagnostics.py b/homeassistant/components/braviatv/diagnostics.py index 917572ffcca..b74a8a3ebdb 100644 --- a/homeassistant/components/braviatv/diagnostics.py +++ b/homeassistant/components/braviatv/diagnostics.py @@ -21,9 +21,7 @@ async def async_get_config_entry_diagnostics( device_info = await coordinator.client.get_system_info() - diagnostics_data = { + return { "config_entry": async_redact_data(config_entry.as_dict(), TO_REDACT), "device_info": async_redact_data(device_info, TO_REDACT), } - - return diagnostics_data diff --git a/homeassistant/components/brother/diagnostics.py b/homeassistant/components/brother/diagnostics.py index a4afb385f8d..ee5eedd84cb 100644 --- a/homeassistant/components/brother/diagnostics.py +++ b/homeassistant/components/brother/diagnostics.py @@ -20,11 +20,9 @@ async def async_get_config_entry_diagnostics( config_entry.entry_id ] - diagnostics_data = { + return { "info": dict(config_entry.data), "data": asdict(coordinator.data), "model": coordinator.brother.model, "firmware": coordinator.brother.firmware, } - - return diagnostics_data diff --git a/homeassistant/components/canary/__init__.py b/homeassistant/components/canary/__init__.py index 60ce50484d8..f879c308a88 100644 --- a/homeassistant/components/canary/__init__.py +++ b/homeassistant/components/canary/__init__.py @@ -140,10 +140,8 @@ async def _async_update_listener(hass: HomeAssistant, entry: ConfigEntry) -> Non def _get_canary_api_instance(entry: ConfigEntry) -> Api: """Initialize a new instance of CanaryApi.""" - canary = Api( + return Api( entry.data[CONF_USERNAME], entry.data[CONF_PASSWORD], entry.options.get(CONF_TIMEOUT, DEFAULT_TIMEOUT), ) - - return canary diff --git a/homeassistant/components/channels/media_player.py b/homeassistant/components/channels/media_player.py index 002ec8d4efb..2b8fc4a2b3e 100644 --- a/homeassistant/components/channels/media_player.py +++ b/homeassistant/components/channels/media_player.py @@ -167,8 +167,7 @@ class ChannelsPlayer(MediaPlayerEntity): @property def source_list(self): """List of favorite channels.""" - sources = [channel["name"] for channel in self.favorite_channels] - return sources + return [channel["name"] for channel in self.favorite_channels] @property def is_volume_muted(self): diff --git a/homeassistant/components/cisco_mobility_express/device_tracker.py b/homeassistant/components/cisco_mobility_express/device_tracker.py index c156f43942e..d96ab54a68f 100644 --- a/homeassistant/components/cisco_mobility_express/device_tracker.py +++ b/homeassistant/components/cisco_mobility_express/device_tracker.py @@ -72,11 +72,10 @@ class CiscoMEDeviceScanner(DeviceScanner): def get_device_name(self, device): """Return the name of the given device or None if we don't know.""" - name = next( + return next( (result.clId for result in self.last_results if result.macaddr == device), None, ) - return name def get_extra_attributes(self, device): """Get extra attributes of a device. diff --git a/homeassistant/components/cloud/__init__.py b/homeassistant/components/cloud/__init__.py index 80c2e86a2a3..d85415cf9eb 100644 --- a/homeassistant/components/cloud/__init__.py +++ b/homeassistant/components/cloud/__init__.py @@ -396,6 +396,4 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" - unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) - - return unload_ok + return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) diff --git a/homeassistant/components/cloud/account_link.py b/homeassistant/components/cloud/account_link.py index df2789663c0..784de14e6ad 100644 --- a/homeassistant/components/cloud/account_link.py +++ b/homeassistant/components/cloud/account_link.py @@ -65,7 +65,7 @@ async def _get_services(hass: HomeAssistant) -> list[dict[str, Any]]: services: list[dict[str, Any]] if DATA_SERVICES in hass.data: services = hass.data[DATA_SERVICES] - return services + return services # noqa: RET504 try: services = await account_link.async_fetch_available_services(hass.data[DOMAIN]) diff --git a/homeassistant/components/coinbase/config_flow.py b/homeassistant/components/coinbase/config_flow.py index dafa50bafcb..71ebcec65ee 100644 --- a/homeassistant/components/coinbase/config_flow.py +++ b/homeassistant/components/coinbase/config_flow.py @@ -50,8 +50,7 @@ STEP_USER_DATA_SCHEMA = vol.Schema( def get_user_from_client(api_key, api_token): """Get the user name from Coinbase API credentials.""" client = Client(api_key, api_token) - user = client.get_current_user() - return user + return client.get_current_user() async def validate_api(hass: HomeAssistant, data): diff --git a/homeassistant/components/conversation/agent_manager.py b/homeassistant/components/conversation/agent_manager.py index 838539b4992..9f31ccd6c62 100644 --- a/homeassistant/components/conversation/agent_manager.py +++ b/homeassistant/components/conversation/agent_manager.py @@ -84,7 +84,7 @@ async def async_converse( language = hass.config.language _LOGGER.debug("Processing in %s: %s", language, text) - result = await method( + return await method( ConversationInput( text=text, context=context, @@ -93,7 +93,6 @@ async def async_converse( language=language, ) ) - return result class AgentManager: diff --git a/homeassistant/components/conversation/default_agent.py b/homeassistant/components/conversation/default_agent.py index f652c5ee0eb..32cec18dfef 100644 --- a/homeassistant/components/conversation/default_agent.py +++ b/homeassistant/components/conversation/default_agent.py @@ -240,7 +240,7 @@ class DefaultAgent(ConversationEntity): slot_lists = self._make_slot_lists() intent_context = self._make_intent_context(user_input) - result = await self.hass.async_add_executor_job( + return await self.hass.async_add_executor_job( self._recognize, user_input, lang_intents, @@ -249,8 +249,6 @@ class DefaultAgent(ConversationEntity): language, ) - return result - async def async_process(self, user_input: ConversationInput) -> ConversationResult: """Process a sentence.""" language = user_input.language or self.hass.config.language @@ -901,8 +899,7 @@ class DefaultAgent(ConversationEntity): # Force rebuild on next use self._trigger_intents = None - unregister = functools.partial(self._unregister_trigger, trigger_data) - return unregister + return functools.partial(self._unregister_trigger, trigger_data) def _rebuild_trigger_intents(self) -> None: """Rebuild the HassIL intents object from the current trigger sentences.""" diff --git a/homeassistant/components/cppm_tracker/device_tracker.py b/homeassistant/components/cppm_tracker/device_tracker.py index 8978028641d..9b1ebbb1ed8 100644 --- a/homeassistant/components/cppm_tracker/device_tracker.py +++ b/homeassistant/components/cppm_tracker/device_tracker.py @@ -64,10 +64,9 @@ class CPPMDeviceScanner(DeviceScanner): def get_device_name(self, device): """Retrieve device name.""" - name = next( + return next( (result["name"] for result in self.results if result["mac"] == device), None ) - return name def get_cppm_data(self): """Retrieve data from Aruba Clearpass and return parsed result.""" diff --git a/homeassistant/components/daikin/__init__.py b/homeassistant/components/daikin/__init__.py index f0b62e95b1f..6f1196c7721 100644 --- a/homeassistant/components/daikin/__init__.py +++ b/homeassistant/components/daikin/__init__.py @@ -97,9 +97,7 @@ async def daikin_api_setup( _LOGGER.error("Unexpected error creating device %s", host) return None - api = DaikinApi(device) - - return api + return DaikinApi(device) class DaikinApi: diff --git a/homeassistant/components/device_tracker/legacy.py b/homeassistant/components/device_tracker/legacy.py index 1d1d4645bb4..e292e97a8ec 100644 --- a/homeassistant/components/device_tracker/legacy.py +++ b/homeassistant/components/device_tracker/legacy.py @@ -558,8 +558,7 @@ async def get_tracker(hass: HomeAssistant, config: ConfigType) -> DeviceTracker: track_new = defaults.get(CONF_TRACK_NEW, DEFAULT_TRACK_NEW) devices = await async_load_config(yaml_path, hass, consider_home) - tracker = DeviceTracker(hass, consider_home, track_new, defaults, devices) - return tracker + return DeviceTracker(hass, consider_home, track_new, defaults, devices) class DeviceTracker: diff --git a/homeassistant/components/devolo_home_control/diagnostics.py b/homeassistant/components/devolo_home_control/diagnostics.py index 753d04db0a3..33652f8e0bc 100644 --- a/homeassistant/components/devolo_home_control/diagnostics.py +++ b/homeassistant/components/devolo_home_control/diagnostics.py @@ -41,9 +41,7 @@ async def async_get_config_entry_diagnostics( for gateway in gateways ] - diag_data = { + return { "entry": async_redact_data(entry.as_dict(), TO_REDACT), "device_info": device_info, } - - return diag_data diff --git a/homeassistant/components/dlink/switch.py b/homeassistant/components/dlink/switch.py index a37caa6700c..36bfe4fb391 100644 --- a/homeassistant/components/dlink/switch.py +++ b/homeassistant/components/dlink/switch.py @@ -51,13 +51,11 @@ class SmartPlugSwitch(DLinkEntity, SwitchEntity): except ValueError: total_consumption = None - attrs = { + return { ATTR_TOTAL_CONSUMPTION: total_consumption, ATTR_TEMPERATURE: temperature, } - return attrs - @property def is_on(self) -> bool: """Return true if switch is on.""" diff --git a/homeassistant/components/dlna_dmr/config_flow.py b/homeassistant/components/dlna_dmr/config_flow.py index 9d95ba3883e..837bfc456d8 100644 --- a/homeassistant/components/dlna_dmr/config_flow.py +++ b/homeassistant/components/dlna_dmr/config_flow.py @@ -339,11 +339,7 @@ class DlnaDmrFlowHandler(ConfigFlow, domain=DOMAIN): entry.unique_id for entry in self._async_current_entries(include_ignore=False) } - discoveries = [ - disc for disc in discoveries if disc.ssdp_udn not in current_unique_ids - ] - - return discoveries + return [disc for disc in discoveries if disc.ssdp_udn not in current_unique_ids] class DlnaDmrOptionsFlowHandler(OptionsFlow): diff --git a/homeassistant/components/dlna_dms/config_flow.py b/homeassistant/components/dlna_dms/config_flow.py index 480f45ee95b..b50dc7ff227 100644 --- a/homeassistant/components/dlna_dms/config_flow.py +++ b/homeassistant/components/dlna_dms/config_flow.py @@ -179,8 +179,4 @@ class DlnaDmsFlowHandler(ConfigFlow, domain=DOMAIN): entry.unique_id for entry in self._async_current_entries(include_ignore=False) } - discoveries = [ - disc for disc in discoveries if disc.ssdp_udn not in current_unique_ids - ] - - return discoveries + return [disc for disc in discoveries if disc.ssdp_udn not in current_unique_ids] diff --git a/homeassistant/components/dlna_dms/dms.py b/homeassistant/components/dlna_dms/dms.py index 66c328f2e92..2312c7d2e3d 100644 --- a/homeassistant/components/dlna_dms/dms.py +++ b/homeassistant/components/dlna_dms/dms.py @@ -516,7 +516,7 @@ class DmsDeviceSource: if isinstance(child, didl_lite.DidlObject) ] - media_source = BrowseMediaSource( + return BrowseMediaSource( domain=DOMAIN, identifier=self._make_identifier(Action.SEARCH, query), media_class=MediaClass.DIRECTORY, @@ -527,8 +527,6 @@ class DmsDeviceSource: children=children, ) - return media_source - def _didl_to_play_media(self, item: didl_lite.DidlObject) -> DidlPlayMedia: """Return the first playable resource from a DIDL-Lite object.""" assert self._device @@ -583,7 +581,7 @@ class DmsDeviceSource: mime_type = _resource_mime_type(item.res[0]) if item.res else None media_content_type = mime_type or item.upnp_class - media_source = BrowseMediaSource( + return BrowseMediaSource( domain=DOMAIN, identifier=self._make_identifier(Action.OBJECT, item.id), media_class=MEDIA_CLASS_MAP.get(item.upnp_class, ""), @@ -595,8 +593,6 @@ class DmsDeviceSource: thumbnail=self._didl_thumbnail_url(item), ) - return media_source - def _didl_thumbnail_url(self, item: didl_lite.DidlObject) -> str | None: """Return absolute URL of a thumbnail for a DIDL-Lite object. diff --git a/homeassistant/components/ecowitt/diagnostics.py b/homeassistant/components/ecowitt/diagnostics.py index e4aecc1c07b..db7d2e0989d 100644 --- a/homeassistant/components/ecowitt/diagnostics.py +++ b/homeassistant/components/ecowitt/diagnostics.py @@ -22,7 +22,7 @@ async def async_get_device_diagnostics( station = ecowitt.stations[station_id] - data = { + return { "device": { "name": station.station, "model": station.model, @@ -36,5 +36,3 @@ async def async_get_device_diagnostics( if sensor.station.key == station_id }, } - - return data diff --git a/homeassistant/components/egardia/alarm_control_panel.py b/homeassistant/components/egardia/alarm_control_panel.py index c58396ae947..dec4750d219 100644 --- a/homeassistant/components/egardia/alarm_control_panel.py +++ b/homeassistant/components/egardia/alarm_control_panel.py @@ -102,7 +102,7 @@ class EgardiaAlarm(alarm.AlarmControlPanelEntity): def lookupstatusfromcode(self, statuscode): """Look at the rs_codes and returns the status from the code.""" - status = next( + return next( ( status_group.upper() for status_group, codes in self._rs_codes.items() @@ -111,7 +111,6 @@ class EgardiaAlarm(alarm.AlarmControlPanelEntity): ), "UNKNOWN", ) - return status def parsestatus(self, status): """Parse the status.""" diff --git a/homeassistant/components/electric_kiwi/oauth2.py b/homeassistant/components/electric_kiwi/oauth2.py index 864550991f5..9a6c4cd22a5 100644 --- a/homeassistant/components/electric_kiwi/oauth2.py +++ b/homeassistant/components/electric_kiwi/oauth2.py @@ -73,5 +73,4 @@ class ElectricKiwiLocalOAuth2Implementation(AuthImplementation): resp = await session.post(self.token_url, data=data, headers=headers) resp.raise_for_status() - resp_json = cast(dict, await resp.json()) - return resp_json + return cast(dict, await resp.json()) diff --git a/homeassistant/components/enocean/config_flow.py b/homeassistant/components/enocean/config_flow.py index 1137eb23256..157d58bbf23 100644 --- a/homeassistant/components/enocean/config_flow.py +++ b/homeassistant/components/enocean/config_flow.py @@ -81,10 +81,7 @@ class EnOceanFlowHandler(ConfigFlow, domain=DOMAIN): async def validate_enocean_conf(self, user_input) -> bool: """Return True if the user_input contains a valid dongle path.""" dongle_path = user_input[CONF_DEVICE] - path_is_valid = await self.hass.async_add_executor_job( - dongle.validate_path, dongle_path - ) - return path_is_valid + return await self.hass.async_add_executor_job(dongle.validate_path, dongle_path) def create_enocean_entry(self, user_input): """Create an entry for the provided configuration.""" diff --git a/homeassistant/components/environment_canada/diagnostics.py b/homeassistant/components/environment_canada/diagnostics.py index 63f8bb72189..0fb565fda59 100644 --- a/homeassistant/components/environment_canada/diagnostics.py +++ b/homeassistant/components/environment_canada/diagnostics.py @@ -21,9 +21,7 @@ async def async_get_config_entry_diagnostics( coordinators = hass.data[DOMAIN][config_entry.entry_id] weather_coord = coordinators["weather_coordinator"] - diagnostics_data = { + return { "config_entry_data": async_redact_data(dict(config_entry.data), TO_REDACT), "weather_data": dict(weather_coord.ec_data.conditions), } - - return diagnostics_data diff --git a/homeassistant/components/ezviz/config_flow.py b/homeassistant/components/ezviz/config_flow.py index a453398a17a..a17d8312700 100644 --- a/homeassistant/components/ezviz/config_flow.py +++ b/homeassistant/components/ezviz/config_flow.py @@ -70,15 +70,13 @@ def _validate_and_create_auth(data: dict) -> dict[str, Any]: ezviz_token = ezviz_client.login() - auth_data = { + return { CONF_SESSION_ID: ezviz_token[CONF_SESSION_ID], CONF_RFSESSION_ID: ezviz_token[CONF_RFSESSION_ID], CONF_URL: ezviz_token["api_url"], CONF_TYPE: ATTR_TYPE_CLOUD, } - return auth_data - def _test_camera_rtsp_creds(data: dict) -> None: """Try DESCRIBE on RTSP camera with credentials.""" diff --git a/homeassistant/components/ffmpeg/__init__.py b/homeassistant/components/ffmpeg/__init__.py index 09d8e2401f0..e5086166ff5 100644 --- a/homeassistant/components/ffmpeg/__init__.py +++ b/homeassistant/components/ffmpeg/__init__.py @@ -133,10 +133,9 @@ async def async_get_image( else: extra_cmd += " " + size_cmd - image = await asyncio.shield( + return await asyncio.shield( ffmpeg.get_image(input_source, output_format=output_format, extra_cmd=extra_cmd) ) - return image class FFmpegManager: diff --git a/homeassistant/components/fireservicerota/binary_sensor.py b/homeassistant/components/fireservicerota/binary_sensor.py index 9938f6ab096..a22991f2008 100644 --- a/homeassistant/components/fireservicerota/binary_sensor.py +++ b/homeassistant/components/fireservicerota/binary_sensor.py @@ -63,7 +63,7 @@ class ResponseBinarySensor(CoordinatorEntity, BinarySensorEntity): return attr data = self.coordinator.data - attr = { + return { key: data[key] for key in ( "start_time", @@ -77,5 +77,3 @@ class ResponseBinarySensor(CoordinatorEntity, BinarySensorEntity): ) if key in data } - - return attr diff --git a/homeassistant/components/fireservicerota/switch.py b/homeassistant/components/fireservicerota/switch.py index 04e1e4ef5eb..22287653788 100644 --- a/homeassistant/components/fireservicerota/switch.py +++ b/homeassistant/components/fireservicerota/switch.py @@ -71,7 +71,7 @@ class ResponseSwitch(SwitchEntity): return attr data = self._state_attributes - attr = { + return { key: data[key] for key in ( "user_name", @@ -87,8 +87,6 @@ class ResponseSwitch(SwitchEntity): if key in data } - return attr - async def async_turn_on(self, **kwargs: Any) -> None: """Send Acknowledge response status.""" await self.async_set_response(True) diff --git a/homeassistant/components/flipr/config_flow.py b/homeassistant/components/flipr/config_flow.py index fb7985b9602..0b0230f536e 100644 --- a/homeassistant/components/flipr/config_flow.py +++ b/homeassistant/components/flipr/config_flow.py @@ -91,9 +91,7 @@ class FliprConfigFlow(ConfigFlow, domain=DOMAIN): # Instantiates the flipr API that does not require async since it is has no network access. client = FliprAPIRestClient(self._username, self._password) - flipr_ids = await self.hass.async_add_executor_job(client.search_flipr_ids) - - return flipr_ids + return await self.hass.async_add_executor_job(client.search_flipr_ids) async def async_step_flipr_id( self, user_input: dict[str, str] | None = None diff --git a/homeassistant/components/folder/sensor.py b/homeassistant/components/folder/sensor.py index c4454eba800..6c8e4fc63a9 100644 --- a/homeassistant/components/folder/sensor.py +++ b/homeassistant/components/folder/sensor.py @@ -39,8 +39,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( def get_files_list(folder_path: str, filter_term: str) -> list[str]: """Return the list of files, applying filter.""" query = folder_path + filter_term - files_list = glob.glob(query) - return files_list + return glob.glob(query) def get_size(files_list: list[str]) -> int: diff --git a/homeassistant/components/fritz/diagnostics.py b/homeassistant/components/fritz/diagnostics.py index 3136f03f95b..c4725b99e43 100644 --- a/homeassistant/components/fritz/diagnostics.py +++ b/homeassistant/components/fritz/diagnostics.py @@ -21,7 +21,7 @@ async def async_get_config_entry_diagnostics( """Return diagnostics for a config entry.""" avm_wrapper: AvmWrapper = hass.data[DOMAIN][entry.entry_id] - diag_data = { + return { "entry": async_redact_data(entry.as_dict(), TO_REDACT), "device_info": { "model": avm_wrapper.model, @@ -51,5 +51,3 @@ async def async_get_config_entry_diagnostics( "wan_link_properties": await avm_wrapper.async_get_wan_link_properties(), }, } - - return diag_data diff --git a/homeassistant/components/frontier_silicon/browse_media.py b/homeassistant/components/frontier_silicon/browse_media.py index da5169b8e7c..0b51cb767c7 100644 --- a/homeassistant/components/frontier_silicon/browse_media.py +++ b/homeassistant/components/frontier_silicon/browse_media.py @@ -94,7 +94,7 @@ async def browse_top_level(current_mode, afsapi: AFSAPI): for top_level_media_content_id, name in TOP_LEVEL_DIRECTORIES.items() ] - library_info = BrowseMedia( + return BrowseMedia( media_class=MediaClass.DIRECTORY, media_content_id="library", media_content_type=MediaType.CHANNELS, @@ -105,8 +105,6 @@ async def browse_top_level(current_mode, afsapi: AFSAPI): children_media_class=MediaClass.DIRECTORY, ) - return library_info - async def browse_node( afsapi: AFSAPI, diff --git a/homeassistant/components/gios/diagnostics.py b/homeassistant/components/gios/diagnostics.py index 1cdd9299a1c..0bdd8f3a7ef 100644 --- a/homeassistant/components/gios/diagnostics.py +++ b/homeassistant/components/gios/diagnostics.py @@ -18,9 +18,7 @@ async def async_get_config_entry_diagnostics( """Return diagnostics for a config entry.""" coordinator: GiosDataUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id] - diagnostics_data = { + return { "config_entry": config_entry.as_dict(), "coordinator_data": asdict(coordinator.data), } - - return diagnostics_data diff --git a/homeassistant/components/goodwe/diagnostics.py b/homeassistant/components/goodwe/diagnostics.py index 600f02b9b7e..66806d31589 100644 --- a/homeassistant/components/goodwe/diagnostics.py +++ b/homeassistant/components/goodwe/diagnostics.py @@ -18,7 +18,7 @@ async def async_get_config_entry_diagnostics( """Return diagnostics for a config entry.""" inverter: Inverter = hass.data[DOMAIN][config_entry.entry_id][KEY_INVERTER] - diagnostics_data = { + return { "config_entry": config_entry.as_dict(), "inverter": { "model_name": inverter.model_name, @@ -32,5 +32,3 @@ async def async_get_config_entry_diagnostics( "arm_svn_version": inverter.arm_svn_version, }, } - - return diagnostics_data diff --git a/homeassistant/components/google_assistant/smart_home.py b/homeassistant/components/google_assistant/smart_home.py index df55fc0d7c8..bee1c8443fa 100644 --- a/homeassistant/components/google_assistant/smart_home.py +++ b/homeassistant/components/google_assistant/smart_home.py @@ -139,9 +139,7 @@ async def async_devices_sync( await data.config.async_connect_agent_user(agent_user_id) devices = await async_devices_sync_response(hass, data.config, agent_user_id) - response = create_sync_response(agent_user_id, devices) - - return response + return create_sync_response(agent_user_id, devices) @HANDLERS.register("action.devices.QUERY") diff --git a/homeassistant/components/google_assistant/trait.py b/homeassistant/components/google_assistant/trait.py index dd1e0cb3409..3efeabfa778 100644 --- a/homeassistant/components/google_assistant/trait.py +++ b/homeassistant/components/google_assistant/trait.py @@ -1927,9 +1927,7 @@ class ModesTrait(_Trait): # Shortcut since all domains are currently unique break - payload = {"availableModes": modes} - - return payload + return {"availableModes": modes} def query_attributes(self): """Return current modes.""" @@ -2104,9 +2102,7 @@ class InputSelectorTrait(_Trait): for source in sourcelist ] - payload = {"availableInputs": inputs, "orderedInputs": True} - - return payload + return {"availableInputs": inputs, "orderedInputs": True} def query_attributes(self): """Return current modes.""" diff --git a/homeassistant/components/greeneye_monitor/sensor.py b/homeassistant/components/greeneye_monitor/sensor.py index 1290fc9459a..d9ab6b16960 100644 --- a/homeassistant/components/greeneye_monitor/sensor.py +++ b/homeassistant/components/greeneye_monitor/sensor.py @@ -220,12 +220,11 @@ class PulseCounter(GEMSensor): if self._sensor.pulses_per_second is None: return None - result = ( + return ( self._sensor.pulses_per_second * self._counted_quantity_per_pulse * self._seconds_per_time_unit ) - return result @property def _seconds_per_time_unit(self) -> int: diff --git a/homeassistant/components/harmony/data.py b/homeassistant/components/harmony/data.py index 992eaf52326..cdb31b4388c 100644 --- a/homeassistant/components/harmony/data.py +++ b/homeassistant/components/harmony/data.py @@ -48,17 +48,13 @@ class HarmonyData(HarmonySubscriberMixin): def activity_names(self) -> list[str]: """Names of all the remotes activities.""" activity_infos = self.activities - activities = [activity["label"] for activity in activity_infos] - - return activities + return [activity["label"] for activity in activity_infos] @property def device_names(self): """Names of all of the devices connected to the hub.""" device_infos = self._client.config.get("device", []) - devices = [device["label"] for device in device_infos] - - return devices + return [device["label"] for device in device_infos] @property def unique_id(self): diff --git a/homeassistant/components/hko/coordinator.py b/homeassistant/components/hko/coordinator.py index c7d80ae299e..566ba5dcf5e 100644 --- a/homeassistant/components/hko/coordinator.py +++ b/homeassistant/components/hko/coordinator.py @@ -101,7 +101,7 @@ class HKOUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]): def _convert_current(self, data: dict[str, Any]) -> dict[str, Any]: """Return temperature and humidity in the appropriate format.""" - current = { + return { API_HUMIDITY: data[API_HUMIDITY][API_DATA][0][API_VALUE], API_TEMPERATURE: next( ( @@ -112,12 +112,11 @@ class HKOUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]): 0, ), } - return current def _convert_forecast(self, data: dict[str, Any]) -> dict[str, Any]: """Return daily forecast in the appropriate format.""" date = data[API_FORECAST_DATE] - forecast = { + return { ATTR_FORECAST_CONDITION: self._convert_icon_condition( data[API_FORECAST_ICON], data[API_FORECAST_WEATHER] ), @@ -125,7 +124,6 @@ class HKOUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]): ATTR_FORECAST_TEMP_LOW: data[API_FORECAST_MIN_TEMP][API_VALUE], ATTR_FORECAST_TIME: f"{date[0:4]}-{date[4:6]}-{date[6:8]}T00:00:00+08:00", } - return forecast def _convert_icon_condition(self, icon_code: int, info: str) -> str: """Return the condition corresponding to an icon code.""" diff --git a/homeassistant/components/homeassistant/exposed_entities.py b/homeassistant/components/homeassistant/exposed_entities.py index 135b2847520..4d6d9724ecb 100644 --- a/homeassistant/components/homeassistant/exposed_entities.py +++ b/homeassistant/components/homeassistant/exposed_entities.py @@ -259,7 +259,7 @@ class ExposedEntities: if assistant in registry_entry.options: if "should_expose" in registry_entry.options[assistant]: should_expose = registry_entry.options[assistant]["should_expose"] - return should_expose + return should_expose # noqa: RET504 if self.async_get_expose_new_entities(assistant): should_expose = self._is_default_exposed(entity_id, registry_entry) @@ -286,7 +286,7 @@ class ExposedEntities: ) and assistant in exposed_entity.assistants: if "should_expose" in exposed_entity.assistants[assistant]: should_expose = exposed_entity.assistants[assistant]["should_expose"] - return should_expose + return should_expose # noqa: RET504 if self.async_get_expose_new_entities(assistant): should_expose = self._is_default_exposed(entity_id, None) diff --git a/homeassistant/components/http/data_validator.py b/homeassistant/components/http/data_validator.py index 749c4f63a2f..e1ba1caae56 100644 --- a/homeassistant/components/http/data_validator.py +++ b/homeassistant/components/http/data_validator.py @@ -70,7 +70,6 @@ class RequestDataValidator: f"Message format incorrect: {err}", HTTPStatus.BAD_REQUEST ) - result = await method(view, request, data, *args, **kwargs) - return result + return await method(view, request, data, *args, **kwargs) return wrapper diff --git a/homeassistant/components/image/__init__.py b/homeassistant/components/image/__init__.py index 5b0d1a2a330..f40958a28ea 100644 --- a/homeassistant/components/image/__init__.py +++ b/homeassistant/components/image/__init__.py @@ -82,8 +82,7 @@ async def _async_get_image(image_entity: ImageEntity, timeout: int) -> Image: async with asyncio.timeout(timeout): if image_bytes := await image_entity.async_image(): content_type = valid_image_content_type(image_entity.content_type) - image = Image(content_type, image_bytes) - return image + return Image(content_type, image_bytes) raise HomeAssistantError("Unable to get image") diff --git a/homeassistant/components/imap/diagnostics.py b/homeassistant/components/imap/diagnostics.py index 467f19d6338..8afe3e327ba 100644 --- a/homeassistant/components/imap/diagnostics.py +++ b/homeassistant/components/imap/diagnostics.py @@ -31,9 +31,7 @@ def _async_get_diagnostics( redacted_config = async_redact_data(entry.data, REDACT_CONFIG) coordinator: ImapDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id] - data = { + return { "config": redacted_config, "event": coordinator.diagnostics_data, } - - return data diff --git a/homeassistant/components/insteon/api/properties.py b/homeassistant/components/insteon/api/properties.py index 7fac5439f56..20e798dded0 100644 --- a/homeassistant/components/insteon/api/properties.py +++ b/homeassistant/components/insteon/api/properties.py @@ -139,8 +139,7 @@ def property_to_dict(prop): modified = value == prop.new_value if prop.value_type in [ToggleMode, RelayMode] or prop.name == RAMP_RATE_IN_SEC: value = str(value).lower() - prop_dict = {"name": prop.name, "value": value, "modified": modified} - return prop_dict + return {"name": prop.name, "value": value, "modified": modified} def update_property(device, prop_name, value): diff --git a/homeassistant/components/integration/sensor.py b/homeassistant/components/integration/sensor.py index cf9ba5f2950..65e967d2af7 100644 --- a/homeassistant/components/integration/sensor.py +++ b/homeassistant/components/integration/sensor.py @@ -466,12 +466,10 @@ class IntegrationSensor(RestoreSensor): @property def extra_state_attributes(self) -> dict[str, str] | None: """Return the state attributes of the sensor.""" - state_attr = { + return { ATTR_SOURCE_ID: self._source_entity, } - return state_attr - @property def extra_restore_state_data(self) -> IntegrationSensorExtraStoredData: """Return sensor specific state data to be restored.""" diff --git a/homeassistant/components/intellifire/number.py b/homeassistant/components/intellifire/number.py index dca7a74c78e..17ed3b7bd27 100644 --- a/homeassistant/components/intellifire/number.py +++ b/homeassistant/components/intellifire/number.py @@ -61,8 +61,7 @@ class IntellifireFlameControlEntity(IntellifireEntity, NumberEntity): def native_value(self) -> float | None: """Return the current Flame Height segment number value.""" # UI uses 1-5 for flame height, backing lib uses 0-4 - value = self.coordinator.read_api.data.flameheight + 1 - return value + return self.coordinator.read_api.data.flameheight + 1 async def async_set_native_value(self, value: float) -> None: """Slider change.""" diff --git a/homeassistant/components/jellyfin/media_source.py b/homeassistant/components/jellyfin/media_source.py index add04d1a1ec..6d982458378 100644 --- a/homeassistant/components/jellyfin/media_source.py +++ b/homeassistant/components/jellyfin/media_source.py @@ -286,7 +286,7 @@ class JellyfinSource(MediaSource): mime_type = _media_mime_type(track) thumbnail_url = self._get_thumbnail_url(track) - result = BrowseMediaSource( + return BrowseMediaSource( domain=DOMAIN, identifier=track_id, media_class=MediaClass.TRACK, @@ -297,8 +297,6 @@ class JellyfinSource(MediaSource): thumbnail=thumbnail_url, ) - return result - async def _build_movie_library( self, library: dict[str, Any], include_children: bool ) -> BrowseMediaSource: @@ -347,7 +345,7 @@ class JellyfinSource(MediaSource): mime_type = _media_mime_type(movie) thumbnail_url = self._get_thumbnail_url(movie) - result = BrowseMediaSource( + return BrowseMediaSource( domain=DOMAIN, identifier=movie_id, media_class=MediaClass.MOVIE, @@ -358,8 +356,6 @@ class JellyfinSource(MediaSource): thumbnail=thumbnail_url, ) - return result - async def _build_tv_library( self, library: dict[str, Any], include_children: bool ) -> BrowseMediaSource: @@ -486,7 +482,7 @@ class JellyfinSource(MediaSource): mime_type = _media_mime_type(episode) thumbnail_url = self._get_thumbnail_url(episode) - result = BrowseMediaSource( + return BrowseMediaSource( domain=DOMAIN, identifier=episode_id, media_class=MediaClass.EPISODE, @@ -497,8 +493,6 @@ class JellyfinSource(MediaSource): thumbnail=thumbnail_url, ) - return result - async def _get_children( self, parent_id: str, item_type: str ) -> list[dict[str, Any]]: diff --git a/homeassistant/components/kodi/config_flow.py b/homeassistant/components/kodi/config_flow.py index 1d9d1ca4f7c..b4d9c575122 100644 --- a/homeassistant/components/kodi/config_flow.py +++ b/homeassistant/components/kodi/config_flow.py @@ -300,7 +300,7 @@ class KodiConfigFlow(ConfigFlow, domain=DOMAIN): @callback def _get_data(self): - data = { + return { CONF_NAME: self._name, CONF_HOST: self._host, CONF_PORT: self._port, @@ -311,8 +311,6 @@ class KodiConfigFlow(ConfigFlow, domain=DOMAIN): CONF_TIMEOUT: DEFAULT_TIMEOUT, } - return data - class CannotConnect(HomeAssistantError): """Error to indicate we cannot connect.""" diff --git a/homeassistant/components/kostal_plenticore/helper.py b/homeassistant/components/kostal_plenticore/helper.py index 4a4e6539f03..37666557eff 100644 --- a/homeassistant/components/kostal_plenticore/helper.py +++ b/homeassistant/components/kostal_plenticore/helper.py @@ -235,8 +235,7 @@ class SettingDataUpdateCoordinator( _LOGGER.debug("Fetching %s for %s", self.name, self._fetch) - fetched_data = await client.get_setting_values(self._fetch) - return fetched_data + return await client.get_setting_values(self._fetch) class PlenticoreSelectUpdateCoordinator(DataUpdateCoordinator[_DataT]): # pylint: disable=hass-enforce-coordinator-module @@ -295,9 +294,7 @@ class SelectDataUpdateCoordinator( _LOGGER.debug("Fetching select %s for %s", self.name, self._fetch) - fetched_data = await self._async_get_current_option(self._fetch) - - return fetched_data + return await self._async_get_current_option(self._fetch) async def _async_get_current_option( self, @@ -313,8 +310,7 @@ class SelectDataUpdateCoordinator( continue for option in val.values(): if option[all_option] == "1": - fetched = {mid: {cast(str, pids[0]): all_option}} - return fetched + return {mid: {cast(str, pids[0]): all_option}} return {mid: {cast(str, pids[0]): "None"}} return {} diff --git a/homeassistant/components/lg_soundbar/__init__.py b/homeassistant/components/lg_soundbar/__init__.py index cd1ce1c8139..250cba887c1 100644 --- a/homeassistant/components/lg_soundbar/__init__.py +++ b/homeassistant/components/lg_soundbar/__init__.py @@ -35,5 +35,4 @@ async def async_unload_entry( hass: core.HomeAssistant, entry: config_entries.ConfigEntry ) -> bool: """Unload a config entry.""" - result = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) - return result + return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index 726aef73c01..332d701148e 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -957,8 +957,7 @@ class LightEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): @property def _light_internal_rgbw_color(self) -> tuple[int, int, int, int] | None: """Return the rgbw color value [int, int, int, int].""" - rgbw_color = self.rgbw_color - return rgbw_color + return self.rgbw_color @cached_property def rgbww_color(self) -> tuple[int, int, int, int, int] | None: diff --git a/homeassistant/components/linear_garage_door/config_flow.py b/homeassistant/components/linear_garage_door/config_flow.py index bfb6f825030..31629f8e3b0 100644 --- a/homeassistant/components/linear_garage_door/config_flow.py +++ b/homeassistant/components/linear_garage_door/config_flow.py @@ -53,15 +53,13 @@ async def validate_input( finally: await hub.close() - info = { + return { "email": data["email"], "password": data["password"], "sites": sites, "device_id": device_id, } - return info - class LinearGarageDoorConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Linear Garage Door.""" diff --git a/homeassistant/components/logbook/queries/devices.py b/homeassistant/components/logbook/queries/devices.py index f4b1c06c40c..0e67ad23381 100644 --- a/homeassistant/components/logbook/queries/devices.py +++ b/homeassistant/components/logbook/queries/devices.py @@ -82,7 +82,7 @@ def devices_stmt( json_quotable_device_ids: list[str], ) -> StatementLambdaElement: """Generate a logbook query for multiple devices.""" - stmt = lambda_stmt( + return lambda_stmt( lambda: _apply_devices_context_union( select_events_without_states(start_day, end_day, event_type_ids).where( apply_event_device_id_matchers(json_quotable_device_ids) @@ -93,7 +93,6 @@ def devices_stmt( json_quotable_device_ids, ).order_by(Events.time_fired_ts) ) - return stmt def apply_event_device_id_matchers( diff --git a/homeassistant/components/logbook/queries/entities_and_devices.py b/homeassistant/components/logbook/queries/entities_and_devices.py index 383bb71e223..bef34f0858b 100644 --- a/homeassistant/components/logbook/queries/entities_and_devices.py +++ b/homeassistant/components/logbook/queries/entities_and_devices.py @@ -110,7 +110,7 @@ def entities_devices_stmt( json_quoted_device_ids: list[str], ) -> StatementLambdaElement: """Generate a logbook query for multiple entities.""" - stmt = lambda_stmt( + return lambda_stmt( lambda: _apply_entities_devices_context_union( select_events_without_states(start_day, end_day, event_type_ids).where( _apply_event_entity_id_device_id_matchers( @@ -125,7 +125,6 @@ def entities_devices_stmt( json_quoted_device_ids, ).order_by(Events.time_fired_ts) ) - return stmt def _apply_event_entity_id_device_id_matchers( diff --git a/homeassistant/components/luci/device_tracker.py b/homeassistant/components/luci/device_tracker.py index d62c1b07b5c..183f383e7e4 100644 --- a/homeassistant/components/luci/device_tracker.py +++ b/homeassistant/components/luci/device_tracker.py @@ -71,11 +71,10 @@ class LuciDeviceScanner(DeviceScanner): def get_device_name(self, device): """Return the name of the given device or None if we don't know.""" - name = next( + return next( (result.hostname for result in self.last_results if result.mac == device), None, ) - return name def get_extra_attributes(self, device): """Get extra attributes of a device. diff --git a/homeassistant/components/matter/helpers.py b/homeassistant/components/matter/helpers.py index 9aa58879214..cab9b602753 100644 --- a/homeassistant/components/matter/helpers.py +++ b/homeassistant/components/matter/helpers.py @@ -109,7 +109,7 @@ def get_node_from_device_entry( if server_info is None: raise RuntimeError("Matter server information is not available") - node = next( + return next( ( node for node in matter_client.get_nodes() @@ -118,5 +118,3 @@ def get_node_from_device_entry( ), None, ) - - return node diff --git a/homeassistant/components/media_source/local_source.py b/homeassistant/components/media_source/local_source.py index 8a67ae4a5b4..a1685df285e 100644 --- a/homeassistant/components/media_source/local_source.py +++ b/homeassistant/components/media_source/local_source.py @@ -93,12 +93,10 @@ class LocalSource(MediaSource): else: source_dir_id, location = None, "" - result = await self.hass.async_add_executor_job( + return await self.hass.async_add_executor_job( self._browse_media, source_dir_id, location ) - return result - def _browse_media( self, source_dir_id: str | None, location: str ) -> BrowseMediaSource: diff --git a/homeassistant/components/melcloud/climate.py b/homeassistant/components/melcloud/climate.py index 4bf12650b82..08b3658c270 100644 --- a/homeassistant/components/melcloud/climate.py +++ b/homeassistant/components/melcloud/climate.py @@ -330,12 +330,11 @@ class AtwDeviceZoneClimate(MelCloudClimate): @property def extra_state_attributes(self) -> dict[str, Any]: """Return the optional state attributes with device specific additions.""" - data = { + return { ATTR_STATUS: ATW_ZONE_HVAC_MODE_LOOKUP.get( self._zone.status, self._zone.status ) } - return data @property def hvac_mode(self) -> HVACMode: diff --git a/homeassistant/components/melcloud/water_heater.py b/homeassistant/components/melcloud/water_heater.py index 7d170430b04..8de1ac53311 100644 --- a/homeassistant/components/melcloud/water_heater.py +++ b/homeassistant/components/melcloud/water_heater.py @@ -73,8 +73,7 @@ class AtwWaterHeater(WaterHeaterEntity): @property def extra_state_attributes(self) -> dict[str, Any] | None: """Return the optional state attributes with device specific additions.""" - data = {ATTR_STATUS: self._device.status} - return data + return {ATTR_STATUS: self._device.status} @property def temperature_unit(self) -> str: diff --git a/homeassistant/components/meteoclimatic/__init__.py b/homeassistant/components/meteoclimatic/__init__.py index 2c371ebdcfd..f81d60c3d00 100644 --- a/homeassistant/components/meteoclimatic/__init__.py +++ b/homeassistant/components/meteoclimatic/__init__.py @@ -49,5 +49,4 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" - unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) - return unload_ok + return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) diff --git a/homeassistant/components/mjpeg/camera.py b/homeassistant/components/mjpeg/camera.py index ab8c67f2ca9..dcb2eff2fd6 100644 --- a/homeassistant/components/mjpeg/camera.py +++ b/homeassistant/components/mjpeg/camera.py @@ -146,8 +146,7 @@ class MjpegCamera(Camera): async with asyncio.timeout(TIMEOUT): response = await websession.get(self._still_image_url, auth=self._auth) - image = await response.read() - return image + return await response.read() except TimeoutError: LOGGER.error("Timeout getting camera image from %s", self.name) diff --git a/homeassistant/components/mobile_app/helpers.py b/homeassistant/components/mobile_app/helpers.py index 13d50b7984f..7f88074bf34 100644 --- a/homeassistant/components/mobile_app/helpers.py +++ b/homeassistant/components/mobile_app/helpers.py @@ -104,8 +104,7 @@ def _convert_legacy_encryption_key(key: str) -> bytes: keylen = SecretBox.KEY_SIZE key_bytes = key.encode("utf-8") key_bytes = key_bytes[:keylen] - key_bytes = key_bytes.ljust(keylen, b"\0") - return key_bytes + return key_bytes.ljust(keylen, b"\0") def decrypt_payload_legacy(key: str, ciphertext: bytes) -> JsonValueType | None: diff --git a/homeassistant/components/mqtt/client.py b/homeassistant/components/mqtt/client.py index 83830de4963..978123e169c 100644 --- a/homeassistant/components/mqtt/client.py +++ b/homeassistant/components/mqtt/client.py @@ -187,7 +187,7 @@ async def async_subscribe( translation_domain=DOMAIN, translation_placeholders={"topic": topic}, ) from exc - async_remove = await mqtt_data.client.async_subscribe( + return await mqtt_data.client.async_subscribe( topic, catch_log_exception( msg_callback, @@ -199,7 +199,6 @@ async def async_subscribe( qos, encoding, ) - return async_remove @bind_hass diff --git a/homeassistant/components/mqtt/trigger.py b/homeassistant/components/mqtt/trigger.py index d7086885b24..7aa798a7a3c 100644 --- a/homeassistant/components/mqtt/trigger.py +++ b/homeassistant/components/mqtt/trigger.py @@ -99,7 +99,6 @@ async def async_attach_trigger( "Attaching MQTT trigger for topic: '%s', payload: '%s'", topic, wanted_payload ) - remove = await mqtt.async_subscribe( + return await mqtt.async_subscribe( hass, topic, mqtt_automation_listener, encoding=encoding, qos=qos ) - return remove diff --git a/homeassistant/components/mqtt/util.py b/homeassistant/components/mqtt/util.py index a4635d1e4cc..ab21ab56f1b 100644 --- a/homeassistant/components/mqtt/util.py +++ b/homeassistant/components/mqtt/util.py @@ -218,8 +218,7 @@ def valid_birth_will(config: ConfigType) -> ConfigType: def get_mqtt_data(hass: HomeAssistant) -> MqttData: """Return typed MqttData from hass.data[DATA_MQTT].""" - mqtt_data: MqttData - mqtt_data = hass.data[DATA_MQTT] + mqtt_data: MqttData = hass.data[DATA_MQTT] return mqtt_data diff --git a/homeassistant/components/mysensors/config_flow.py b/homeassistant/components/mysensors/config_flow.py index b4347a39e12..9a8d79ca3a7 100644 --- a/homeassistant/components/mysensors/config_flow.py +++ b/homeassistant/components/mysensors/config_flow.py @@ -63,7 +63,7 @@ def is_persistence_file(value: str) -> str: def _get_schema_common(user_input: dict[str, str]) -> dict: """Create a schema with options common to all gateway types.""" - schema = { + return { vol.Required( CONF_VERSION, description={ @@ -72,7 +72,6 @@ def _get_schema_common(user_input: dict[str, str]) -> dict: ): str, vol.Optional(CONF_PERSISTENCE_FILE): str, } - return schema def _validate_version(version: str) -> dict[str, str]: diff --git a/homeassistant/components/mysensors/gateway.py b/homeassistant/components/mysensors/gateway.py index 8e9fb5442ea..0a037dfce31 100644 --- a/homeassistant/components/mysensors/gateway.py +++ b/homeassistant/components/mysensors/gateway.py @@ -129,7 +129,7 @@ async def setup_gateway( ) -> BaseAsyncGateway | None: """Set up the Gateway for the given ConfigEntry.""" - ready_gateway = await _get_gateway( + return await _get_gateway( hass, gateway_type=entry.data[CONF_GATEWAY_TYPE], device=entry.data[CONF_DEVICE], @@ -144,7 +144,6 @@ async def setup_gateway( topic_out_prefix=entry.data.get(CONF_TOPIC_OUT_PREFIX), retain=entry.data.get(CONF_RETAIN, False), ) - return ready_gateway async def _get_gateway( diff --git a/homeassistant/components/mysensors/helpers.py b/homeassistant/components/mysensors/helpers.py index cb075b8f485..c456cfd1f11 100644 --- a/homeassistant/components/mysensors/helpers.py +++ b/homeassistant/components/mysensors/helpers.py @@ -152,7 +152,7 @@ def get_child_schema( """Return a child schema.""" set_req = gateway.const.SetReq child_schema = child.get_schema(gateway.protocol_version) - schema = child_schema.extend( + return child_schema.extend( { vol.Required( set_req[name].value, msg=invalid_msg(gateway, child, name) @@ -161,7 +161,6 @@ def get_child_schema( }, extra=vol.ALLOW_EXTRA, ) - return schema def invalid_msg( diff --git a/homeassistant/components/mystrom/binary_sensor.py b/homeassistant/components/mystrom/binary_sensor.py index 2201eb778d6..66ea2cc9679 100644 --- a/homeassistant/components/mystrom/binary_sensor.py +++ b/homeassistant/components/mystrom/binary_sensor.py @@ -38,8 +38,7 @@ class MyStromView(HomeAssistantView): async def get(self, request): """Handle the GET request received from a myStrom button.""" - res = await self._handle(request.app[KEY_HASS], request.query) - return res + return await self._handle(request.app[KEY_HASS], request.query) async def _handle(self, hass, data): """Handle requests to the myStrom endpoint.""" diff --git a/homeassistant/components/myuplink/binary_sensor.py b/homeassistant/components/myuplink/binary_sensor.py index 38b8c9c5fd3..6b7ec66a7b4 100644 --- a/homeassistant/components/myuplink/binary_sensor.py +++ b/homeassistant/components/myuplink/binary_sensor.py @@ -34,11 +34,7 @@ def get_description(device_point: DevicePoint) -> BinarySensorEntityDescription 2. Default to None """ prefix, _, _ = device_point.category.partition(" ") - description = CATEGORY_BASED_DESCRIPTIONS.get(prefix, {}).get( - device_point.parameter_id - ) - - return description + return CATEGORY_BASED_DESCRIPTIONS.get(prefix, {}).get(device_point.parameter_id) async def async_setup_entry( diff --git a/homeassistant/components/myuplink/diagnostics.py b/homeassistant/components/myuplink/diagnostics.py index d108db595a1..15b643ffd92 100644 --- a/homeassistant/components/myuplink/diagnostics.py +++ b/homeassistant/components/myuplink/diagnostics.py @@ -39,9 +39,7 @@ async def async_get_config_entry_diagnostics( } ) - diagnostics_data = { + return { "config_entry_data": async_redact_data(dict(config_entry.data), TO_REDACT), "myuplink_data": async_redact_data(myuplink_data, TO_REDACT), } - - return diagnostics_data diff --git a/homeassistant/components/myuplink/switch.py b/homeassistant/components/myuplink/switch.py index d26695f4cbe..11dca1e2ac0 100644 --- a/homeassistant/components/myuplink/switch.py +++ b/homeassistant/components/myuplink/switch.py @@ -39,11 +39,7 @@ def get_description(device_point: DevicePoint) -> SwitchEntityDescription | None 2. Default to None """ prefix, _, _ = device_point.category.partition(" ") - description = CATEGORY_BASED_DESCRIPTIONS.get(prefix, {}).get( - device_point.parameter_id - ) - - return description + return CATEGORY_BASED_DESCRIPTIONS.get(prefix, {}).get(device_point.parameter_id) async def async_setup_entry( diff --git a/homeassistant/components/nam/diagnostics.py b/homeassistant/components/nam/diagnostics.py index 8ce885f0297..db1a97d8fb1 100644 --- a/homeassistant/components/nam/diagnostics.py +++ b/homeassistant/components/nam/diagnostics.py @@ -22,9 +22,7 @@ async def async_get_config_entry_diagnostics( """Return diagnostics for a config entry.""" coordinator: NAMDataUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id] - diagnostics_data = { + return { "info": async_redact_data(config_entry.data, TO_REDACT), "data": asdict(coordinator.data), } - - return diagnostics_data diff --git a/homeassistant/components/nextdns/diagnostics.py b/homeassistant/components/nextdns/diagnostics.py index c0a9071bb9d..cade6476d82 100644 --- a/homeassistant/components/nextdns/diagnostics.py +++ b/homeassistant/components/nextdns/diagnostics.py @@ -37,7 +37,7 @@ async def async_get_config_entry_diagnostics( settings_coordinator = coordinators[ATTR_SETTINGS] status_coordinator = coordinators[ATTR_STATUS] - diagnostics_data = { + return { "config_entry": async_redact_data(config_entry.as_dict(), TO_REDACT), "dnssec_coordinator_data": asdict(dnssec_coordinator.data), "encryption_coordinator_data": asdict(encryption_coordinator.data), @@ -46,5 +46,3 @@ async def async_get_config_entry_diagnostics( "settings_coordinator_data": asdict(settings_coordinator.data), "status_coordinator_data": asdict(status_coordinator.data), } - - return diagnostics_data diff --git a/homeassistant/components/nuki/binary_sensor.py b/homeassistant/components/nuki/binary_sensor.py index f2a98599e27..9b4772ee108 100644 --- a/homeassistant/components/nuki/binary_sensor.py +++ b/homeassistant/components/nuki/binary_sensor.py @@ -55,10 +55,9 @@ class NukiDoorsensorEntity(NukiEntity[NukiDevice], BinarySensorEntity): @property def extra_state_attributes(self): """Return the device specific state attributes.""" - data = { + return { ATTR_NUKI_ID: self._nuki_device.nuki_id, } - return data @property def available(self) -> bool: @@ -96,10 +95,9 @@ class NukiRingactionEntity(NukiEntity[NukiDevice], BinarySensorEntity): @property def extra_state_attributes(self): """Return the device specific state attributes.""" - data = { + return { ATTR_NUKI_ID: self._nuki_device.nuki_id, } - return data @property def is_on(self) -> bool: diff --git a/homeassistant/components/numato/sensor.py b/homeassistant/components/numato/sensor.py index 6efc3f6160f..ef71e00bc73 100644 --- a/homeassistant/components/numato/sensor.py +++ b/homeassistant/components/numato/sensor.py @@ -116,8 +116,7 @@ class NumatoGpioAdc(SensorEntity): def _clamp_to_source_range(self, val): # clamp to source range val = max(val, self._src_range[0]) - val = min(val, self._src_range[1]) - return val + return min(val, self._src_range[1]) def _linear_scale_to_dest_range(self, val): # linear scale to dest range @@ -125,5 +124,4 @@ class NumatoGpioAdc(SensorEntity): adc_val_rel = val - self._src_range[0] ratio = float(adc_val_rel) / float(src_len) dst_len = self._dst_range[1] - self._dst_range[0] - dest_val = self._dst_range[0] + ratio * dst_len - return dest_val + return self._dst_range[0] + ratio * dst_len diff --git a/homeassistant/components/nut/__init__.py b/homeassistant/components/nut/__init__.py index 575def8bf0f..8b715237e01 100644 --- a/homeassistant/components/nut/__init__.py +++ b/homeassistant/components/nut/__init__.py @@ -265,9 +265,7 @@ class PyNUTData: manufacturer = _manufacturer_from_status(self._status) model = _model_from_status(self._status) firmware = _firmware_from_status(self._status) - device_info = NUTDeviceInfo(manufacturer, model, firmware) - - return device_info + return NUTDeviceInfo(manufacturer, model, firmware) async def _async_get_status(self) -> dict[str, str]: """Get the ups status from NUT.""" diff --git a/homeassistant/components/omnilogic/common.py b/homeassistant/components/omnilogic/common.py index adc87e7be26..0484c889ba3 100644 --- a/homeassistant/components/omnilogic/common.py +++ b/homeassistant/components/omnilogic/common.py @@ -69,9 +69,7 @@ class OmniLogicUpdateCoordinator(DataUpdateCoordinator[dict[tuple, dict[str, Any return data - parsed_data = get_item_data(data, "Backyard", (), parsed_data) - - return parsed_data + return get_item_data(data, "Backyard", (), parsed_data) class OmniLogicEntity(CoordinatorEntity[OmniLogicUpdateCoordinator]): diff --git a/homeassistant/components/opnsense/device_tracker.py b/homeassistant/components/opnsense/device_tracker.py index 7c018e20a36..6357ce38e1d 100644 --- a/homeassistant/components/opnsense/device_tracker.py +++ b/homeassistant/components/opnsense/device_tracker.py @@ -14,10 +14,9 @@ async def async_get_scanner( ) -> OPNSenseDeviceScanner: """Configure the OPNSense device_tracker.""" interface_client = hass.data[OPNSENSE_DATA]["interfaces"] - scanner = OPNSenseDeviceScanner( + return OPNSenseDeviceScanner( interface_client, hass.data[OPNSENSE_DATA][CONF_TRACKER_INTERFACE] ) - return scanner class OPNSenseDeviceScanner(DeviceScanner): @@ -46,8 +45,7 @@ class OPNSenseDeviceScanner(DeviceScanner): """Return the name of the given device or None if we don't know.""" if device not in self.last_results: return None - hostname = self.last_results[device].get("hostname") or None - return hostname + return self.last_results[device].get("hostname") or None def update_info(self): """Ensure the information from the OPNSense router is up to date. diff --git a/homeassistant/components/overkiz/config_flow.py b/homeassistant/components/overkiz/config_flow.py index f95f885f7ef..eb79910d63f 100644 --- a/homeassistant/components/overkiz/config_flow.py +++ b/homeassistant/components/overkiz/config_flow.py @@ -368,12 +368,10 @@ class OverkizConfigFlow(ConfigFlow, domain=DOMAIN): self, username: str, password: str, server: OverkizServer ) -> OverkizClient: session = async_create_clientsession(self.hass) - client = OverkizClient( + return OverkizClient( username=username, password=password, server=server, session=session ) - return client - async def _create_local_api_token( self, cloud_client: OverkizClient, host: str, verify_ssl: bool ) -> str: diff --git a/homeassistant/components/plaato/__init__.py b/homeassistant/components/plaato/__init__.py index 0d8678d95ef..c68e2c8ad75 100644 --- a/homeassistant/components/plaato/__init__.py +++ b/homeassistant/components/plaato/__init__.py @@ -234,8 +234,7 @@ class PlaatoCoordinator(DataUpdateCoordinator): # pylint: disable=hass-enforce- async def _async_update_data(self): """Update data via library.""" - data = await self.api.get_data( + return await self.api.get_data( session=aiohttp_client.async_get_clientsession(self.hass), device_type=self.device_type, ) - return data diff --git a/homeassistant/components/proxmoxve/__init__.py b/homeassistant/components/proxmoxve/__init__.py index e0b8f91088d..6d6771debc4 100644 --- a/homeassistant/components/proxmoxve/__init__.py +++ b/homeassistant/components/proxmoxve/__init__.py @@ -200,8 +200,7 @@ def create_coordinator_container_vm( def poll_api() -> dict[str, Any] | None: """Call the api.""" - vm_status = call_api_container_vm(proxmox, node_name, vm_id, vm_type) - return vm_status + return call_api_container_vm(proxmox, node_name, vm_id, vm_type) vm_status = await hass.async_add_executor_job(poll_api) diff --git a/homeassistant/components/qvr_pro/camera.py b/homeassistant/components/qvr_pro/camera.py index 2754ab3a1ec..38221f89cfd 100644 --- a/homeassistant/components/qvr_pro/camera.py +++ b/homeassistant/components/qvr_pro/camera.py @@ -90,9 +90,7 @@ class QVRProCamera(Camera): @property def extra_state_attributes(self): """Get the state attributes.""" - attrs = {"qvr_guid": self.guid} - - return attrs + return {"qvr_guid": self.guid} def camera_image( self, width: int | None = None, height: int | None = None diff --git a/homeassistant/components/recorder/history/modern.py b/homeassistant/components/recorder/history/modern.py index 5fd4f415e02..675bb1b8cf8 100644 --- a/homeassistant/components/recorder/history/modern.py +++ b/homeassistant/components/recorder/history/modern.py @@ -174,8 +174,7 @@ def _significant_states_stmt( StateAttributes, States.attributes_id == StateAttributes.attributes_id ) if not include_start_time_state or not run_start_ts: - stmt = stmt.order_by(States.metadata_id, States.last_updated_ts) - return stmt + return stmt.order_by(States.metadata_id, States.last_updated_ts) unioned_subquery = union_all( _select_from_subquery( _get_start_time_state_stmt( diff --git a/homeassistant/components/recorder/statistics.py b/homeassistant/components/recorder/statistics.py index 0c127d079ad..e70a52c36f1 100644 --- a/homeassistant/components/recorder/statistics.py +++ b/homeassistant/components/recorder/statistics.py @@ -349,8 +349,7 @@ def get_start_time() -> datetime: now = dt_util.utcnow() current_period_minutes = now.minute - now.minute % 5 current_period = now.replace(minute=current_period_minutes, second=0, microsecond=0) - last_period = current_period - timedelta(minutes=5) - return last_period + return current_period - timedelta(minutes=5) def _compile_hourly_statistics_summary_mean_stmt( diff --git a/homeassistant/components/roon/config_flow.py b/homeassistant/components/roon/config_flow.py index d24cdb0c98d..2dc0bf71cd4 100644 --- a/homeassistant/components/roon/config_flow.py +++ b/homeassistant/components/roon/config_flow.py @@ -97,9 +97,7 @@ async def discover(hass): """Connect and authenticate home assistant.""" hub = RoonHub(hass) - servers = await hub.discover() - - return servers + return await hub.discover() async def authenticate(hass: HomeAssistant, host, port, servers): diff --git a/homeassistant/components/samsungtv/device_trigger.py b/homeassistant/components/samsungtv/device_trigger.py index e47cde785eb..5b8ff3ebdb8 100644 --- a/homeassistant/components/samsungtv/device_trigger.py +++ b/homeassistant/components/samsungtv/device_trigger.py @@ -55,8 +55,7 @@ async def async_get_triggers( _hass: HomeAssistant, device_id: str ) -> list[dict[str, str]]: """List device triggers for device.""" - triggers = [async_get_turn_on_trigger(device_id)] - return triggers + return [async_get_turn_on_trigger(device_id)] async def async_attach_trigger( diff --git a/homeassistant/components/schedule/__init__.py b/homeassistant/components/schedule/__init__.py index 2dc2ff2d035..e69a6761bc7 100644 --- a/homeassistant/components/schedule/__init__.py +++ b/homeassistant/components/schedule/__init__.py @@ -256,8 +256,7 @@ class Schedule(CollectionEntity): @classmethod def from_storage(cls, config: ConfigType) -> Schedule: """Return entity instance initialized from storage.""" - schedule = cls(config, editable=True) - return schedule + return cls(config, editable=True) @classmethod def from_yaml(cls, config: ConfigType) -> Schedule: diff --git a/homeassistant/components/sensibo/sensor.py b/homeassistant/components/sensibo/sensor.py index 0a2b23b2cd9..81ab3a06067 100644 --- a/homeassistant/components/sensibo/sensor.py +++ b/homeassistant/components/sensibo/sensor.py @@ -311,8 +311,7 @@ class SensiboDeviceSensor(SensiboDeviceBaseEntity, SensorEntity): @property def native_value(self) -> StateType | datetime: """Return value of sensor.""" - state = self.entity_description.value_fn(self.device_data) - return state + return self.entity_description.value_fn(self.device_data) @property def extra_state_attributes(self) -> Mapping[str, Any] | None: diff --git a/homeassistant/components/sharkiq/vacuum.py b/homeassistant/components/sharkiq/vacuum.py index 6647b79c892..d028b0b8b87 100644 --- a/homeassistant/components/sharkiq/vacuum.py +++ b/homeassistant/components/sharkiq/vacuum.py @@ -267,11 +267,10 @@ class SharkVacuumEntity(CoordinatorEntity[SharkIqUpdateCoordinator], StateVacuum @property def extra_state_attributes(self) -> dict[str, Any]: """Return a dictionary of device state attributes specific to sharkiq.""" - data = { + return { ATTR_ERROR_CODE: self.error_code, ATTR_ERROR_MSG: self.sharkiq.error_text, ATTR_LOW_LIGHT: self.low_light, ATTR_RECHARGE_RESUME: self.recharge_resume, ATTR_ROOMS: self.available_rooms, } - return data diff --git a/homeassistant/components/sky_hub/device_tracker.py b/homeassistant/components/sky_hub/device_tracker.py index 52c56993be0..bc4a0fdc743 100644 --- a/homeassistant/components/sky_hub/device_tracker.py +++ b/homeassistant/components/sky_hub/device_tracker.py @@ -54,11 +54,10 @@ class SkyHubDeviceScanner(DeviceScanner): async def async_get_device_name(self, device): """Return the name of the given device.""" - name = next( + return next( (result.name for result in self.last_results if result.mac == device), None, ) - return name async def async_get_extra_attributes(self, device): """Get extra attributes of a device.""" diff --git a/homeassistant/components/smarttub/light.py b/homeassistant/components/smarttub/light.py index b5fac0b34f6..532234f4059 100644 --- a/homeassistant/components/smarttub/light.py +++ b/homeassistant/components/smarttub/light.py @@ -96,14 +96,12 @@ class SmartTubLight(SmartTubEntity, LightEntity): @property def effect_list(self): """Return the list of supported effects.""" - effects = [ + return [ effect for effect in map(self._light_mode_to_effect, SpaLight.LightMode) if effect is not None ] - return effects - @staticmethod def _light_mode_to_effect(light_mode: SpaLight.LightMode): if light_mode == SpaLight.LightMode.OFF: diff --git a/homeassistant/components/sms/gateway.py b/homeassistant/components/sms/gateway.py index 9b5b8c1f51e..e0cbf78dba4 100644 --- a/homeassistant/components/sms/gateway.py +++ b/homeassistant/components/sms/gateway.py @@ -134,9 +134,7 @@ class Gateway: _LOGGER.info("Failed to read messages!") # Link all SMS when there are concatenated messages - entries = gammu.LinkSMS(entries) - - return entries + return gammu.LinkSMS(entries) @callback def _notify_incoming_sms(self, messages): diff --git a/homeassistant/components/sonos/media_browser.py b/homeassistant/components/sonos/media_browser.py index 6e6f388ed50..b6fc250ab23 100644 --- a/homeassistant/components/sonos/media_browser.py +++ b/homeassistant/components/sonos/media_browser.py @@ -501,7 +501,7 @@ def get_media( # Format is S:TITLE or S:ITEM_ID splits = item_id.split(":") title = splits[1] if len(splits) > 1 else None - playlist = next( + return next( ( p for p in media_library.get_playlists() @@ -509,7 +509,6 @@ def get_media( ), None, ) - return playlist if not item_id.startswith("A:ALBUM") and search_type == SONOS_ALBUM: item_id = "A:ALBUMARTIST/" + "/".join(item_id.split("/")[2:]) diff --git a/homeassistant/components/soundtouch/media_player.py b/homeassistant/components/soundtouch/media_player.py index 0843cc1a826..c09c4ed72c4 100644 --- a/homeassistant/components/soundtouch/media_player.py +++ b/homeassistant/components/soundtouch/media_player.py @@ -409,10 +409,8 @@ class SoundTouchMediaPlayer(MediaPlayerEntity): if slave_instance and slave_instance.entity_id != master: slaves.append(slave_instance.entity_id) - attributes = { + return { "master": master, "is_master": master == self.entity_id, "slaves": slaves, } - - return attributes diff --git a/homeassistant/components/squeezebox/browse_media.py b/homeassistant/components/squeezebox/browse_media.py index b770a3e22a3..bc63bcb7f2f 100644 --- a/homeassistant/components/squeezebox/browse_media.py +++ b/homeassistant/components/squeezebox/browse_media.py @@ -170,8 +170,7 @@ async def library_payload(hass, player): else: library_info["children"].append(item) - response = BrowseMedia(**library_info) - return response + return BrowseMedia(**library_info) def media_source_content_filter(item: BrowseMedia) -> bool: diff --git a/homeassistant/components/squeezebox/media_player.py b/homeassistant/components/squeezebox/media_player.py index 007d880a263..7d072fa2570 100644 --- a/homeassistant/components/squeezebox/media_player.py +++ b/homeassistant/components/squeezebox/media_player.py @@ -258,14 +258,12 @@ class SqueezeBoxEntity(MediaPlayerEntity): @property def extra_state_attributes(self): """Return device-specific attributes.""" - squeezebox_attr = { + return { attr: getattr(self, attr) for attr in ATTR_TO_PROPERTY if getattr(self, attr) is not None } - return squeezebox_attr - @callback def rediscovered(self, unique_id, connected): """Make a player available again.""" diff --git a/homeassistant/components/statistics/sensor.py b/homeassistant/components/statistics/sensor.py index 5c10768a408..36513dfd851 100644 --- a/homeassistant/components/statistics/sensor.py +++ b/homeassistant/components/statistics/sensor.py @@ -762,19 +762,17 @@ class StatisticsSensor(SensorEntity): def _stat_sum_differences(self) -> StateType: if len(self.states) >= 2: - diff_sum = sum( + return sum( abs(j - i) for i, j in zip(list(self.states), list(self.states)[1:]) ) - return diff_sum return None def _stat_sum_differences_nonnegative(self) -> StateType: if len(self.states) >= 2: - diff_sum_nn = sum( + return sum( (j - i if j >= i else j - 0) for i, j in zip(list(self.states), list(self.states)[1:]) ) - return diff_sum_nn return None def _stat_total(self) -> StateType: diff --git a/homeassistant/components/subaru/__init__.py b/homeassistant/components/subaru/__init__.py index d7169fc181e..db2ee7fdbbc 100644 --- a/homeassistant/components/subaru/__init__.py +++ b/homeassistant/components/subaru/__init__.py @@ -149,7 +149,7 @@ async def update_subaru(vehicle, controller): def get_vehicle_info(controller, vin): """Obtain vehicle identifiers and capabilities.""" - info = { + return { VEHICLE_VIN: vin, VEHICLE_MODEL_NAME: controller.get_model_name(vin), VEHICLE_MODEL_YEAR: controller.get_model_year(vin), @@ -161,7 +161,6 @@ def get_vehicle_info(controller, vin): VEHICLE_HAS_SAFETY_SERVICE: controller.get_safety_status(vin), VEHICLE_LAST_UPDATE: 0, } - return info def get_device_info(vehicle_info): diff --git a/homeassistant/components/subaru/diagnostics.py b/homeassistant/components/subaru/diagnostics.py index 0a26387d1c2..726457aa341 100644 --- a/homeassistant/components/subaru/diagnostics.py +++ b/homeassistant/components/subaru/diagnostics.py @@ -25,7 +25,7 @@ async def async_get_config_entry_diagnostics( """Return diagnostics for a config entry.""" coordinator = hass.data[DOMAIN][config_entry.entry_id][ENTRY_COORDINATOR] - diagnostics_data = { + return { "config_entry": async_redact_data(config_entry.data, CONFIG_FIELDS_TO_REDACT), "options": async_redact_data(config_entry.options, []), "data": [ @@ -34,8 +34,6 @@ async def async_get_config_entry_diagnostics( ], } - return diagnostics_data - async def async_get_device_diagnostics( hass: HomeAssistant, config_entry: ConfigEntry, device: DeviceEntry diff --git a/homeassistant/components/supla/__init__.py b/homeassistant/components/supla/__init__.py index 46a3ec2b2c0..8f04b5b662e 100644 --- a/homeassistant/components/supla/__init__.py +++ b/homeassistant/components/supla/__init__.py @@ -101,13 +101,12 @@ async def discover_devices(hass, hass_config): async def _fetch_channels(): async with asyncio.timeout(SCAN_INTERVAL.total_seconds()): - channels = { + return { channel["id"]: channel for channel in await server.get_channels( # noqa: B023 include=["iodevice", "state", "connected"] ) } - return channels coordinator = DataUpdateCoordinator( hass, diff --git a/homeassistant/components/synology_dsm/sensor.py b/homeassistant/components/synology_dsm/sensor.py index 47483ee4a63..b742669712e 100644 --- a/homeassistant/components/synology_dsm/sensor.py +++ b/homeassistant/components/synology_dsm/sensor.py @@ -4,6 +4,7 @@ from __future__ import annotations from dataclasses import dataclass from datetime import datetime, timedelta +from typing import cast from synology_dsm.api.core.utilization import SynoCoreUtilization from synology_dsm.api.dsm.information import SynoDSMInformation @@ -387,8 +388,10 @@ class SynoDSMStorageSensor(SynologyDSMDeviceEntity, SynoDSMSensor): @property def native_value(self) -> StateType: """Return the state.""" - attr = getattr(self._api.storage, self.entity_description.key)(self._device_id) - return attr # type: ignore[no-any-return] + return cast( + StateType, + getattr(self._api.storage, self.entity_description.key)(self._device_id), + ) class SynoDSMInfoSensor(SynoDSMSensor): diff --git a/homeassistant/components/tado/climate.py b/homeassistant/components/tado/climate.py index 621f5a1ad61..6d298a80e79 100644 --- a/homeassistant/components/tado/climate.py +++ b/homeassistant/components/tado/climate.py @@ -206,7 +206,7 @@ def create_climate_entity( cool_max_temp = float(cool_temperatures["celsius"]["max"]) cool_step = cool_temperatures["celsius"].get("step", PRECISION_TENTHS) - entity = TadoClimate( + return TadoClimate( tado, name, zone_id, @@ -222,7 +222,6 @@ def create_climate_entity( cool_step, supported_fan_modes, ) - return entity class TadoClimate(TadoZoneEntity, ClimateEntity): diff --git a/homeassistant/components/tado/water_heater.py b/homeassistant/components/tado/water_heater.py index 99172228973..f1257f097eb 100644 --- a/homeassistant/components/tado/water_heater.py +++ b/homeassistant/components/tado/water_heater.py @@ -106,7 +106,7 @@ def create_water_heater_entity(tado: TadoConnector, name: str, zone_id: int, zon min_temp = None max_temp = None - entity = TadoWaterHeater( + return TadoWaterHeater( tado, name, zone_id, @@ -115,8 +115,6 @@ def create_water_heater_entity(tado: TadoConnector, name: str, zone_id: int, zon max_temp, ) - return entity - class TadoWaterHeater(TadoZoneEntity, WaterHeaterEntity): """Representation of a Tado water heater.""" diff --git a/homeassistant/components/tankerkoenig/diagnostics.py b/homeassistant/components/tankerkoenig/diagnostics.py index 4846d2687a2..0af5b29c5a8 100644 --- a/homeassistant/components/tankerkoenig/diagnostics.py +++ b/homeassistant/components/tankerkoenig/diagnostics.py @@ -27,11 +27,10 @@ async def async_get_config_entry_diagnostics( """Return diagnostics for a config entry.""" coordinator: TankerkoenigDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id] - diag_data = { + return { "entry": async_redact_data(entry.as_dict(), TO_REDACT), "data": { station_id: asdict(price_info) for station_id, price_info in coordinator.data.items() }, } - return diag_data diff --git a/homeassistant/components/telegram_bot/__init__.py b/homeassistant/components/telegram_bot/__init__.py index 4e47be8b807..897fd6a9bac 100644 --- a/homeassistant/components/telegram_bot/__init__.py +++ b/homeassistant/components/telegram_bot/__init__.py @@ -983,10 +983,9 @@ class TelegramNotificationService: """Remove bot from chat.""" chat_id = self._get_target_chat_ids(chat_id)[0] _LOGGER.debug("Leave from chat ID %s", chat_id) - leaved = await self._send_msg( + return await self._send_msg( self.bot.leave_chat, "Error leaving chat", None, chat_id ) - return leaved class BaseTelegramBotEntity: diff --git a/homeassistant/components/template/sensor.py b/homeassistant/components/template/sensor.py index a6dbedc6161..a341fdd5f87 100644 --- a/homeassistant/components/template/sensor.py +++ b/homeassistant/components/template/sensor.py @@ -237,8 +237,7 @@ def async_create_preview_sensor( ) -> SensorTemplate: """Create a preview sensor.""" validated_config = SENSOR_SCHEMA(config | {CONF_NAME: name}) - entity = SensorTemplate(hass, validated_config, None) - return entity + return SensorTemplate(hass, validated_config, None) class SensorTemplate(TemplateEntity, SensorEntity): diff --git a/homeassistant/components/tensorflow/image_processing.py b/homeassistant/components/tensorflow/image_processing.py index 632db28ca3a..40e30ca3848 100644 --- a/homeassistant/components/tensorflow/image_processing.py +++ b/homeassistant/components/tensorflow/image_processing.py @@ -96,9 +96,7 @@ def get_model_detection_function(model): image, shapes = model.preprocess(image) prediction_dict = model.predict(image, shapes) - detections = model.postprocess(prediction_dict, shapes) - - return detections + return model.postprocess(prediction_dict, shapes) return detect_fn diff --git a/homeassistant/components/tractive/diagnostics.py b/homeassistant/components/tractive/diagnostics.py index f2bc80c51a1..cd1f5632f46 100644 --- a/homeassistant/components/tractive/diagnostics.py +++ b/homeassistant/components/tractive/diagnostics.py @@ -20,12 +20,10 @@ async def async_get_config_entry_diagnostics( """Return diagnostics for a config entry.""" trackables = hass.data[DOMAIN][config_entry.entry_id][TRACKABLES] - diagnostics_data = async_redact_data( + return async_redact_data( { "config_entry": config_entry.as_dict(), "trackables": [item.trackable for item in trackables], }, TO_REDACT, ) - - return diagnostics_data diff --git a/homeassistant/components/ubus/device_tracker.py b/homeassistant/components/ubus/device_tracker.py index 0aebea84c7d..b728059d0be 100644 --- a/homeassistant/components/ubus/device_tracker.py +++ b/homeassistant/components/ubus/device_tracker.py @@ -106,8 +106,7 @@ class UbusDeviceScanner(DeviceScanner): if self.mac2name is None: # Generation of mac2name dictionary failed return None - name = self.mac2name.get(device.upper(), None) - return name + return self.mac2name.get(device.upper(), None) async def async_get_extra_attributes(self, device: str) -> dict[str, str]: """Return the host to distinguish between multiple routers.""" diff --git a/homeassistant/components/uk_transport/sensor.py b/homeassistant/components/uk_transport/sensor.py index 24a88724add..134dd675163 100644 --- a/homeassistant/components/uk_transport/sensor.py +++ b/homeassistant/components/uk_transport/sensor.py @@ -284,5 +284,4 @@ def _delta_mins(hhmm_time_str): if hhmm_datetime < now: hhmm_datetime += timedelta(days=1) - delta_mins = (hhmm_datetime - now).total_seconds() // 60 - return delta_mins + return (hhmm_datetime - now).total_seconds() // 60 diff --git a/homeassistant/components/unifi/device_tracker.py b/homeassistant/components/unifi/device_tracker.py index 96a8a5dc1f8..a41d1942536 100644 --- a/homeassistant/components/unifi/device_tracker.py +++ b/homeassistant/components/unifi/device_tracker.py @@ -359,6 +359,4 @@ class UnifiScannerEntity(UnifiEntity[HandlerT, ApiItemT], ScannerEntity): if self.is_connected: attributes_to_check = CLIENT_CONNECTED_ALL_ATTRIBUTES - attributes = {k: raw[k] for k in attributes_to_check if k in raw} - - return attributes + return {k: raw[k] for k in attributes_to_check if k in raw} diff --git a/homeassistant/components/unifiprotect/media_source.py b/homeassistant/components/unifiprotect/media_source.py index 32cac04797f..ba962891454 100644 --- a/homeassistant/components/unifiprotect/media_source.py +++ b/homeassistant/components/unifiprotect/media_source.py @@ -419,9 +419,7 @@ class ProtectMediaSource(MediaSource): if camera is not None: title = f"{camera.display_name} > {title}" - title = f"{data.api.bootstrap.nvr.display_name} > {title}" - - return title + return f"{data.api.bootstrap.nvr.display_name} > {title}" async def _build_event( self, @@ -868,7 +866,7 @@ class ProtectMediaSource(MediaSource): async def _build_console(self, data: ProtectData) -> BrowseMediaSource: """Build media source for a single UniFi Protect NVR.""" - base = BrowseMediaSource( + return BrowseMediaSource( domain=DOMAIN, identifier=f"{data.api.bootstrap.nvr.id}:browse", media_class=MediaClass.DIRECTORY, @@ -880,8 +878,6 @@ class ProtectMediaSource(MediaSource): children=await self._build_cameras(data), ) - return base - async def _build_sources(self) -> BrowseMediaSource: """Return all media source for all UniFi Protect NVRs.""" diff --git a/homeassistant/components/unifiprotect/views.py b/homeassistant/components/unifiprotect/views.py index 0aa7056976b..0f9bff63689 100644 --- a/homeassistant/components/unifiprotect/views.py +++ b/homeassistant/components/unifiprotect/views.py @@ -52,15 +52,13 @@ def async_generate_event_video_url(event: Event) -> str: raise ValueError("Event is ongoing") url_format = VideoProxyView.url or "{nvr_id}/{camera_id}/{start}/{end}" - url = url_format.format( + return url_format.format( nvr_id=event.api.bootstrap.nvr.id, camera_id=event.camera_id, start=event.start.replace(microsecond=0).isoformat(), end=event.end.replace(microsecond=0).isoformat(), ) - return url - @callback def _client_error(message: Any, code: HTTPStatus) -> web.Response: diff --git a/homeassistant/components/upnp/device.py b/homeassistant/components/upnp/device.py index 4dff753ac6a..0b9eecb1b15 100644 --- a/homeassistant/components/upnp/device.py +++ b/homeassistant/components/upnp/device.py @@ -74,9 +74,7 @@ async def async_create_device(hass: HomeAssistant, location: str) -> Device: # Create profile wrapper. igd_device = IgdDevice(upnp_device, None) - device = Device(hass, igd_device) - - return device + return Device(hass, igd_device) class Device: diff --git a/homeassistant/components/uvc/camera.py b/homeassistant/components/uvc/camera.py index 307db17c2b8..4615bc2990a 100644 --- a/homeassistant/components/uvc/camera.py +++ b/homeassistant/components/uvc/camera.py @@ -243,7 +243,7 @@ class UnifiVideoCamera(Camera): """Return the source of the stream.""" for channel in self._caminfo["channels"]: if channel["isRtspEnabled"]: - uri = next( + return next( ( uri for i, uri in enumerate(channel["rtspUris"]) @@ -251,7 +251,6 @@ class UnifiVideoCamera(Camera): if re.search(self._nvr._host, uri) ) ) - return uri return None diff --git a/homeassistant/components/vesync/diagnostics.py b/homeassistant/components/vesync/diagnostics.py index b56c8fc5db6..9af8a7fed67 100644 --- a/homeassistant/components/vesync/diagnostics.py +++ b/homeassistant/components/vesync/diagnostics.py @@ -24,7 +24,7 @@ async def async_get_config_entry_diagnostics( """Return diagnostics for a config entry.""" manager: VeSync = hass.data[DOMAIN][VS_MANAGER] - data = { + return { DOMAIN: { "bulb_count": len(manager.bulbs), "fan_count": len(manager.fans), @@ -40,8 +40,6 @@ async def async_get_config_entry_diagnostics( }, } - return data - async def async_get_device_diagnostics( hass: HomeAssistant, entry: ConfigEntry, device: DeviceEntry diff --git a/homeassistant/components/webostv/device_trigger.py b/homeassistant/components/webostv/device_trigger.py index 0175df5d828..17d92b1abf3 100644 --- a/homeassistant/components/webostv/device_trigger.py +++ b/homeassistant/components/webostv/device_trigger.py @@ -55,8 +55,7 @@ async def async_get_triggers( _hass: HomeAssistant, device_id: str ) -> list[dict[str, str]]: """List device triggers for device.""" - triggers = [async_get_turn_on_trigger(device_id)] - return triggers + return [async_get_turn_on_trigger(device_id)] async def async_attach_trigger( diff --git a/homeassistant/components/ws66i/config_flow.py b/homeassistant/components/ws66i/config_flow.py index 5692ffcb81b..0cf0b557f35 100644 --- a/homeassistant/components/ws66i/config_flow.py +++ b/homeassistant/components/ws66i/config_flow.py @@ -128,12 +128,10 @@ class WS66iConfigFlow(ConfigFlow, domain=DOMAIN): @callback def _key_for_source(index, source, previous_sources): - key = vol.Required( + return vol.Required( source, description={"suggested_value": previous_sources[str(index)]} ) - return key - class Ws66iOptionsFlowHandler(OptionsFlow): """Handle a WS66i options flow.""" diff --git a/homeassistant/components/xiaomi_aqara/lock.py b/homeassistant/components/xiaomi_aqara/lock.py index 90afbe15911..8499864576a 100644 --- a/homeassistant/components/xiaomi_aqara/lock.py +++ b/homeassistant/components/xiaomi_aqara/lock.py @@ -61,8 +61,7 @@ class XiaomiAqaraLock(LockEntity, XiaomiDevice): @property def extra_state_attributes(self) -> dict[str, int]: """Return the state attributes.""" - attributes = {ATTR_VERIFIED_WRONG_TIMES: self._verified_wrong_times} - return attributes + return {ATTR_VERIFIED_WRONG_TIMES: self._verified_wrong_times} @callback def clear_unlock_state(self, _): diff --git a/homeassistant/components/xiaomi_miio/__init__.py b/homeassistant/components/xiaomi_miio/__init__.py index 5384bd93a7e..35ee017286f 100644 --- a/homeassistant/components/xiaomi_miio/__init__.py +++ b/homeassistant/components/xiaomi_miio/__init__.py @@ -248,7 +248,7 @@ def _async_update_data_vacuum( fan_speeds = device.fan_speed_presets() - data = VacuumCoordinatorData( + return VacuumCoordinatorData( device.status(), device.dnd_status(), device.last_clean_details(), @@ -259,8 +259,6 @@ def _async_update_data_vacuum( {v: k for k, v in fan_speeds.items()}, ) - return data - async def update_async() -> VacuumCoordinatorData: """Fetch data from the device using async_add_executor_job.""" diff --git a/homeassistant/components/xmpp/notify.py b/homeassistant/components/xmpp/notify.py index 50797536aee..4f7af2be7ee 100644 --- a/homeassistant/components/xmpp/notify.py +++ b/homeassistant/components/xmpp/notify.py @@ -297,7 +297,7 @@ async def async_send_message( # noqa: C901 _LOGGER.info("Uploading file from URL, %s", filename) - url = await self["xep_0363"].upload_file( + return await self["xep_0363"].upload_file( filename, size=filesize, input_file=result.content, @@ -305,8 +305,6 @@ async def async_send_message( # noqa: C901 timeout=timeout, ) - return url - async def upload_file_from_path(self, path, timeout=None): """Upload a file from a local file path via XEP_0363.""" _LOGGER.info("Uploading file from path, %s", path) @@ -328,7 +326,7 @@ async def async_send_message( # noqa: C901 filename = self.get_random_filename(data.get(ATTR_PATH)) _LOGGER.debug("Uploading file with random filename %s", filename) - url = await self["xep_0363"].upload_file( + return await self["xep_0363"].upload_file( filename, size=filesize, input_file=input_file, @@ -336,8 +334,6 @@ async def async_send_message( # noqa: C901 timeout=timeout, ) - return url - def send_text_message(self): """Send a text only message to a room or a recipient.""" try: diff --git a/homeassistant/components/yamaha_musiccast/media_player.py b/homeassistant/components/yamaha_musiccast/media_player.py index 3edf524c8ad..a068ac6ddca 100644 --- a/homeassistant/components/yamaha_musiccast/media_player.py +++ b/homeassistant/components/yamaha_musiccast/media_player.py @@ -385,7 +385,7 @@ class MusicCastMediaPlayer(MusicCastDeviceEntity, MediaPlayerEntity): else: children.append(item) - overview = BrowseMedia( + return BrowseMedia( title=media_content_provider.title, media_class=MEDIA_CLASS_MAPPING.get(media_content_provider.content_type), media_content_id=media_content_provider.content_id, @@ -395,8 +395,6 @@ class MusicCastMediaPlayer(MusicCastDeviceEntity, MediaPlayerEntity): children=children, ) - return overview - async def async_select_sound_mode(self, sound_mode: str) -> None: """Select sound mode.""" await self.coordinator.musiccast.select_sound_mode(self._zone_id, sound_mode) diff --git a/homeassistant/components/zha/core/cluster_handlers/closures.py b/homeassistant/components/zha/core/cluster_handlers/closures.py index c57ad507317..e96d6492beb 100644 --- a/homeassistant/components/zha/core/cluster_handlers/closures.py +++ b/homeassistant/components/zha/core/cluster_handlers/closures.py @@ -96,8 +96,7 @@ class DoorLockClusterHandler(ClusterHandler): async def async_get_user_code(self, code_slot: int) -> int: """Get the user code from the code slot.""" - result = await self.get_pin_code(code_slot - 1) - return result + return await self.get_pin_code(code_slot - 1) async def async_clear_user_code(self, code_slot: int) -> None: """Clear the code slot.""" @@ -117,8 +116,7 @@ class DoorLockClusterHandler(ClusterHandler): async def async_get_user_type(self, code_slot: int) -> str: """Get user type.""" - result = await self.get_user_type(code_slot - 1) - return result + return await self.get_user_type(code_slot - 1) @registries.ZIGBEE_CLUSTER_HANDLER_REGISTRY.register(Shade.cluster_id) diff --git a/homeassistant/components/zha/device_action.py b/homeassistant/components/zha/device_action.py index 076cb1d420e..8f5a03a7fe5 100644 --- a/homeassistant/components/zha/device_action.py +++ b/homeassistant/components/zha/device_action.py @@ -136,8 +136,7 @@ async def async_validate_action_config( ) -> ConfigType: """Validate config.""" schema = ACTION_SCHEMA_MAP.get(config[CONF_TYPE], DEFAULT_ACTION_SCHEMA) - config = schema(config) - return config + return schema(config) async def async_get_actions( diff --git a/homeassistant/components/zha/light.py b/homeassistant/components/zha/light.py index 8d65899707e..5e729a74f0d 100644 --- a/homeassistant/components/zha/light.py +++ b/homeassistant/components/zha/light.py @@ -147,11 +147,10 @@ class BaseLight(LogMixin, light.LightEntity): @property def extra_state_attributes(self) -> dict[str, Any]: """Return state attributes.""" - attributes = { + return { "off_with_transition": self._off_with_transition, "off_brightness": self._off_brightness, } - return attributes @property def is_on(self) -> bool: diff --git a/homeassistant/components/zha/sensor.py b/homeassistant/components/zha/sensor.py index 91fe302291a..e8507a96e2c 100644 --- a/homeassistant/components/zha/sensor.py +++ b/homeassistant/components/zha/sensor.py @@ -434,8 +434,7 @@ class Battery(Sensor): # per zcl specs battery percent is reported at 200% ¯\_(ツ)_/¯ if not isinstance(value, numbers.Number) or value == -1 or value == 255: return None - value = round(value / 2) - return value + return round(value / 2) @property def extra_state_attributes(self) -> dict[str, Any]: diff --git a/homeassistant/components/zwave_js/scripts/convert_device_diagnostics_to_fixture.py b/homeassistant/components/zwave_js/scripts/convert_device_diagnostics_to_fixture.py index 1005c3bb4db..6b73d1362f9 100644 --- a/homeassistant/components/zwave_js/scripts/convert_device_diagnostics_to_fixture.py +++ b/homeassistant/components/zwave_js/scripts/convert_device_diagnostics_to_fixture.py @@ -25,9 +25,7 @@ def get_arguments() -> argparse.Namespace: ), ) - arguments = parser.parse_args() - - return arguments + return parser.parse_args() def get_fixtures_dir_path(data: dict) -> Path: diff --git a/homeassistant/components/zwave_me/__init__.py b/homeassistant/components/zwave_me/__init__.py index 66f02246792..7e00924c221 100644 --- a/homeassistant/components/zwave_me/__init__.py +++ b/homeassistant/components/zwave_me/__init__.py @@ -63,8 +63,7 @@ class ZWaveMeController: async def async_establish_connection(self): """Get connection status.""" - is_connected = await self.zwave_api.get_connection() - return is_connected + return await self.zwave_api.get_connection() def add_device(self, device: ZWaveMeData) -> None: """Send signal to create device.""" diff --git a/homeassistant/config.py b/homeassistant/config.py index d3f30f84a68..61b346944fa 100644 --- a/homeassistant/config.py +++ b/homeassistant/config.py @@ -329,8 +329,7 @@ def _validate_currency(data: Any) -> Any: return cv.currency(data) except vol.InInvalid: with suppress(vol.InInvalid): - currency = cv.historic_currency(data) - return currency + return cv.historic_currency(data) raise diff --git a/homeassistant/helpers/aiohttp_client.py b/homeassistant/helpers/aiohttp_client.py index 6278586f469..2437d42da59 100644 --- a/homeassistant/helpers/aiohttp_client.py +++ b/homeassistant/helpers/aiohttp_client.py @@ -126,7 +126,7 @@ def async_create_clientsession( if auto_cleanup: auto_cleanup_method = _async_register_clientsession_shutdown - clientsession = _async_create_clientsession( + return _async_create_clientsession( hass, verify_ssl, auto_cleanup_method=auto_cleanup_method, @@ -134,8 +134,6 @@ def async_create_clientsession( **kwargs, ) - return clientsession - @callback def _async_create_clientsession( diff --git a/homeassistant/helpers/restore_state.py b/homeassistant/helpers/restore_state.py index 7979247c8b0..4970b89db1f 100644 --- a/homeassistant/helpers/restore_state.py +++ b/homeassistant/helpers/restore_state.py @@ -73,12 +73,11 @@ class StoredState: def as_dict(self) -> dict[str, Any]: """Return a dict representation of the stored state to be JSON serialized.""" - result = { + return { "state": self.state.json_fragment, "extra_data": self.extra_data.as_dict() if self.extra_data else None, "last_seen": self.last_seen, } - return result @classmethod def from_dict(cls, json_dict: dict) -> Self: diff --git a/homeassistant/helpers/schema_config_entry_flow.py b/homeassistant/helpers/schema_config_entry_flow.py index 0486c7b6f8c..978ce949eb3 100644 --- a/homeassistant/helpers/schema_config_entry_flow.py +++ b/homeassistant/helpers/schema_config_entry_flow.py @@ -357,8 +357,7 @@ class SchemaConfigFlowHandler(ConfigFlow, ABC): ) -> ConfigFlowResult: """Handle a config flow step.""" # pylint: disable-next=protected-access - result = await self._common_handler.async_step(step_id, user_input) - return result + return await self._common_handler.async_step(step_id, user_input) return _async_step @@ -452,8 +451,7 @@ class SchemaOptionsFlowHandler(OptionsFlowWithConfigEntry): ) -> ConfigFlowResult: """Handle an options flow step.""" # pylint: disable-next=protected-access - result = await self._common_handler.async_step(step_id, user_input) - return result + return await self._common_handler.async_step(step_id, user_input) return _async_step diff --git a/homeassistant/helpers/script.py b/homeassistant/helpers/script.py index 0b054307702..0fee9fae322 100644 --- a/homeassistant/helpers/script.py +++ b/homeassistant/helpers/script.py @@ -817,8 +817,7 @@ class _ScriptRun: return True - result = traced_test_conditions(self._hass, self._variables) - return result + return traced_test_conditions(self._hass, self._variables) @async_trace_path("repeat") async def _async_repeat_step(self): # noqa: C901 diff --git a/homeassistant/util/logging.py b/homeassistant/util/logging.py index 489b6493ef1..09ece063dd0 100644 --- a/homeassistant/util/logging.py +++ b/homeassistant/util/logging.py @@ -198,12 +198,10 @@ def async_create_catching_coro( target: target coroutine. """ trace = traceback.extract_stack() - wrapped_target = catch_log_coro_exception( + return catch_log_coro_exception( target, lambda: "Exception in {} called from\n {}".format( target.__name__, "".join(traceback.format_list(trace[:-1])), ), ) - - return wrapped_target diff --git a/homeassistant/util/package.py b/homeassistant/util/package.py index 44f9be3272f..067bf5ff36d 100644 --- a/homeassistant/util/package.py +++ b/homeassistant/util/package.py @@ -147,5 +147,4 @@ async def async_get_user_site(deps_dir: str) -> str: close_fds=False, # required for posix_spawn ) stdout, _ = await process.communicate() - lib_dir = stdout.decode().strip() - return lib_dir + return stdout.decode().strip() diff --git a/homeassistant/util/timeout.py b/homeassistant/util/timeout.py index cf73ee6b220..94baa57e4d8 100644 --- a/homeassistant/util/timeout.py +++ b/homeassistant/util/timeout.py @@ -472,8 +472,7 @@ class TimeoutManager: # Global Zone if zone_name == ZONE_GLOBAL: - task = _GlobalTaskContext(self, current_task, timeout, cool_down) - return task + return _GlobalTaskContext(self, current_task, timeout, cool_down) # Zone Handling if zone_name in self.zones: diff --git a/pyproject.toml b/pyproject.toml index e8558524b08..f35aa12221f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -719,7 +719,6 @@ ignore = [ # temporarily disabled "PT019", - "RET504", "RET503", "RET502", "RET501", diff --git a/script/gen_requirements_all.py b/script/gen_requirements_all.py index 9a9ff6821c7..d8fffac1a06 100755 --- a/script/gen_requirements_all.py +++ b/script/gen_requirements_all.py @@ -263,9 +263,7 @@ def normalize_package_name(requirement: str) -> str: return "" # pipdeptree needs lowercase and dash instead of underscore as separator - package = match.group(1).lower().replace("_", "-") - - return package + return match.group(1).lower().replace("_", "-") def comment_requirement(req: str) -> bool: diff --git a/script/install_integration_requirements.py b/script/install_integration_requirements.py index 1a87be04f7e..fec893c008a 100644 --- a/script/install_integration_requirements.py +++ b/script/install_integration_requirements.py @@ -18,9 +18,7 @@ def get_arguments() -> argparse.Namespace: "integration", type=valid_integration, help="Integration to target." ) - arguments = parser.parse_args() - - return arguments + return parser.parse_args() def main() -> int | None: diff --git a/script/scaffold/__main__.py b/script/scaffold/__main__.py index f81f9144f98..45dbed790e6 100644 --- a/script/scaffold/__main__.py +++ b/script/scaffold/__main__.py @@ -25,9 +25,7 @@ def get_arguments() -> argparse.Namespace: "--integration", type=valid_integration, help="Integration to target." ) - arguments = parser.parse_args() - - return arguments + return parser.parse_args() def main(): diff --git a/tests/components/airthings_ble/__init__.py b/tests/components/airthings_ble/__init__.py index ba213e0c2e7..3622a21f633 100644 --- a/tests/components/airthings_ble/__init__.py +++ b/tests/components/airthings_ble/__init__.py @@ -235,11 +235,10 @@ def create_entry(hass): def create_device(entry: ConfigEntry, device_registry: DeviceRegistry): """Create a device for the given entry.""" - device = device_registry.async_get_or_create( + return device_registry.async_get_or_create( config_entry_id=entry.entry_id, connections={(CONNECTION_BLUETOOTH, WAVE_SERVICE_INFO.address)}, manufacturer="Airthings AS", name="Airthings Wave Plus (123456)", model="Wave Plus", ) - return device diff --git a/tests/components/alexa/test_smart_home_http.py b/tests/components/alexa/test_smart_home_http.py index 153442552a4..1c30c72e72c 100644 --- a/tests/components/alexa/test_smart_home_http.py +++ b/tests/components/alexa/test_smart_home_http.py @@ -23,12 +23,11 @@ async def do_http_discovery(config, hass, hass_client): http_client = await hass_client() request = get_new_request("Alexa.Discovery", "Discover") - response = await http_client.post( + return await http_client.post( smart_home.SMART_HOME_HTTP_ENDPOINT, data=json.dumps(request), headers={"content-type": CONTENT_TYPE_JSON}, ) - return response @pytest.mark.parametrize( diff --git a/tests/components/blebox/test_config_flow.py b/tests/components/blebox/test_config_flow.py index fd6d0ce8fb2..612c4f09424 100644 --- a/tests/components/blebox/test_config_flow.py +++ b/tests/components/blebox/test_config_flow.py @@ -88,8 +88,7 @@ async def test_flow_works( def product_class_mock_fixture(): """Return a mocked feature.""" path = "homeassistant.components.blebox.config_flow.Box" - patcher = patch(path, DEFAULT, blebox_uniapi.box.Box, True, True) - return patcher + return patch(path, DEFAULT, blebox_uniapi.box.Box, True, True) async def test_flow_with_connection_failure( diff --git a/tests/components/cast/conftest.py b/tests/components/cast/conftest.py index d9ebb24696e..66a55ba7efd 100644 --- a/tests/components/cast/conftest.py +++ b/tests/components/cast/conftest.py @@ -18,8 +18,7 @@ def get_multizone_status_mock(): @pytest.fixture def get_cast_type_mock(): """Mock pychromecast dial.""" - mock = MagicMock(spec_set=pychromecast.dial.get_cast_type) - return mock + return MagicMock(spec_set=pychromecast.dial.get_cast_type) @pytest.fixture diff --git a/tests/components/dlna_dmr/conftest.py b/tests/components/dlna_dmr/conftest.py index bb47a468dc4..59b1af546f2 100644 --- a/tests/components/dlna_dmr/conftest.py +++ b/tests/components/dlna_dmr/conftest.py @@ -82,7 +82,7 @@ def domain_data_mock(hass: HomeAssistant) -> Iterable[Mock]: @pytest.fixture def config_entry_mock() -> MockConfigEntry: """Mock a config entry for this platform.""" - mock_entry = MockConfigEntry( + return MockConfigEntry( unique_id=MOCK_DEVICE_UDN, domain=DLNA_DOMAIN, data={ @@ -94,13 +94,12 @@ def config_entry_mock() -> MockConfigEntry: title=MOCK_DEVICE_NAME, options={}, ) - return mock_entry @pytest.fixture def config_entry_mock_no_mac() -> MockConfigEntry: """Mock a config entry that does not already contain a MAC address.""" - mock_entry = MockConfigEntry( + return MockConfigEntry( unique_id=MOCK_DEVICE_UDN, domain=DLNA_DOMAIN, data={ @@ -111,7 +110,6 @@ def config_entry_mock_no_mac() -> MockConfigEntry: title=MOCK_DEVICE_NAME, options={}, ) - return mock_entry @pytest.fixture diff --git a/tests/components/dlna_dmr/test_media_player.py b/tests/components/dlna_dmr/test_media_player.py index 9ead49f0955..87c54c2956b 100644 --- a/tests/components/dlna_dmr/test_media_player.py +++ b/tests/components/dlna_dmr/test_media_player.py @@ -85,9 +85,7 @@ async def setup_mock_component(hass: HomeAssistant, mock_entry: MockConfigEntry) entries = async_entries_for_config_entry(async_get_er(hass), mock_entry.entry_id) assert len(entries) == 1 - entity_id = entries[0].entity_id - - return entity_id + return entries[0].entity_id async def get_attrs(hass: HomeAssistant, entity_id: str) -> Mapping[str, Any]: diff --git a/tests/components/dlna_dms/conftest.py b/tests/components/dlna_dms/conftest.py index eacf03e9da7..c1bee224c5a 100644 --- a/tests/components/dlna_dms/conftest.py +++ b/tests/components/dlna_dms/conftest.py @@ -93,7 +93,7 @@ def aiohttp_session_requester_mock() -> Iterable[Mock]: @pytest.fixture def config_entry_mock() -> MockConfigEntry: """Mock a config entry for this platform.""" - mock_entry = MockConfigEntry( + return MockConfigEntry( unique_id=MOCK_DEVICE_USN, domain=DOMAIN, version=CONFIG_VERSION, @@ -104,7 +104,6 @@ def config_entry_mock() -> MockConfigEntry: }, title=MOCK_DEVICE_NAME, ) - return mock_entry @pytest.fixture diff --git a/tests/components/electric_kiwi/conftest.py b/tests/components/electric_kiwi/conftest.py index 0a1d32f0ec0..8819b1e134d 100644 --- a/tests/components/electric_kiwi/conftest.py +++ b/tests/components/electric_kiwi/conftest.py @@ -63,7 +63,7 @@ def component_setup( @pytest.fixture(name="config_entry") def mock_config_entry(hass: HomeAssistant) -> MockConfigEntry: """Create mocked config entry.""" - entry = MockConfigEntry( + return MockConfigEntry( title="Electric Kiwi", domain=DOMAIN, data={ @@ -79,7 +79,6 @@ def mock_config_entry(hass: HomeAssistant) -> MockConfigEntry: }, unique_id=DOMAIN, ) - return entry @pytest.fixture diff --git a/tests/components/escea/test_config_flow.py b/tests/components/escea/test_config_flow.py index 3cb914bfaf3..aa863bd4371 100644 --- a/tests/components/escea/test_config_flow.py +++ b/tests/components/escea/test_config_flow.py @@ -25,8 +25,7 @@ def mock_discovery_service_fixture() -> AsyncMock: @pytest.fixture(name="mock_controller") def mock_controller_fixture() -> MagicMock: """Mock controller.""" - controller = MagicMock() - return controller + return MagicMock() def _mock_start_discovery( diff --git a/tests/components/esphome/test_voice_assistant.py b/tests/components/esphome/test_voice_assistant.py index 427cd1dbc8f..9882419ed5a 100644 --- a/tests/components/esphome/test_voice_assistant.py +++ b/tests/components/esphome/test_voice_assistant.py @@ -47,7 +47,7 @@ def voice_assistant_udp_server( server.close() server = VoiceAssistantUDPServer(hass, entry_data, Mock(), handle_finished) - return server + return server # noqa: RET504 return _voice_assistant_udp_server diff --git a/tests/components/feedreader/test_init.py b/tests/components/feedreader/test_init.py index f836d233670..67ce95811a0 100644 --- a/tests/components/feedreader/test_init.py +++ b/tests/components/feedreader/test_init.py @@ -36,8 +36,7 @@ VALID_CONFIG_5 = {feedreader.DOMAIN: {CONF_URLS: [URL], CONF_MAX_ENTRIES: 1}} def load_fixture_bytes(src: str) -> bytes: """Return byte stream of fixture.""" feed_data = load_fixture(src, DOMAIN) - raw = bytes(feed_data, "utf-8") - return raw + return bytes(feed_data, "utf-8") @pytest.fixture(name="feed_one_event") diff --git a/tests/components/generic/conftest.py b/tests/components/generic/conftest.py index e9233ffc559..92a9298cbd5 100644 --- a/tests/components/generic/conftest.py +++ b/tests/components/generic/conftest.py @@ -68,11 +68,10 @@ def mock_create_stream(): mock_stream.add_provider.return_value = mock_provider mock_stream.start = AsyncMock() mock_stream.stop = AsyncMock() - fake_create_stream = patch( + return patch( "homeassistant.components.generic.config_flow.create_stream", return_value=mock_stream, ) - return fake_create_stream @pytest.fixture diff --git a/tests/components/gree/common.py b/tests/components/gree/common.py index 97656596ce6..ca217168b18 100644 --- a/tests/components/gree/common.py +++ b/tests/components/gree/common.py @@ -69,7 +69,7 @@ def build_device_info_mock( def build_device_mock(name="fake-device-1", ipAddress="1.1.1.1", mac="aabbcc112233"): """Build mock device object.""" - mock = Mock( + return Mock( device_info=build_device_info_mock(name, ipAddress, mac), name=name, bind=AsyncMock(), @@ -89,7 +89,6 @@ def build_device_mock(name="fake-device-1", ipAddress="1.1.1.1", mac="aabbcc1122 power_save=False, steady_heat=False, ) - return mock async def async_setup_gree(hass: HomeAssistant) -> MockConfigEntry: diff --git a/tests/components/here_travel_time/test_config_flow.py b/tests/components/here_travel_time/test_config_flow.py index 002e2ed8fdb..eb958991c71 100644 --- a/tests/components/here_travel_time/test_config_flow.py +++ b/tests/components/here_travel_time/test_config_flow.py @@ -84,13 +84,12 @@ async def option_init_result_fixture(hass: HomeAssistant) -> FlowResultType: await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() flow = await hass.config_entries.options.async_init(entry.entry_id) - result = await hass.config_entries.options.async_configure( + return await hass.config_entries.options.async_configure( flow["flow_id"], user_input={ CONF_ROUTE_MODE: ROUTE_MODE_FASTEST, }, ) - return result @pytest.fixture(name="origin_step_result") @@ -102,7 +101,7 @@ async def origin_step_result_fixture( user_step_result["flow_id"], {"next_step_id": "origin_coordinates"} ) - location_selector_result = await hass.config_entries.flow.async_configure( + return await hass.config_entries.flow.async_configure( origin_menu_result["flow_id"], { "origin": { @@ -112,7 +111,6 @@ async def origin_step_result_fixture( } }, ) - return location_selector_result @pytest.mark.parametrize( diff --git a/tests/components/homekit_controller/common.py b/tests/components/homekit_controller/common.py index 39466cc51e4..8c45080c786 100644 --- a/tests/components/homekit_controller/common.py +++ b/tests/components/homekit_controller/common.py @@ -195,8 +195,7 @@ async def setup_accessories_from_file(hass: HomeAssistant, path: str) -> Accesso load_fixture, os.path.join("homekit_controller", path) ) accessories_json = hkloads(accessories_fixture) - accessories = Accessories.from_list(accessories_json) - return accessories + return Accessories.from_list(accessories_json) async def setup_platform(hass): diff --git a/tests/components/homematicip_cloud/conftest.py b/tests/components/homematicip_cloud/conftest.py index 88298521f75..3f87f12d9fc 100644 --- a/tests/components/homematicip_cloud/conftest.py +++ b/tests/components/homematicip_cloud/conftest.py @@ -54,7 +54,7 @@ def hmip_config_entry_fixture() -> config_entries.ConfigEntry: HMIPC_NAME: "", HMIPC_PIN: HAPPIN, } - config_entry = MockConfigEntry( + return MockConfigEntry( version=1, domain=HMIPC_DOMAIN, title="Home Test SN", @@ -63,8 +63,6 @@ def hmip_config_entry_fixture() -> config_entries.ConfigEntry: source=SOURCE_IMPORT, ) - return config_entry - @pytest.fixture(name="default_mock_hap_factory") async def default_mock_hap_factory_fixture( diff --git a/tests/components/http/test_data_validator.py b/tests/components/http/test_data_validator.py index af55e0b8597..9a4e80052f6 100644 --- a/tests/components/http/test_data_validator.py +++ b/tests/components/http/test_data_validator.py @@ -30,8 +30,7 @@ async def get_client(aiohttp_client, validator): return b"" TestView().register(app[KEY_HASS], app, app.router) - client = await aiohttp_client(app) - return client + return await aiohttp_client(app) async def test_validator(aiohttp_client: ClientSessionGenerator) -> None: diff --git a/tests/components/insteon/test_config_flow.py b/tests/components/insteon/test_config_flow.py index ae21489bd62..7cc0eefc0b5 100644 --- a/tests/components/insteon/test_config_flow.py +++ b/tests/components/insteon/test_config_flow.py @@ -95,11 +95,10 @@ async def _init_form(hass, modem_type): ) assert result["type"] is FlowResultType.MENU - result2 = await hass.config_entries.flow.async_configure( + return await hass.config_entries.flow.async_configure( result["flow_id"], {"next_step_id": modem_type}, ) - return result2 async def _device_form(hass, flow_id, connection, user_input): @@ -303,11 +302,10 @@ async def _options_init_form(hass, entry_id, step): assert result["type"] is FlowResultType.MENU assert result["step_id"] == "init" - result2 = await hass.config_entries.options.async_configure( + return await hass.config_entries.options.async_configure( result["flow_id"], {"next_step_id": step}, ) - return result2 async def _options_form( diff --git a/tests/components/lcn/conftest.py b/tests/components/lcn/conftest.py index 2e50f20561e..6571b63ddf1 100644 --- a/tests/components/lcn/conftest.py +++ b/tests/components/lcn/conftest.py @@ -68,14 +68,13 @@ def create_config_entry(name): title = entry_data[CONF_HOST] unique_id = fixture_filename - entry = MockConfigEntry( + return MockConfigEntry( domain=DOMAIN, title=title, unique_id=unique_id, data=entry_data, options=options, ) - return entry @pytest.fixture diff --git a/tests/components/lookin/__init__.py b/tests/components/lookin/__init__.py index e19bdc9fd73..cea0f969893 100644 --- a/tests/components/lookin/__init__.py +++ b/tests/components/lookin/__init__.py @@ -31,13 +31,11 @@ ZEROCONF_DATA = ZeroconfServiceInfo( def _mocked_climate() -> Climate: - climate = MagicMock(auto_spec=Climate) - return climate + return MagicMock(auto_spec=Climate) def _mocked_remote() -> Remote: - remote = MagicMock(auto_spec=Remote) - return remote + return MagicMock(auto_spec=Remote) def _mocked_device() -> Device: diff --git a/tests/components/minecraft_server/test_init.py b/tests/components/minecraft_server/test_init.py index 8ac2e7ca04d..6f7a49a190c 100644 --- a/tests/components/minecraft_server/test_init.py +++ b/tests/components/minecraft_server/test_init.py @@ -108,13 +108,11 @@ def create_v1_mock_binary_sensor_entity_entry( device_id=device_entry_id, ) assert entity_entry.unique_id == entity_unique_id - binary_sensor_entity_id_key_mapping = { + return { "entity_id": entity_entry.entity_id, "key": BINARY_SENSOR_KEYS["v2"], } - return binary_sensor_entity_id_key_mapping - async def test_setup_and_unload_entry( hass: HomeAssistant, java_mock_config_entry: MockConfigEntry diff --git a/tests/components/modern_forms/__init__.py b/tests/components/modern_forms/__init__.py index 65de87c333d..ae4e5bd9862 100644 --- a/tests/components/modern_forms/__init__.py +++ b/tests/components/modern_forms/__init__.py @@ -19,10 +19,9 @@ async def modern_forms_call_mock(method, url, data): fixture = "modern_forms/device_info.json" else: fixture = "modern_forms/device_status.json" - response = AiohttpClientMockResponse( + return AiohttpClientMockResponse( method=method, url=url, json=json.loads(load_fixture(fixture)) ) - return response async def modern_forms_no_light_call_mock(method, url, data): @@ -31,10 +30,9 @@ async def modern_forms_no_light_call_mock(method, url, data): fixture = "modern_forms/device_info_no_light.json" else: fixture = "modern_forms/device_status_no_light.json" - response = AiohttpClientMockResponse( + return AiohttpClientMockResponse( method=method, url=url, json=json.loads(load_fixture(fixture)) ) - return response async def modern_forms_timers_set_mock(method, url, data): @@ -43,10 +41,9 @@ async def modern_forms_timers_set_mock(method, url, data): fixture = "modern_forms/device_info.json" else: fixture = "modern_forms/device_status_timers_active.json" - response = AiohttpClientMockResponse( + return AiohttpClientMockResponse( method=method, url=url, json=json.loads(load_fixture(fixture)) ) - return response async def init_integration( diff --git a/tests/components/mysensors/conftest.py b/tests/components/mysensors/conftest.py index bcf852e1368..e18043fda1f 100644 --- a/tests/components/mysensors/conftest.py +++ b/tests/components/mysensors/conftest.py @@ -116,7 +116,7 @@ def transport_write(transport: MagicMock) -> MagicMock: @pytest.fixture(name="serial_entry") async def serial_entry_fixture(hass: HomeAssistant) -> MockConfigEntry: """Create a config entry for a serial gateway.""" - entry = MockConfigEntry( + return MockConfigEntry( domain=DOMAIN, data={ CONF_GATEWAY_TYPE: CONF_GATEWAY_TYPE_SERIAL, @@ -125,7 +125,6 @@ async def serial_entry_fixture(hass: HomeAssistant) -> MockConfigEntry: CONF_BAUD_RATE: DEFAULT_BAUD_RATE, }, ) - return entry @pytest.fixture(name="config_entry") @@ -219,8 +218,7 @@ def cover_node_binary( ) -> Sensor: """Load the cover child node.""" nodes = update_gateway_nodes(gateway_nodes, deepcopy(cover_node_binary_state)) - node = nodes[1] - return node + return nodes[1] @pytest.fixture(name="cover_node_percentage_state", scope="session") @@ -235,8 +233,7 @@ def cover_node_percentage( ) -> Sensor: """Load the cover child node.""" nodes = update_gateway_nodes(gateway_nodes, deepcopy(cover_node_percentage_state)) - node = nodes[1] - return node + return nodes[1] @pytest.fixture(name="door_sensor_state", scope="session") @@ -249,8 +246,7 @@ def door_sensor_state_fixture() -> dict: def door_sensor(gateway_nodes: dict[int, Sensor], door_sensor_state: dict) -> Sensor: """Load the door sensor.""" nodes = update_gateway_nodes(gateway_nodes, deepcopy(door_sensor_state)) - node = nodes[1] - return node + return nodes[1] @pytest.fixture(name="gps_sensor_state", scope="session") @@ -263,8 +259,7 @@ def gps_sensor_state_fixture() -> dict: def gps_sensor(gateway_nodes: dict[int, Sensor], gps_sensor_state: dict) -> Sensor: """Load the gps sensor.""" nodes = update_gateway_nodes(gateway_nodes, deepcopy(gps_sensor_state)) - node = nodes[1] - return node + return nodes[1] @pytest.fixture(name="dimmer_node_state", scope="session") @@ -277,8 +272,7 @@ def dimmer_node_state_fixture() -> dict: def dimmer_node(gateway_nodes: dict[int, Sensor], dimmer_node_state: dict) -> Sensor: """Load the dimmer child node.""" nodes = update_gateway_nodes(gateway_nodes, deepcopy(dimmer_node_state)) - node = nodes[1] - return node + return nodes[1] @pytest.fixture(name="hvac_node_auto_state", scope="session") @@ -293,8 +287,7 @@ def hvac_node_auto( ) -> Sensor: """Load the hvac auto child node.""" nodes = update_gateway_nodes(gateway_nodes, deepcopy(hvac_node_auto_state)) - node = nodes[1] - return node + return nodes[1] @pytest.fixture(name="hvac_node_cool_state", scope="session") @@ -309,8 +302,7 @@ def hvac_node_cool( ) -> Sensor: """Load the hvac cool child node.""" nodes = update_gateway_nodes(gateway_nodes, deepcopy(hvac_node_cool_state)) - node = nodes[1] - return node + return nodes[1] @pytest.fixture(name="hvac_node_heat_state", scope="session") @@ -325,8 +317,7 @@ def hvac_node_heat( ) -> Sensor: """Load the hvac heat child node.""" nodes = update_gateway_nodes(gateway_nodes, deepcopy(hvac_node_heat_state)) - node = nodes[1] - return node + return nodes[1] @pytest.fixture(name="power_sensor_state", scope="session") @@ -339,8 +330,7 @@ def power_sensor_state_fixture() -> dict: def power_sensor(gateway_nodes: dict[int, Sensor], power_sensor_state: dict) -> Sensor: """Load the power sensor.""" nodes = update_gateway_nodes(gateway_nodes, power_sensor_state) - node = nodes[1] - return node + return nodes[1] @pytest.fixture(name="rgb_node_state", scope="session") @@ -353,8 +343,7 @@ def rgb_node_state_fixture() -> dict: def rgb_node(gateway_nodes: dict[int, Sensor], rgb_node_state: dict) -> Sensor: """Load the rgb child node.""" nodes = update_gateway_nodes(gateway_nodes, deepcopy(rgb_node_state)) - node = nodes[1] - return node + return nodes[1] @pytest.fixture(name="rgbw_node_state", scope="session") @@ -367,8 +356,7 @@ def rgbw_node_state_fixture() -> dict: def rgbw_node(gateway_nodes: dict[int, Sensor], rgbw_node_state: dict) -> Sensor: """Load the rgbw child node.""" nodes = update_gateway_nodes(gateway_nodes, deepcopy(rgbw_node_state)) - node = nodes[1] - return node + return nodes[1] @pytest.fixture(name="energy_sensor_state", scope="session") @@ -383,8 +371,7 @@ def energy_sensor( ) -> Sensor: """Load the energy sensor.""" nodes = update_gateway_nodes(gateway_nodes, energy_sensor_state) - node = nodes[1] - return node + return nodes[1] @pytest.fixture(name="sound_sensor_state", scope="session") @@ -397,8 +384,7 @@ def sound_sensor_state_fixture() -> dict: def sound_sensor(gateway_nodes: dict[int, Sensor], sound_sensor_state: dict) -> Sensor: """Load the sound sensor.""" nodes = update_gateway_nodes(gateway_nodes, sound_sensor_state) - node = nodes[1] - return node + return nodes[1] @pytest.fixture(name="distance_sensor_state", scope="session") @@ -413,8 +399,7 @@ def distance_sensor( ) -> Sensor: """Load the distance sensor.""" nodes = update_gateway_nodes(gateway_nodes, distance_sensor_state) - node = nodes[1] - return node + return nodes[1] @pytest.fixture(name="ir_transceiver_state", scope="session") @@ -429,8 +414,7 @@ def ir_transceiver( ) -> Sensor: """Load the ir transceiver child node.""" nodes = update_gateway_nodes(gateway_nodes, deepcopy(ir_transceiver_state)) - node = nodes[1] - return node + return nodes[1] @pytest.fixture(name="relay_node_state", scope="session") @@ -443,8 +427,7 @@ def relay_node_state_fixture() -> dict: def relay_node(gateway_nodes: dict[int, Sensor], relay_node_state: dict) -> Sensor: """Load the relay child node.""" nodes = update_gateway_nodes(gateway_nodes, deepcopy(relay_node_state)) - node = nodes[1] - return node + return nodes[1] @pytest.fixture(name="temperature_sensor_state", scope="session") @@ -459,8 +442,7 @@ def temperature_sensor( ) -> Sensor: """Load the temperature sensor.""" nodes = update_gateway_nodes(gateway_nodes, temperature_sensor_state) - node = nodes[1] - return node + return nodes[1] @pytest.fixture(name="text_node_state", scope="session") @@ -473,8 +455,7 @@ def text_node_state_fixture() -> dict: def text_node(gateway_nodes: dict[int, Sensor], text_node_state: dict) -> Sensor: """Load the text child node.""" nodes = update_gateway_nodes(gateway_nodes, text_node_state) - node = nodes[1] - return node + return nodes[1] @pytest.fixture(name="battery_sensor_state", scope="session") @@ -489,5 +470,4 @@ def battery_sensor( ) -> Sensor: """Load the battery sensor.""" nodes = update_gateway_nodes(gateway_nodes, deepcopy(battery_sensor_state)) - node = nodes[1] - return node + return nodes[1] diff --git a/tests/components/nest/test_media_source.py b/tests/components/nest/test_media_source.py index 3d0ec521df2..def99633435 100644 --- a/tests/components/nest/test_media_source.py +++ b/tests/components/nest/test_media_source.py @@ -85,8 +85,7 @@ def frame_image_data(frame_i, total_frames): img[:, :, 2] = 0.5 + 0.5 * np.sin(2 * np.pi * (2 / 3 + frame_i / total_frames)) img = np.round(255 * img).astype(np.uint8) - img = np.clip(img, 0, 255) - return img + return np.clip(img, 0, 255) @pytest.fixture diff --git a/tests/components/nextcloud/conftest.py b/tests/components/nextcloud/conftest.py index 0ea281abb49..58b37359d42 100644 --- a/tests/components/nextcloud/conftest.py +++ b/tests/components/nextcloud/conftest.py @@ -9,12 +9,10 @@ import pytest @pytest.fixture def mock_nextcloud_monitor() -> Mock: """Mock of NextcloudMonitor.""" - ncm = Mock( + return Mock( update=Mock(return_value=True), ) - return ncm - @pytest.fixture def mock_setup_entry() -> Generator[AsyncMock, None, None]: diff --git a/tests/components/overkiz/__init__.py b/tests/components/overkiz/__init__.py index e7d729ea41c..48d6055f23a 100644 --- a/tests/components/overkiz/__init__.py +++ b/tests/components/overkiz/__init__.py @@ -11,6 +11,4 @@ def load_setup_fixture( ) -> Setup: """Return setup from fixture.""" setup_json = load_json_object_fixture(fixture) - setup = Setup(**humps.decamelize(setup_json)) - - return setup + return Setup(**humps.decamelize(setup_json)) diff --git a/tests/components/plex/conftest.py b/tests/components/plex/conftest.py index d6c91a9d9a8..7e82b1c9d26 100644 --- a/tests/components/plex/conftest.py +++ b/tests/components/plex/conftest.py @@ -599,8 +599,7 @@ def setup_plex_server( websocket_connected(mock_websocket) await hass.async_block_till_done() - plex_server = hass.data[DOMAIN][SERVERS][entry.unique_id] - return plex_server + return hass.data[DOMAIN][SERVERS][entry.unique_id] return _wrapper diff --git a/tests/components/ps4/test_media_player.py b/tests/components/ps4/test_media_player.py index 6adcad03016..e0be9d508fc 100644 --- a/tests/components/ps4/test_media_player.py +++ b/tests/components/ps4/test_media_player.py @@ -147,9 +147,7 @@ async def setup_mock_component(hass, entry=None): mock_entities = hass.states.async_entity_ids() - mock_entity_id = mock_entities[0] - - return mock_entity_id + return mock_entities[0] async def mock_ddp_response(hass, mock_status_data): diff --git a/tests/components/refoss/__init__.py b/tests/components/refoss/__init__.py index e7c160ef0af..51c4261b954 100644 --- a/tests/components/refoss/__init__.py +++ b/tests/components/refoss/__init__.py @@ -62,7 +62,7 @@ class FakeDiscovery: def build_device_mock(name="r10", ip="1.1.1.1", mac="aabbcc112233"): """Build mock device object.""" - mock = Mock( + return Mock( uuid="abc", dev_name=name, device_type="r10", @@ -74,7 +74,6 @@ def build_device_mock(name="r10", ip="1.1.1.1", mac="aabbcc112233"): sub_type="eu", channels=[0], ) - return mock def build_base_device_mock(name="r10", ip="1.1.1.1", mac="aabbcc112233"): diff --git a/tests/components/shopping_list/test_todo.py b/tests/components/shopping_list/test_todo.py index fb6f61d4edf..173544d0be2 100644 --- a/tests/components/shopping_list/test_todo.py +++ b/tests/components/shopping_list/test_todo.py @@ -53,8 +53,7 @@ async def ws_move_item( if previous_uid is not None: data["previous_uid"] = previous_uid await client.send_json_auto_id(data) - resp = await client.receive_json() - return resp + return await client.receive_json() return move diff --git a/tests/components/smtp/test_notify.py b/tests/components/smtp/test_notify.py index dd51cf15992..15be7b66d27 100644 --- a/tests/components/smtp/test_notify.py +++ b/tests/components/smtp/test_notify.py @@ -72,7 +72,7 @@ async def test_reload_notify(hass: HomeAssistant) -> None: @pytest.fixture def message(): """Return MockSMTP object with test data.""" - mailer = MockSMTP( + return MockSMTP( "localhost", 25, 5, @@ -85,7 +85,6 @@ def message(): 0, True, ) - return mailer HTML = """ diff --git a/tests/components/srp_energy/conftest.py b/tests/components/srp_energy/conftest.py index c2cc6d5e1a4..12fa7ffd6d6 100644 --- a/tests/components/srp_energy/conftest.py +++ b/tests/components/srp_energy/conftest.py @@ -36,8 +36,7 @@ def fixture_hass_tz_info(hass: HomeAssistant, setup_hass_config) -> dt.tzinfo | @pytest.fixture(name="test_date") def fixture_test_date(hass: HomeAssistant, hass_tz_info) -> dt.datetime | None: """Return test datetime for the hass timezone.""" - test_date = dt.datetime(2022, 8, 2, 0, 0, 0, 0, tzinfo=hass_tz_info) - return test_date + return dt.datetime(2022, 8, 2, 0, 0, 0, 0, tzinfo=hass_tz_info) @pytest.fixture(name="mock_config_entry") diff --git a/tests/components/stream/common.py b/tests/components/stream/common.py index ab42141c667..e642b209146 100644 --- a/tests/components/stream/common.py +++ b/tests/components/stream/common.py @@ -59,8 +59,7 @@ def frame_image_data(frame_i, total_frames): img[:, :, 2] = 0.5 + 0.5 * np.sin(2 * np.pi * (2 / 3 + frame_i / total_frames)) img = np.round(255 * img).astype(np.uint8) - img = np.clip(img, 0, 255) - return img + return np.clip(img, 0, 255) def generate_video(encoder, container_format, duration): diff --git a/tests/components/tesla_wall_connector/conftest.py b/tests/components/tesla_wall_connector/conftest.py index a31df11dcd0..e10ae190a59 100644 --- a/tests/components/tesla_wall_connector/conftest.py +++ b/tests/components/tesla_wall_connector/conftest.py @@ -88,14 +88,12 @@ async def create_wall_connector_entry( def get_vitals_mock() -> Vitals: """Get mocked vitals object.""" - vitals = MagicMock(auto_spec=Vitals) - return vitals + return MagicMock(auto_spec=Vitals) def get_lifetime_mock() -> Lifetime: """Get mocked lifetime object.""" - lifetime = MagicMock(auto_spec=Lifetime) - return lifetime + return MagicMock(auto_spec=Lifetime) @dataclass diff --git a/tests/components/transport_nsw/test_sensor.py b/tests/components/transport_nsw/test_sensor.py index 9ecff818592..80df947dbe7 100644 --- a/tests/components/transport_nsw/test_sensor.py +++ b/tests/components/transport_nsw/test_sensor.py @@ -19,7 +19,7 @@ VALID_CONFIG = { def get_departuresMock(_stop_id, route, destination, api_key): """Mock TransportNSW departures loading.""" - data = { + return { "stop_id": "209516", "route": "199", "due": 16, @@ -28,7 +28,6 @@ def get_departuresMock(_stop_id, route, destination, api_key): "destination": "Palm Beach", "mode": "Bus", } - return data @patch("TransportNSW.TransportNSW.get_departures", side_effect=get_departuresMock) @@ -50,7 +49,7 @@ async def test_transportnsw_config(mocked_get_departures, hass: HomeAssistant) - def get_departuresMock_notFound(_stop_id, route, destination, api_key): """Mock TransportNSW departures loading.""" - data = { + return { "stop_id": "n/a", "route": "n/a", "due": "n/a", @@ -59,7 +58,6 @@ def get_departuresMock_notFound(_stop_id, route, destination, api_key): "destination": "n/a", "mode": "n/a", } - return data @patch( diff --git a/tests/components/upb/test_config_flow.py b/tests/components/upb/test_config_flow.py index 3a82eaa0ae7..5eaed2e3a24 100644 --- a/tests/components/upb/test_config_flow.py +++ b/tests/components/upb/test_config_flow.py @@ -34,11 +34,10 @@ async def valid_tcp_flow(hass, sync_complete=True, config_ok=True): flow = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - result = await hass.config_entries.flow.async_configure( + return await hass.config_entries.flow.async_configure( flow["flow_id"], {"protocol": "TCP", "address": "1.2.3.4", "file_path": "upb.upe"}, ) - return result async def test_full_upb_flow_with_serial_port(hass: HomeAssistant) -> None: diff --git a/tests/components/vesync/conftest.py b/tests/components/vesync/conftest.py index 23e0938cce6..5500ef1a55f 100644 --- a/tests/components/vesync/conftest.py +++ b/tests/components/vesync/conftest.py @@ -71,15 +71,13 @@ def manager_fixture() -> VeSync: @pytest.fixture(name="fan") def fan_fixture(): """Create a mock VeSync fan fixture.""" - mock_fixture = Mock(VeSyncAirBypass) - return mock_fixture + return Mock(VeSyncAirBypass) @pytest.fixture(name="bulb") def bulb_fixture(): """Create a mock VeSync bulb fixture.""" - mock_fixture = Mock(VeSyncBulb) - return mock_fixture + return Mock(VeSyncBulb) @pytest.fixture(name="switch") @@ -101,5 +99,4 @@ def dimmable_switch_fixture(): @pytest.fixture(name="outlet") def outlet_fixture(): """Create a mock VeSync outlet fixture.""" - mock_fixture = Mock(VeSyncOutlet) - return mock_fixture + return Mock(VeSyncOutlet) diff --git a/tests/components/zha/conftest.py b/tests/components/zha/conftest.py index 254cf13c556..7d3722b5037 100644 --- a/tests/components/zha/conftest.py +++ b/tests/components/zha/conftest.py @@ -422,12 +422,11 @@ def zha_device_mock( zigpy_device = zigpy_device_mock( endpoints, ieee, manufacturer, model, node_desc, patch_cluster=patch_cluster ) - zha_device = zha_core_device.ZHADevice( + return zha_core_device.ZHADevice( hass, zigpy_device, ZHAGateway(hass, {}, config_entry), ) - return zha_device return _zha_device diff --git a/tests/components/zha/test_cluster_handlers.py b/tests/components/zha/test_cluster_handlers.py index b8fbd071a6d..ca21b74e106 100644 --- a/tests/components/zha/test_cluster_handlers.py +++ b/tests/components/zha/test_cluster_handlers.py @@ -119,8 +119,7 @@ async def poll_control_device(zha_device_restored, zigpy_device_mock): "test model", ) - zha_device = await zha_device_restored(zigpy_dev) - return zha_device + return await zha_device_restored(zigpy_dev) @pytest.mark.parametrize( diff --git a/tests/components/zha/test_device.py b/tests/components/zha/test_device.py index 289442b3466..fefc68a8d94 100644 --- a/tests/components/zha/test_device.py +++ b/tests/components/zha/test_device.py @@ -115,8 +115,7 @@ async def ota_zha_device(zha_device_restored, zigpy_device_mock): "test model", ) - zha_device = await zha_device_restored(zigpy_dev) - return zha_device + return await zha_device_restored(zigpy_dev) def _send_time_changed(hass, seconds): diff --git a/tests/components/zha/test_gateway.py b/tests/components/zha/test_gateway.py index d090ac8aba0..666594bd854 100644 --- a/tests/components/zha/test_gateway.py +++ b/tests/components/zha/test_gateway.py @@ -60,8 +60,7 @@ def required_platform_only(): async def zha_dev_basic(hass, zha_device_restored, zigpy_dev_basic): """ZHA device with just a basic cluster.""" - zha_device = await zha_device_restored(zigpy_dev_basic) - return zha_device + return await zha_device_restored(zigpy_dev_basic) @pytest.fixture diff --git a/tests/components/zha/test_number.py b/tests/components/zha/test_number.py index 6bb1703a229..b3fc42c35df 100644 --- a/tests/components/zha/test_number.py +++ b/tests/components/zha/test_number.py @@ -61,7 +61,7 @@ def zigpy_analog_output_device(zigpy_device_mock): async def light(zigpy_device_mock): """Siren fixture.""" - zigpy_device = zigpy_device_mock( + return zigpy_device_mock( { 1: { SIG_EP_PROFILE: zha.PROFILE_ID, @@ -79,8 +79,6 @@ async def light(zigpy_device_mock): node_descriptor=b"\x02@\x84_\x11\x7fd\x00\x00,d\x00\x00", ) - return zigpy_device - async def test_number( hass: HomeAssistant, zha_device_joined_restored, zigpy_analog_output_device diff --git a/tests/components/zha/test_select.py b/tests/components/zha/test_select.py index 97aed05dcd3..1d3811d0293 100644 --- a/tests/components/zha/test_select.py +++ b/tests/components/zha/test_select.py @@ -72,7 +72,7 @@ async def siren(hass, zigpy_device_mock, zha_device_joined_restored): async def light(hass, zigpy_device_mock): """Siren fixture.""" - zigpy_device = zigpy_device_mock( + return zigpy_device_mock( { 1: { SIG_EP_PROFILE: zha.PROFILE_ID, @@ -88,8 +88,6 @@ async def light(hass, zigpy_device_mock): node_descriptor=b"\x02@\x84_\x11\x7fd\x00\x00,d\x00\x00", ) - return zigpy_device - @pytest.fixture def core_rs(hass_storage): diff --git a/tests/components/zha/test_update.py b/tests/components/zha/test_update.py index 60cd5bf9ff9..32be013e673 100644 --- a/tests/components/zha/test_update.py +++ b/tests/components/zha/test_update.py @@ -229,7 +229,7 @@ def make_packet(zigpy_device, cluster, cmd_name: str, **kwargs): kwargs=kwargs, ) - ota_packet = t.ZigbeePacket( + return t.ZigbeePacket( src=t.AddrModeAddress(addr_mode=t.AddrMode.NWK, address=zigpy_device.nwk), src_ep=1, dst=t.AddrModeAddress(addr_mode=t.AddrMode.NWK, address=0x0000), @@ -242,8 +242,6 @@ def make_packet(zigpy_device, cluster, cmd_name: str, **kwargs): rssi=-30, ) - return ota_packet - @patch("zigpy.device.AFTER_OTA_ATTR_READ_DELAY", 0.01) async def test_firmware_update_success( diff --git a/tests/components/zwave_js/conftest.py b/tests/components/zwave_js/conftest.py index 98453071bc1..dbf7357d4a0 100644 --- a/tests/components/zwave_js/conftest.py +++ b/tests/components/zwave_js/conftest.py @@ -966,8 +966,7 @@ def aeotec_radiator_thermostat_fixture(client, aeotec_radiator_thermostat_state) def nortek_thermostat_added_event_fixture(client): """Mock a Nortek thermostat node added event.""" event_data = json.loads(load_fixture("zwave_js/nortek_thermostat_added_event.json")) - event = Event("node added", event_data) - return event + return Event("node added", event_data) @pytest.fixture(name="nortek_thermostat_removed_event") @@ -976,8 +975,7 @@ def nortek_thermostat_removed_event_fixture(client): event_data = json.loads( load_fixture("zwave_js/nortek_thermostat_removed_event.json") ) - event = Event("node removed", event_data) - return event + return Event("node removed", event_data) @pytest.fixture(name="integration") diff --git a/tests/hassfest/test_requirements.py b/tests/hassfest/test_requirements.py index 7cb08621e83..f3b008a6113 100644 --- a/tests/hassfest/test_requirements.py +++ b/tests/hassfest/test_requirements.py @@ -11,7 +11,7 @@ from script.hassfest.requirements import validate_requirements_format @pytest.fixture def integration(): """Fixture for hassfest integration model.""" - integration = Integration( + return Integration( path=Path("homeassistant/components/test"), _manifest={ "domain": "test", @@ -21,7 +21,6 @@ def integration(): "requirements": [], }, ) - return integration def test_validate_requirements_format_with_space(integration: Integration) -> None: diff --git a/tests/helpers/test_update_coordinator.py b/tests/helpers/test_update_coordinator.py index 25f72d76e3c..be1bbf0580e 100644 --- a/tests/helpers/test_update_coordinator.py +++ b/tests/helpers/test_update_coordinator.py @@ -63,14 +63,13 @@ def get_crd( calls += 1 return calls - crd = update_coordinator.DataUpdateCoordinator[int]( + return update_coordinator.DataUpdateCoordinator[int]( hass, _LOGGER, name="test", update_method=refresh, update_interval=update_interval, ) - return crd DEFAULT_UPDATE_INTERVAL = timedelta(seconds=10) diff --git a/tests/util/test_ssl.py b/tests/util/test_ssl.py index 4a88e061cbc..d0c7ce3bfb6 100644 --- a/tests/util/test_ssl.py +++ b/tests/util/test_ssl.py @@ -15,8 +15,7 @@ from homeassistant.util.ssl import ( @pytest.fixture def mock_sslcontext(): """Mock the ssl lib.""" - ssl_mock = MagicMock(set_ciphers=Mock(return_value=True)) - return ssl_mock + return MagicMock(set_ciphers=Mock(return_value=True)) def test_client_context(mock_sslcontext) -> None: