Add missing type annotations to Notion (#52599)

This commit is contained in:
Aaron Bach 2021-07-07 17:39:52 -05:00 committed by GitHub
parent 50d56fd755
commit f44a13970a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 7 deletions

View file

@ -208,7 +208,7 @@ class NotionEntity(CoordinatorEntity):
raise NotImplementedError
@callback
def _handle_coordinator_update(self):
def _handle_coordinator_update(self) -> None:
"""Respond to a DataUpdateCoordinator update."""
if self._task_id in self.coordinator.data["tasks"]:
self.hass.async_create_task(self._async_update_bridge_id())
@ -216,7 +216,7 @@ class NotionEntity(CoordinatorEntity):
self.async_write_ha_state()
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Handle entity which will be added."""
await super().async_added_to_hass()
self._async_update_from_latest_data()

View file

@ -44,7 +44,7 @@ BINARY_SENSOR_TYPES = {
async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
):
) -> None:
"""Set up Notion sensors based on a config entry."""
coordinator = hass.data[DOMAIN][DATA_COORDINATOR][entry.entry_id]

View file

@ -1,10 +1,13 @@
"""Config flow to configure the Notion integration."""
from __future__ import annotations
from aionotion import async_get_client
from aionotion.errors import NotionError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import aiohttp_client
from .const import DOMAIN
@ -15,19 +18,21 @@ class NotionFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
VERSION = 1
def __init__(self):
def __init__(self) -> None:
"""Initialize the config flow."""
self.data_schema = vol.Schema(
{vol.Required(CONF_USERNAME): str, vol.Required(CONF_PASSWORD): str}
)
async def _show_form(self, errors=None):
async def _show_form(self, errors: dict[str, str] | None = None) -> FlowResult:
"""Show the form to the user."""
return self.async_show_form(
step_id="user", data_schema=self.data_schema, errors=errors or {}
)
async def async_step_user(self, user_input=None):
async def async_step_user(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
"""Handle the start of the config flow."""
if not user_input:
return await self._show_form()

View file

@ -14,7 +14,7 @@ SENSOR_TYPES = {SENSOR_TEMPERATURE: ("Temperature", "temperature", TEMP_CELSIUS)
async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
):
) -> None:
"""Set up Notion sensors based on a config entry."""
coordinator = hass.data[DOMAIN][DATA_COORDINATOR][entry.entry_id]