Cleanup unnecessary returns (#121652)

This commit is contained in:
epenet 2024-07-10 15:11:56 +02:00 committed by GitHub
parent b0837dd98f
commit e812b0e02f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 9 additions and 15 deletions

View File

@ -123,7 +123,7 @@ class DiscordNotificationService(BaseNotificationService):
if ATTR_TARGET not in kwargs: if ATTR_TARGET not in kwargs:
_LOGGER.error("No target specified") _LOGGER.error("No target specified")
return None return
data = kwargs.get(ATTR_DATA) or {} data = kwargs.get(ATTR_DATA) or {}

View File

@ -174,10 +174,9 @@ class InputButton(collection.CollectionEntity, ButtonEntity, RestoreEntity):
async def async_press(self) -> None: async def async_press(self) -> None:
"""Press the button. """Press the button.
Left emtpty intentionally. Left empty intentionally.
The input button itself doesn't trigger anything. The input button itself doesn't trigger anything.
""" """
return None
async def async_update_config(self, config: ConfigType) -> None: async def async_update_config(self, config: ConfigType) -> None:
"""Handle when the config is updated.""" """Handle when the config is updated."""

View File

@ -317,7 +317,7 @@ async def async_setup_trigger(
) )
send_discovery_done(hass, discovery_data) send_discovery_done(hass, discovery_data)
clear_discovery_hash(hass, discovery_data[ATTR_DISCOVERY_HASH]) clear_discovery_hash(hass, discovery_data[ATTR_DISCOVERY_HASH])
return None return
if TYPE_CHECKING: if TYPE_CHECKING:
assert isinstance(device_id, str) assert isinstance(device_id, str)

View File

@ -106,16 +106,15 @@ class NeurioData:
"""Return latest active power value.""" """Return latest active power value."""
return self._active_power return self._active_power
def get_active_power(self): def get_active_power(self) -> None:
"""Return current power value.""" """Return current power value."""
try: try:
sample = self.neurio_client.get_samples_live_last(self.sensor_id) sample = self.neurio_client.get_samples_live_last(self.sensor_id)
self._active_power = sample["consumptionPower"] self._active_power = sample["consumptionPower"]
except (requests.exceptions.RequestException, ValueError, KeyError): except (requests.exceptions.RequestException, ValueError, KeyError):
_LOGGER.warning("Could not update current power usage") _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.""" """Return current daily power usage."""
kwh = 0 kwh = 0
start_time = dt_util.start_of_local_day().astimezone(dt_util.UTC).isoformat() 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): except (requests.exceptions.RequestException, ValueError, KeyError):
_LOGGER.warning("Could not update daily power usage") _LOGGER.warning("Could not update daily power usage")
return None return
for result in history: for result in history:
kwh += result["consumptionEnergy"] / 3600000 kwh += result["consumptionEnergy"] / 3600000

View File

@ -30,7 +30,7 @@ class DiscoveryService(Listener):
device = await async_build_base_device(device_info) device = await async_build_base_device(device_info)
if device is None: if device is None:
return None return
coordo = RefossDataUpdateCoordinator(self.hass, device) coordo = RefossDataUpdateCoordinator(self.hass, device)
self.hass.data[DOMAIN][COORDINATORS].append(coordo) self.hass.data[DOMAIN][COORDINATORS].append(coordo)

View File

@ -30,7 +30,7 @@ async def async_setup_platform(
) -> None: ) -> None:
"""Set up the sensor platform.""" """Set up the sensor platform."""
if discovery_info is None: if discovery_info is None:
return None return
consumer = hass.data[DOMAIN][KEY_CONSUMER] consumer = hass.data[DOMAIN][KEY_CONSUMER]

View File

@ -33,7 +33,7 @@ async def async_setup_platform(
) -> None: ) -> None:
"""Set up actuator platform.""" """Set up actuator platform."""
if discovery_info is None: if discovery_info is None:
return None return
consumer = hass.data[DOMAIN][KEY_CONSUMER] consumer = hass.data[DOMAIN][KEY_CONSUMER]

View File

@ -922,7 +922,6 @@ class WeatherEntity(Entity, PostInit, cached_properties=CACHED_PROPERTIES_WITH_A
forecast_type: Literal["daily", "hourly", "twice_daily"], forecast_type: Literal["daily", "hourly", "twice_daily"],
) -> None: ) -> None:
"""Start subscription to forecast_type.""" """Start subscription to forecast_type."""
return None
@callback @callback
def _async_subscription_ended( 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"], forecast_type: Literal["daily", "hourly", "twice_daily"],
) -> None: ) -> None:
"""End subscription to forecast_type.""" """End subscription to forecast_type."""
return None
@final @final
@callback @callback

View File

@ -129,13 +129,11 @@ class Throttle:
async def throttled_value() -> None: async def throttled_value() -> None:
"""Stand-in function for when real func is being throttled.""" """Stand-in function for when real func is being throttled."""
return None
else: else:
def throttled_value() -> None: # type: ignore[misc] def throttled_value() -> None: # type: ignore[misc]
"""Stand-in function for when real func is being throttled.""" """Stand-in function for when real func is being throttled."""
return None
if self.limit_no_throttle is not None: if self.limit_no_throttle is not None:
method = Throttle(self.limit_no_throttle)(method) method = Throttle(self.limit_no_throttle)(method)