Add setup type hints [s] (part 1) (#63476)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
992f9c3c6c
commit
4c48705fe8
9 changed files with 74 additions and 17 deletions
|
@ -6,10 +6,11 @@ from satel_integra.satel_integra import AsyncSatel
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.discovery import async_load_platform
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
DEFAULT_ALARM_NAME = "satel_integra"
|
||||
DEFAULT_PORT = 7094
|
||||
|
@ -90,9 +91,9 @@ CONFIG_SCHEMA = vol.Schema(
|
|||
)
|
||||
|
||||
|
||||
async def async_setup(hass, config):
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up the Satel Integra component."""
|
||||
conf = config.get(DOMAIN)
|
||||
conf = config[DOMAIN]
|
||||
|
||||
zones = conf.get(CONF_ZONES)
|
||||
outputs = conf.get(CONF_OUTPUTS)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Support for getting data from websites with scraping."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
|
@ -27,8 +29,11 @@ from homeassistant.const import (
|
|||
HTTP_BASIC_AUTHENTICATION,
|
||||
HTTP_DIGEST_AUTHENTICATION,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -61,7 +66,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||
)
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||
async def async_setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the Web scrape sensor."""
|
||||
name = config.get(CONF_NAME)
|
||||
resource = config.get(CONF_RESOURCE)
|
||||
|
@ -81,6 +91,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||
if (value_template := config.get(CONF_VALUE_TEMPLATE)) is not None:
|
||||
value_template.hass = hass
|
||||
|
||||
auth: httpx.DigestAuth | tuple[str, str] | None
|
||||
if username and password:
|
||||
if config.get(CONF_AUTHENTICATION) == HTTP_DIGEST_AUTHENTICATION:
|
||||
auth = httpx.DigestAuth(username, password)
|
||||
|
|
|
@ -8,6 +8,7 @@ import voluptuous as vol
|
|||
from homeassistant import config_entries
|
||||
from homeassistant.components import http, websocket_api
|
||||
from homeassistant.components.http.data_validator import RequestDataValidator
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_NAME
|
||||
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
@ -77,7 +78,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||
return True
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry):
|
||||
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
||||
"""Set up shopping list from config flow."""
|
||||
|
||||
async def add_item_service(call: ServiceCall) -> None:
|
||||
|
|
|
@ -6,9 +6,11 @@ from sisyphus_control import Table
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, EVENT_HOMEASSISTANT_STOP
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.discovery import async_load_platform
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -28,7 +30,7 @@ CONFIG_SCHEMA = vol.Schema(
|
|||
)
|
||||
|
||||
|
||||
async def async_setup(hass, config):
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up the sisyphus component."""
|
||||
|
||||
class SocketIONoiseFilter(logging.Filter):
|
||||
|
@ -41,7 +43,7 @@ async def async_setup(hass, config):
|
|||
|
||||
logging.getLogger("socketIO-client").addFilter(SocketIONoiseFilter())
|
||||
tables = hass.data.setdefault(DATA_SISYPHUS, {})
|
||||
table_configs = config.get(DOMAIN)
|
||||
table_configs = config[DOMAIN]
|
||||
session = async_get_clientsession(hass)
|
||||
|
||||
async def add_table(host, name=None):
|
||||
|
|
|
@ -13,7 +13,10 @@ from homeassistant.components.binary_sensor import (
|
|||
BinarySensorEntityDescription,
|
||||
)
|
||||
from homeassistant.const import CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS
|
||||
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
|
||||
|
||||
from . import DEFAULT_ENTITY_NAMESPACE, DOMAIN as SKYBELL_DOMAIN, SkybellDevice
|
||||
|
||||
|
@ -46,9 +49,14 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||
)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the platform for a Skybell device."""
|
||||
skybell = hass.data.get(SKYBELL_DOMAIN)
|
||||
skybell = hass.data[SKYBELL_DOMAIN]
|
||||
|
||||
binary_sensors = [
|
||||
SkybellBinarySensor(device, BINARY_SENSOR_TYPES[sensor_type])
|
||||
|
|
|
@ -9,7 +9,10 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant.components.camera import PLATFORM_SCHEMA, Camera
|
||||
from homeassistant.const import CONF_MONITORED_CONDITIONS
|
||||
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
|
||||
|
||||
from . import DOMAIN as SKYBELL_DOMAIN, SkybellDevice
|
||||
|
||||
|
@ -34,13 +37,18 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||
)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the platform for a Skybell device."""
|
||||
cond = config[CONF_MONITORED_CONDITIONS]
|
||||
names = {}
|
||||
names[IMAGE_ACTIVITY] = config.get(CONF_ACTIVITY_NAME)
|
||||
names[IMAGE_AVATAR] = config.get(CONF_AVATAR_NAME)
|
||||
skybell = hass.data.get(SKYBELL_DOMAIN)
|
||||
skybell = hass.data[SKYBELL_DOMAIN]
|
||||
|
||||
sensors = []
|
||||
for device in skybell.get_devices():
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Light/LED support for the Skybell HD Doorbell."""
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS,
|
||||
ATTR_HS_COLOR,
|
||||
|
@ -6,14 +8,22 @@ from homeassistant.components.light import (
|
|||
SUPPORT_COLOR,
|
||||
LightEntity,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
import homeassistant.util.color as color_util
|
||||
|
||||
from . import DOMAIN as SKYBELL_DOMAIN, SkybellDevice
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the platform for a Skybell device."""
|
||||
skybell = hass.data.get(SKYBELL_DOMAIN)
|
||||
skybell = hass.data[SKYBELL_DOMAIN]
|
||||
|
||||
sensors = []
|
||||
for device in skybell.get_devices():
|
||||
|
|
|
@ -11,7 +11,10 @@ from homeassistant.components.sensor import (
|
|||
SensorEntityDescription,
|
||||
)
|
||||
from homeassistant.const import CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS
|
||||
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
|
||||
|
||||
from . import DEFAULT_ENTITY_NAMESPACE, DOMAIN as SKYBELL_DOMAIN, SkybellDevice
|
||||
|
||||
|
@ -39,9 +42,14 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||
)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the platform for a Skybell device."""
|
||||
skybell = hass.data.get(SKYBELL_DOMAIN)
|
||||
skybell = hass.data[SKYBELL_DOMAIN]
|
||||
|
||||
sensors = [
|
||||
SkybellSensor(device, description)
|
||||
|
|
|
@ -9,7 +9,10 @@ from homeassistant.components.switch import (
|
|||
SwitchEntityDescription,
|
||||
)
|
||||
from homeassistant.const import CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS
|
||||
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
|
||||
|
||||
from . import DEFAULT_ENTITY_NAMESPACE, DOMAIN as SKYBELL_DOMAIN, SkybellDevice
|
||||
|
||||
|
@ -38,9 +41,14 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||
)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the platform for a Skybell device."""
|
||||
skybell = hass.data.get(SKYBELL_DOMAIN)
|
||||
skybell = hass.data[SKYBELL_DOMAIN]
|
||||
|
||||
switches = [
|
||||
SkybellSwitch(device, description)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue