Type hint additions (#26831)

* Type hint additions

* Remove optional from sidebar_icon comment

Co-Authored-By: Franck Nijhof <frenck@frenck.nl>

* Remove optional from sidebar_title comment

Co-Authored-By: Franck Nijhof <frenck@frenck.nl>

* Fix issues after rebase and mypy 0.730
This commit is contained in:
Ville SkyttäandFranck Nijhof authored and GitHub committed 2019-09-29 20:07:49 +03:00
1 parent 4f55235aa2
commit f259ff17d5
27 files changed
+184 -68

No files matched your search

@@ -1,7 +1,7 @@
"""Support for displaying persistent notifications."""
from collections import OrderedDict
import logging
from typing import Awaitable
from typing import Any, Mapping, MutableMapping, Optional
import voluptuous as vol
@@ -14,6 +14,9 @@ from homeassistant.loader import bind_hass
from homeassistant.util import slugify
import homeassistant.util.dt as dt_util
# mypy: allow-untyped-calls, allow-untyped-defs
ATTR_CREATED_AT = "created_at"
ATTR_MESSAGE = "message"
ATTR_NOTIFICATION_ID = "notification_id"
@@ -70,7 +73,10 @@ def dismiss(hass, notification_id):
@callback
@bind_hass
def async_create(
hass: HomeAssistant, message: str, title: str = None, notification_id: str = None
hass: HomeAssistant,
message: str,
title: Optional[str] = None,
notification_id: Optional[str] = None,
) -> None:
"""Generate a notification."""
data = {
@@ -95,9 +101,9 @@ def async_dismiss(hass: HomeAssistant, notification_id: str) -> None:
hass.async_create_task(hass.services.async_call(DOMAIN, SERVICE_DISMISS, data))
async def async_setup(hass: HomeAssistant, config: dict) -> Awaitable[bool]:
async def async_setup(hass: HomeAssistant, config: dict) -> bool:
"""Set up the persistent notification component."""
persistent_notifications = OrderedDict()
persistent_notifications: MutableMapping[str, MutableMapping] = OrderedDict()
hass.data[DOMAIN] = {"notifications": persistent_notifications}
@callback
@@ -201,8 +207,10 @@ async def async_setup(hass: HomeAssistant, config: dict) -> Awaitable[bool]:
@callback
def websocket_get_notifications(
hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg
):
hass: HomeAssistant,
connection: websocket_api.ActiveConnection,
msg: Mapping[str, Any],
) -> None:
"""Return a list of persistent_notifications."""
connection.send_message(
websocket_api.result_message(