mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Add setup type hints to mailbox (#63792)
* Add setup type hints to mailbox * Add more type hints * Adjust base helper * Filter type is not None in mailbox * Filter empty platforms in device_tracker * Filter out empty platform in notify * Filter out empty platform in entity_component Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
7a699480d4
commit
1a46a6687e
@ -1,4 +1,6 @@
|
||||
"""Support for Voice mailboxes."""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from contextlib import suppress
|
||||
from datetime import timedelta
|
||||
@ -10,11 +12,12 @@ from aiohttp.web_exceptions import HTTPNotFound
|
||||
import async_timeout
|
||||
|
||||
from homeassistant.components.http import HomeAssistantView
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import config_per_platform, discovery
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity_component import EntityComponent
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.setup import async_prepare_setup_platform
|
||||
|
||||
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||
@ -30,9 +33,9 @@ CONTENT_TYPE_NONE = "none"
|
||||
SCAN_INTERVAL = timedelta(seconds=30)
|
||||
|
||||
|
||||
async def async_setup(hass, config):
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Track states and offer events for mailboxes."""
|
||||
mailboxes = []
|
||||
mailboxes: list[Mailbox] = []
|
||||
hass.components.frontend.async_register_built_in_panel(
|
||||
"mailbox", "mailbox", "mdi:mailbox"
|
||||
)
|
||||
@ -41,7 +44,11 @@ async def async_setup(hass, config):
|
||||
hass.http.register_view(MailboxMediaView(mailboxes))
|
||||
hass.http.register_view(MailboxDeleteView(mailboxes))
|
||||
|
||||
async def async_setup_platform(p_type, p_config=None, discovery_info=None):
|
||||
async def async_setup_platform(
|
||||
p_type: str,
|
||||
p_config: ConfigType | None = None,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up a mailbox platform."""
|
||||
if p_config is None:
|
||||
p_config = {}
|
||||
@ -104,7 +111,7 @@ async def async_setup(hass, config):
|
||||
class MailboxEntity(Entity):
|
||||
"""Entity for each mailbox platform to provide a badge display."""
|
||||
|
||||
def __init__(self, mailbox):
|
||||
def __init__(self, mailbox: Mailbox) -> None:
|
||||
"""Initialize mailbox entity."""
|
||||
self.mailbox = mailbox
|
||||
self.message_count = 0
|
||||
@ -183,7 +190,7 @@ class StreamError(Exception):
|
||||
class MailboxView(HomeAssistantView):
|
||||
"""Base mailbox view."""
|
||||
|
||||
def __init__(self, mailboxes):
|
||||
def __init__(self, mailboxes: list[Mailbox]) -> None:
|
||||
"""Initialize a basic mailbox view."""
|
||||
self.mailboxes = mailboxes
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user