Use assignment expressions 11 (#57792)

This commit is contained in:
Marc Mueller 2021-10-17 20:15:48 +02:00 committed by GitHub
parent 238b488642
commit aa7dc78a1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 45 additions and 111 deletions

View file

@ -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:

View file

@ -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