Use assignment expressions 11 (#57792)
This commit is contained in:
parent
238b488642
commit
aa7dc78a1e
25 changed files with 45 additions and 111 deletions
|
@ -83,8 +83,7 @@ def has_date_or_time(conf):
|
|||
|
||||
def valid_initial(conf):
|
||||
"""Check the initial value is valid."""
|
||||
initial = conf.get(CONF_INITIAL)
|
||||
if not initial:
|
||||
if not (initial := conf.get(CONF_INITIAL)):
|
||||
return conf
|
||||
|
||||
if conf[CONF_HAS_DATE] and conf[CONF_HAS_TIME]:
|
||||
|
@ -226,8 +225,7 @@ class InputDatetime(RestoreEntity):
|
|||
self.editable = True
|
||||
self._current_datetime = None
|
||||
|
||||
initial = config.get(CONF_INITIAL)
|
||||
if not initial:
|
||||
if not (initial := config.get(CONF_INITIAL)):
|
||||
return
|
||||
|
||||
if self.has_date and self.has_time:
|
||||
|
|
|
@ -41,9 +41,7 @@ async def _async_reproduce_state(
|
|||
reproduce_options: dict[str, Any] | None = None,
|
||||
) -> None:
|
||||
"""Reproduce a single state."""
|
||||
cur_state = hass.states.get(state.entity_id)
|
||||
|
||||
if cur_state is None:
|
||||
if (cur_state := hass.states.get(state.entity_id)) is None:
|
||||
_LOGGER.warning("Unable to find entity %s", state.entity_id)
|
||||
return
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue