mirror of
https://github.com/home-assistant/core.git
synced 2026-08-24 02:24:51 -05:00
Migrate google_mail off hass.data[DOMAIN] to entry.runtime_data / typed storage (#177949)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
"""Support for Google Mail."""
|
||||
# pylint: disable=home-assistant-use-runtime-data # Uses legacy hass.data[DOMAIN] pattern
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_NAME, Platform
|
||||
@@ -26,7 +25,7 @@ CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up the Google Mail integration."""
|
||||
hass.data.setdefault(DOMAIN, {})[DATA_HASS_CONFIG] = config
|
||||
hass.data[DATA_HASS_CONFIG] = config
|
||||
|
||||
async_setup_services(hass)
|
||||
|
||||
@@ -53,9 +52,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: GoogleMailConfigEntry) -
|
||||
Platform.NOTIFY,
|
||||
DOMAIN,
|
||||
{DATA_AUTH: auth, CONF_NAME: entry.title},
|
||||
# Uses legacy hass.data[DOMAIN] pattern
|
||||
# pylint: disable-next=home-assistant-use-runtime-data
|
||||
hass.data[DOMAIN][DATA_HASS_CONFIG],
|
||||
hass.data[DATA_HASS_CONFIG],
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
"""Constants for Google Mail integration."""
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.util.hass_dict import HassKey
|
||||
|
||||
ATTR_BCC = "bcc"
|
||||
ATTR_CC = "cc"
|
||||
ATTR_ENABLED = "enabled"
|
||||
@@ -16,7 +20,9 @@ ATTR_START = "start"
|
||||
ATTR_TITLE = "title"
|
||||
|
||||
DATA_AUTH = "auth"
|
||||
DATA_HASS_CONFIG = "hass_config"
|
||||
# Domain-level root HA config for legacy notify platform discovery.
|
||||
# Not per config entry — entries store auth on entry.runtime_data.
|
||||
DATA_HASS_CONFIG: HassKey[dict[str, Any]] = HassKey("google_mail_hass_config")
|
||||
DEFAULT_ACCESS = [
|
||||
"https://www.googleapis.com/auth/gmail.compose",
|
||||
"https://www.googleapis.com/auth/gmail.settings.basic",
|
||||
|
||||
Reference in New Issue
Block a user