From e812b0e02f27e731b731e902b438957cdf360632 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 10 Jul 2024 15:11:56 +0200 Subject: [PATCH] Cleanup unnecessary returns (#121652) --- homeassistant/components/discord/notify.py | 2 +- homeassistant/components/input_button/__init__.py | 3 +-- homeassistant/components/mqtt/device_trigger.py | 2 +- homeassistant/components/neurio_energy/sensor.py | 7 +++---- homeassistant/components/refoss/bridge.py | 2 +- homeassistant/components/versasense/sensor.py | 2 +- homeassistant/components/versasense/switch.py | 2 +- homeassistant/components/weather/__init__.py | 2 -- homeassistant/util/__init__.py | 2 -- 9 files changed, 9 insertions(+), 15 deletions(-) diff --git a/homeassistant/components/discord/notify.py b/homeassistant/components/discord/notify.py index 5f1e494c97e..c574b458333 100644 --- a/homeassistant/components/discord/notify.py +++ b/homeassistant/components/discord/notify.py @@ -123,7 +123,7 @@ class DiscordNotificationService(BaseNotificationService): if ATTR_TARGET not in kwargs: _LOGGER.error("No target specified") - return None + return data = kwargs.get(ATTR_DATA) or {} diff --git a/homeassistant/components/input_button/__init__.py b/homeassistant/components/input_button/__init__.py index 47ec36969c6..1488d80a1f5 100644 --- a/homeassistant/components/input_button/__init__.py +++ b/homeassistant/components/input_button/__init__.py @@ -174,10 +174,9 @@ class InputButton(collection.CollectionEntity, ButtonEntity, RestoreEntity): async def async_press(self) -> None: """Press the button. - Left emtpty intentionally. + Left empty intentionally. The input button itself doesn't trigger anything. """ - return None async def async_update_config(self, config: ConfigType) -> None: """Handle when the config is updated.""" diff --git a/homeassistant/components/mqtt/device_trigger.py b/homeassistant/components/mqtt/device_trigger.py index bd02b95a311..911dce163f9 100644 --- a/homeassistant/components/mqtt/device_trigger.py +++ b/homeassistant/components/mqtt/device_trigger.py @@ -317,7 +317,7 @@ async def async_setup_trigger( ) send_discovery_done(hass, discovery_data) clear_discovery_hash(hass, discovery_data[ATTR_DISCOVERY_HASH]) - return None + return if TYPE_CHECKING: assert isinstance(device_id, str) diff --git a/homeassistant/components/neurio_energy/sensor.py b/homeassistant/components/neurio_energy/sensor.py index a02a37b740d..5c6482da59a 100644 --- a/homeassistant/components/neurio_energy/sensor.py +++ b/homeassistant/components/neurio_energy/sensor.py @@ -106,16 +106,15 @@ class NeurioData: """Return latest active power value.""" return self._active_power - def get_active_power(self): + def get_active_power(self) -> None: """Return current power value.""" try: sample = self.neurio_client.get_samples_live_last(self.sensor_id) self._active_power = sample["consumptionPower"] except (requests.exceptions.RequestException, ValueError, KeyError): _LOGGER.warning("Could not update current power usage") - return None - def get_daily_usage(self): + def get_daily_usage(self) -> None: """Return current daily power usage.""" kwh = 0 start_time = dt_util.start_of_local_day().astimezone(dt_util.UTC).isoformat() @@ -129,7 +128,7 @@ class NeurioData: ) except (requests.exceptions.RequestException, ValueError, KeyError): _LOGGER.warning("Could not update daily power usage") - return None + return for result in history: kwh += result["consumptionEnergy"] / 3600000 diff --git a/homeassistant/components/refoss/bridge.py b/homeassistant/components/refoss/bridge.py index f7bb526d11a..82cc2540f6c 100644 --- a/homeassistant/components/refoss/bridge.py +++ b/homeassistant/components/refoss/bridge.py @@ -30,7 +30,7 @@ class DiscoveryService(Listener): device = await async_build_base_device(device_info) if device is None: - return None + return coordo = RefossDataUpdateCoordinator(self.hass, device) self.hass.data[DOMAIN][COORDINATORS].append(coordo) diff --git a/homeassistant/components/versasense/sensor.py b/homeassistant/components/versasense/sensor.py index 59d092ccdc1..4c861bf5787 100644 --- a/homeassistant/components/versasense/sensor.py +++ b/homeassistant/components/versasense/sensor.py @@ -30,7 +30,7 @@ async def async_setup_platform( ) -> None: """Set up the sensor platform.""" if discovery_info is None: - return None + return consumer = hass.data[DOMAIN][KEY_CONSUMER] diff --git a/homeassistant/components/versasense/switch.py b/homeassistant/components/versasense/switch.py index 195045882ff..10bca79e536 100644 --- a/homeassistant/components/versasense/switch.py +++ b/homeassistant/components/versasense/switch.py @@ -33,7 +33,7 @@ async def async_setup_platform( ) -> None: """Set up actuator platform.""" if discovery_info is None: - return None + return consumer = hass.data[DOMAIN][KEY_CONSUMER] diff --git a/homeassistant/components/weather/__init__.py b/homeassistant/components/weather/__init__.py index 468c023b470..dab3394426e 100644 --- a/homeassistant/components/weather/__init__.py +++ b/homeassistant/components/weather/__init__.py @@ -922,7 +922,6 @@ class WeatherEntity(Entity, PostInit, cached_properties=CACHED_PROPERTIES_WITH_A forecast_type: Literal["daily", "hourly", "twice_daily"], ) -> None: """Start subscription to forecast_type.""" - return None @callback def _async_subscription_ended( @@ -930,7 +929,6 @@ class WeatherEntity(Entity, PostInit, cached_properties=CACHED_PROPERTIES_WITH_A forecast_type: Literal["daily", "hourly", "twice_daily"], ) -> None: """End subscription to forecast_type.""" - return None @final @callback diff --git a/homeassistant/util/__init__.py b/homeassistant/util/__init__.py index c9aa2817640..c2d825a1676 100644 --- a/homeassistant/util/__init__.py +++ b/homeassistant/util/__init__.py @@ -129,13 +129,11 @@ class Throttle: async def throttled_value() -> None: """Stand-in function for when real func is being throttled.""" - return None else: def throttled_value() -> None: # type: ignore[misc] """Stand-in function for when real func is being throttled.""" - return None if self.limit_no_throttle is not None: method = Throttle(self.limit_no_throttle)(method)