Use assignment expressions 10 (#57791)

This commit is contained in:
Marc Mueller 2021-10-15 21:36:03 +02:00 committed by GitHub
parent 9be3278ffa
commit 12d1dfdaf9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 44 additions and 87 deletions

View file

@ -11,8 +11,7 @@ from homeassistant.core import State
def find_state_attributes(states: list[State], key: str) -> Iterator[Any]:
"""Find attributes with matching key from states."""
for state in states:
value = state.attributes.get(key)
if value is not None:
if (value := state.attributes.get(key)) is not None:
yield value