Use assignment expressions 26 (#58187)
This commit is contained in:
parent
be201e3ebe
commit
184e0d7fdf
15 changed files with 29 additions and 57 deletions
|
@ -186,9 +186,8 @@ def get_service(hass, config, discovery_info=None):
|
|||
hass.http.register_view(HTML5PushCallbackView(registrations))
|
||||
|
||||
gcm_api_key = config.get(ATTR_GCM_API_KEY)
|
||||
gcm_sender_id = config.get(ATTR_GCM_SENDER_ID)
|
||||
|
||||
if gcm_sender_id is not None:
|
||||
if config.get(ATTR_GCM_SENDER_ID) is not None:
|
||||
add_manifest_json_key(ATTR_GCM_SENDER_ID, config.get(ATTR_GCM_SENDER_ID))
|
||||
|
||||
return HTML5NotificationService(
|
||||
|
@ -332,9 +331,7 @@ class HTML5PushCallbackView(HomeAssistantView):
|
|||
# https://auth0.com/docs/quickstart/backend/python
|
||||
def check_authorization_header(self, request):
|
||||
"""Check the authorization header."""
|
||||
|
||||
auth = request.headers.get(AUTHORIZATION)
|
||||
if not auth:
|
||||
if not (auth := request.headers.get(AUTHORIZATION)):
|
||||
return self.json_message(
|
||||
"Authorization header is expected", status_code=HTTPStatus.UNAUTHORIZED
|
||||
)
|
||||
|
@ -463,9 +460,7 @@ class HTML5NotificationService(BaseNotificationService):
|
|||
ATTR_TITLE: kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT),
|
||||
}
|
||||
|
||||
data = kwargs.get(ATTR_DATA)
|
||||
|
||||
if data:
|
||||
if data := kwargs.get(ATTR_DATA):
|
||||
# Pick out fields that should go into the notification directly vs
|
||||
# into the notification data dictionary.
|
||||
|
||||
|
@ -496,9 +491,8 @@ class HTML5NotificationService(BaseNotificationService):
|
|||
if priority not in ["normal", "high"]:
|
||||
priority = DEFAULT_PRIORITY
|
||||
payload["timestamp"] = timestamp * 1000 # Javascript ms since epoch
|
||||
targets = kwargs.get(ATTR_TARGET)
|
||||
|
||||
if not targets:
|
||||
if not (targets := kwargs.get(ATTR_TARGET)):
|
||||
targets = self.registrations.keys()
|
||||
|
||||
for target in list(targets):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue