Add sensor setup type hints [r] (#63312)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-01-03 19:08:34 +01:00 committed by GitHub
parent 595e8a327c
commit 822ac203c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 128 additions and 14 deletions

View file

@ -4,6 +4,8 @@ Support for Rejseplanen information from rejseplanen.dk.
For more info on the API see:
https://help.rejseplanen.dk/hc/en-us/articles/214174465-Rejseplanen-s-API
"""
from __future__ import annotations
from contextlib import suppress
from datetime import datetime, timedelta
import logging
@ -14,7 +16,10 @@ import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ATTR_ATTRIBUTION, CONF_NAME, TIME_MINUTES
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
import homeassistant.util.dt as dt_util
_LOGGER = logging.getLogger(__name__)
@ -73,7 +78,12 @@ def due_in_minutes(timestamp):
return int(diff.total_seconds() // 60)
def setup_platform(hass, config, add_devices, discovery_info=None):
def setup_platform(
hass: HomeAssistant,
config: ConfigType,
add_devices: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the Rejseplanen transport sensor."""
name = config[CONF_NAME]
stop_id = config[CONF_STOP_ID]