Use assignment expressions 05 (#57785)

This commit is contained in:
Marc Mueller 2021-10-17 19:56:00 +02:00 committed by GitHub
parent d09ee11c54
commit 5048bad050
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 36 additions and 71 deletions

View file

@ -212,9 +212,7 @@ class CoverEntity(Entity):
if self.is_closing:
return STATE_CLOSING
closed = self.is_closed
if closed is None:
if (closed := self.is_closed) is None:
return None
return STATE_CLOSED if closed else STATE_OPEN
@ -225,13 +223,11 @@ class CoverEntity(Entity):
"""Return the state attributes."""
data = {}
current = self.current_cover_position
if current is not None:
data[ATTR_CURRENT_POSITION] = self.current_cover_position
if (current := self.current_cover_position) is not None:
data[ATTR_CURRENT_POSITION] = current
current_tilt = self.current_cover_tilt_position
if current_tilt is not None:
data[ATTR_CURRENT_TILT_POSITION] = self.current_cover_tilt_position
if (current_tilt := self.current_cover_tilt_position) is not None:
data[ATTR_CURRENT_TILT_POSITION] = current_tilt
return data