Allow None return for notify get_service (#82444)

This commit is contained in:
Marc Mueller 2022-11-21 08:18:37 +01:00 committed by GitHub
parent d2000f0c7a
commit c068024abe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,7 +41,7 @@ class LegacyNotifyPlatform(Protocol):
hass: HomeAssistant, hass: HomeAssistant,
config: ConfigType, config: ConfigType,
discovery_info: DiscoveryInfoType | None = ..., discovery_info: DiscoveryInfoType | None = ...,
) -> BaseNotificationService: ) -> BaseNotificationService | None:
"""Set up notification service.""" """Set up notification service."""
def get_service( def get_service(
@ -49,7 +49,7 @@ class LegacyNotifyPlatform(Protocol):
hass: HomeAssistant, hass: HomeAssistant,
config: ConfigType, config: ConfigType,
discovery_info: DiscoveryInfoType | None = ..., discovery_info: DiscoveryInfoType | None = ...,
) -> BaseNotificationService: ) -> BaseNotificationService | None:
"""Set up notification service.""" """Set up notification service."""
@ -82,7 +82,7 @@ def async_setup_legacy(
full_name = f"{DOMAIN}.{integration_name}" full_name = f"{DOMAIN}.{integration_name}"
LOGGER.info("Setting up %s", full_name) LOGGER.info("Setting up %s", full_name)
with async_start_setup(hass, [full_name]): with async_start_setup(hass, [full_name]):
notify_service = None notify_service: BaseNotificationService | None = None
try: try:
if hasattr(platform, "async_get_service"): if hasattr(platform, "async_get_service"):
notify_service = await platform.async_get_service( notify_service = await platform.async_get_service(