Use typed config entry in imap (#132029)

* Use typed config entry in imap

* Adjust
This commit is contained in:
epenet 2024-12-02 07:28:29 +01:00 committed by GitHub
parent 28eb4f3dff
commit 5458ee2fa9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 12 deletions

View File

@ -9,12 +9,7 @@ from typing import Any
from aioimaplib import AioImapException from aioimaplib import AioImapException
import voluptuous as vol import voluptuous as vol
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigFlow, ConfigFlowResult, OptionsFlow
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import ( from homeassistant.const import (
CONF_NAME, CONF_NAME,
CONF_PASSWORD, CONF_PASSWORD,
@ -35,6 +30,7 @@ from homeassistant.helpers.selector import (
) )
from homeassistant.util.ssl import SSLCipherList from homeassistant.util.ssl import SSLCipherList
from . import ImapConfigEntry
from .const import ( from .const import (
CONF_CHARSET, CONF_CHARSET,
CONF_CUSTOM_EVENT_DATA_TEMPLATE, CONF_CUSTOM_EVENT_DATA_TEMPLATE,
@ -212,7 +208,7 @@ class IMAPConfigFlow(ConfigFlow, domain=DOMAIN):
@staticmethod @staticmethod
@callback @callback
def async_get_options_flow( def async_get_options_flow(
config_entry: ConfigEntry, config_entry: ImapConfigEntry,
) -> ImapOptionsFlow: ) -> ImapOptionsFlow:
"""Get the options flow for this handler.""" """Get the options flow for this handler."""
return ImapOptionsFlow() return ImapOptionsFlow()

View File

@ -14,7 +14,6 @@ from typing import TYPE_CHECKING, Any
from aioimaplib import AUTH, IMAP4_SSL, NONAUTH, SELECTED, AioImapException from aioimaplib import AUTH, IMAP4_SSL, NONAUTH, SELECTED, AioImapException
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
CONF_PASSWORD, CONF_PASSWORD,
CONF_PORT, CONF_PORT,
@ -53,6 +52,9 @@ from .const import (
) )
from .errors import InvalidAuth, InvalidFolder from .errors import InvalidAuth, InvalidFolder
if TYPE_CHECKING:
from . import ImapConfigEntry
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
BACKOFF_TIME = 10 BACKOFF_TIME = 10
@ -210,14 +212,14 @@ class ImapMessage:
class ImapDataUpdateCoordinator(DataUpdateCoordinator[int | None]): class ImapDataUpdateCoordinator(DataUpdateCoordinator[int | None]):
"""Base class for imap client.""" """Base class for imap client."""
config_entry: ConfigEntry config_entry: ImapConfigEntry
custom_event_template: Template | None custom_event_template: Template | None
def __init__( def __init__(
self, self,
hass: HomeAssistant, hass: HomeAssistant,
imap_client: IMAP4_SSL, imap_client: IMAP4_SSL,
entry: ConfigEntry, entry: ImapConfigEntry,
update_interval: timedelta | None, update_interval: timedelta | None,
) -> None: ) -> None:
"""Initiate imap client.""" """Initiate imap client."""
@ -391,7 +393,7 @@ class ImapPollingDataUpdateCoordinator(ImapDataUpdateCoordinator):
"""Class for imap client.""" """Class for imap client."""
def __init__( def __init__(
self, hass: HomeAssistant, imap_client: IMAP4_SSL, entry: ConfigEntry self, hass: HomeAssistant, imap_client: IMAP4_SSL, entry: ImapConfigEntry
) -> None: ) -> None:
"""Initiate imap client.""" """Initiate imap client."""
_LOGGER.debug( _LOGGER.debug(
@ -437,7 +439,7 @@ class ImapPushDataUpdateCoordinator(ImapDataUpdateCoordinator):
"""Class for imap client.""" """Class for imap client."""
def __init__( def __init__(
self, hass: HomeAssistant, imap_client: IMAP4_SSL, entry: ConfigEntry self, hass: HomeAssistant, imap_client: IMAP4_SSL, entry: ImapConfigEntry
) -> None: ) -> None:
"""Initiate imap client.""" """Initiate imap client."""
_LOGGER.debug("Connected to server %s using IMAP push", entry.data[CONF_SERVER]) _LOGGER.debug("Connected to server %s using IMAP push", entry.data[CONF_SERVER])