Add hints to get_service in syslog (#86701)

pull/86815/head
epenet 2023-01-26 11:10:50 +01:00 committed by GitHub
parent ca8cc284ed
commit b9ffc67a44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 4 deletions

View File

@ -1,4 +1,6 @@
"""Syslog notification service."""
from __future__ import annotations
import syslog
import voluptuous as vol
@ -9,6 +11,8 @@ from homeassistant.components.notify import (
PLATFORM_SCHEMA,
BaseNotificationService,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
CONF_FACILITY = "facility"
CONF_OPTION = "option"
@ -63,12 +67,16 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
)
def get_service(hass, config, discovery_info=None):
def get_service(
hass: HomeAssistant,
config: ConfigType,
discovery_info: DiscoveryInfoType | None = None,
) -> SyslogNotificationService:
"""Get the syslog notification service."""
facility = getattr(syslog, SYSLOG_FACILITY[config.get(CONF_FACILITY)])
option = getattr(syslog, SYSLOG_OPTION[config.get(CONF_OPTION)])
priority = getattr(syslog, SYSLOG_PRIORITY[config.get(CONF_PRIORITY)])
facility = getattr(syslog, SYSLOG_FACILITY[config[CONF_FACILITY]])
option = getattr(syslog, SYSLOG_OPTION[config[CONF_OPTION]])
priority = getattr(syslog, SYSLOG_PRIORITY[config[CONF_PRIORITY]])
return SyslogNotificationService(facility, option, priority)