Use assignment expressions 24 (#58181)
This commit is contained in:
parent
eab235173b
commit
ea2e94a4e5
21 changed files with 29 additions and 66 deletions
|
@ -103,9 +103,7 @@ async def _async_validate_usage_stat(
|
|||
)
|
||||
return
|
||||
|
||||
state = hass.states.get(entity_id)
|
||||
|
||||
if state is None:
|
||||
if (state := hass.states.get(entity_id)) is None:
|
||||
result.append(
|
||||
ValidationIssue(
|
||||
"entity_not_defined",
|
||||
|
@ -180,9 +178,7 @@ def _async_validate_price_entity(
|
|||
unit_error: str,
|
||||
) -> None:
|
||||
"""Validate that the price entity is correct."""
|
||||
state = hass.states.get(entity_id)
|
||||
|
||||
if state is None:
|
||||
if (state := hass.states.get(entity_id)) is None:
|
||||
result.append(
|
||||
ValidationIssue(
|
||||
"entity_not_defined",
|
||||
|
@ -228,9 +224,7 @@ async def _async_validate_cost_stat(
|
|||
if not recorder.is_entity_recorded(hass, stat_id):
|
||||
result.append(ValidationIssue("recorder_untracked", stat_id))
|
||||
|
||||
state = hass.states.get(stat_id)
|
||||
|
||||
if state is None:
|
||||
if (state := hass.states.get(stat_id)) is None:
|
||||
result.append(ValidationIssue("entity_not_defined", stat_id))
|
||||
return
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue