Use assignment expressions 20 (#57969)

This commit is contained in:
Marc Mueller
2021-10-20 20:31:00 +02:00
committed by GitHub
parent 398061706c
commit 487fa0a905
18 changed files with 29 additions and 52 deletions

View File

@@ -205,8 +205,7 @@ class MqttAlarm(MqttEntity, alarm.AlarmControlPanelEntity):
@property
def code_format(self):
"""Return one or more digits/characters."""
code = self._config.get(CONF_CODE)
if code is None:
if (code := self._config.get(CONF_CODE)) is None:
return None
if code == REMOTE_CODE or (isinstance(code, str) and re.search("^\\d+$", code)):
return alarm.FORMAT_NUMBER