mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Replace assert False by raising an error (#86686)
This commit is contained in:
parent
adeaf746ec
commit
d4955a3d87
@ -60,7 +60,7 @@ def _str_to_multi_color_effect(effect_str: str) -> MultiColorEffects:
|
|||||||
if effect.name.lower() == effect_str:
|
if effect.name.lower() == effect_str:
|
||||||
return effect
|
return effect
|
||||||
# unreachable due to schema validation
|
# unreachable due to schema validation
|
||||||
assert False # pragma: no cover
|
raise RuntimeError # pragma: no cover
|
||||||
|
|
||||||
|
|
||||||
def _is_zero_rgb_brightness(rgb: tuple[int, int, int]) -> bool:
|
def _is_zero_rgb_brightness(rgb: tuple[int, int, int]) -> bool:
|
||||||
|
@ -157,9 +157,9 @@ def request_handler_factory(
|
|||||||
elif result is None:
|
elif result is None:
|
||||||
bresult = b""
|
bresult = b""
|
||||||
else:
|
else:
|
||||||
assert (
|
raise TypeError(
|
||||||
False
|
f"Result should be None, string, bytes or StreamResponse. Got: {result}"
|
||||||
), f"Result should be None, string, bytes or StreamResponse. Got: {result}"
|
)
|
||||||
|
|
||||||
return web.Response(body=bresult, status=status_code)
|
return web.Response(body=bresult, status=status_code)
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ class ControllerDevice(ClimateEntity):
|
|||||||
for (key, value) in self._state_to_pizone.items():
|
for (key, value) in self._state_to_pizone.items():
|
||||||
if value == mode:
|
if value == mode:
|
||||||
return key
|
return key
|
||||||
assert False, "Should be unreachable"
|
raise RuntimeError("Should be unreachable")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@_return_on_connection_error([])
|
@_return_on_connection_error([])
|
||||||
|
@ -172,7 +172,8 @@ def execute(
|
|||||||
raise
|
raise
|
||||||
time.sleep(QUERY_RETRY_WAIT)
|
time.sleep(QUERY_RETRY_WAIT)
|
||||||
|
|
||||||
assert False # unreachable # pragma: no cover
|
# Unreachable
|
||||||
|
raise RuntimeError # pragma: no cover
|
||||||
|
|
||||||
|
|
||||||
def execute_stmt_lambda_element(
|
def execute_stmt_lambda_element(
|
||||||
@ -206,7 +207,8 @@ def execute_stmt_lambda_element(
|
|||||||
raise
|
raise
|
||||||
time.sleep(QUERY_RETRY_WAIT)
|
time.sleep(QUERY_RETRY_WAIT)
|
||||||
|
|
||||||
assert False # unreachable # pragma: no cover
|
# Unreachable
|
||||||
|
raise RuntimeError # pragma: no cover
|
||||||
|
|
||||||
|
|
||||||
def validate_or_move_away_sqlite_database(dburl: str) -> bool:
|
def validate_or_move_away_sqlite_database(dburl: str) -> bool:
|
||||||
|
@ -116,7 +116,8 @@ class WemoSwitch(WemoBinaryStateEntity, SwitchEntity):
|
|||||||
if standby_state == StandbyState.STANDBY:
|
if standby_state == StandbyState.STANDBY:
|
||||||
return STATE_STANDBY
|
return STATE_STANDBY
|
||||||
return STATE_UNKNOWN
|
return STATE_UNKNOWN
|
||||||
assert False # Unreachable code statement.
|
# Unreachable code statement.
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self) -> str | None:
|
def icon(self) -> str | None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user