mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 04:50:05 +00:00
Use singleton enum for "not set" sentinels (#41990)
* Use singleton enum for "not set" sentinel https://www.python.org/dev/peps/pep-0484/#support-for-singleton-types-in-unions * Remove unused variable
This commit is contained in:
@@ -13,12 +13,12 @@ from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback
|
||||
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
|
||||
from homeassistant.helpers import entity_registry
|
||||
from homeassistant.helpers.event import Event
|
||||
from homeassistant.helpers.typing import UNDEFINED, UndefinedType
|
||||
from homeassistant.setup import async_process_deps_reqs, async_setup_component
|
||||
from homeassistant.util.decorator import Registry
|
||||
import homeassistant.util.uuid as uuid_util
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
_UNDEF: dict = {}
|
||||
|
||||
SOURCE_DISCOVERY = "discovery"
|
||||
SOURCE_HASSIO = "hassio"
|
||||
@@ -760,12 +760,11 @@ class ConfigEntries:
|
||||
self,
|
||||
entry: ConfigEntry,
|
||||
*,
|
||||
# pylint: disable=dangerous-default-value # _UNDEFs not modified
|
||||
unique_id: Union[str, dict, None] = _UNDEF,
|
||||
title: Union[str, dict] = _UNDEF,
|
||||
data: dict = _UNDEF,
|
||||
options: dict = _UNDEF,
|
||||
system_options: dict = _UNDEF,
|
||||
unique_id: Union[str, dict, None, UndefinedType] = UNDEFINED,
|
||||
title: Union[str, dict, UndefinedType] = UNDEFINED,
|
||||
data: Union[dict, UndefinedType] = UNDEFINED,
|
||||
options: Union[dict, UndefinedType] = UNDEFINED,
|
||||
system_options: Union[dict, UndefinedType] = UNDEFINED,
|
||||
) -> bool:
|
||||
"""Update a config entry.
|
||||
|
||||
@@ -777,24 +776,24 @@ class ConfigEntries:
|
||||
"""
|
||||
changed = False
|
||||
|
||||
if unique_id is not _UNDEF and entry.unique_id != unique_id:
|
||||
if unique_id is not UNDEFINED and entry.unique_id != unique_id:
|
||||
changed = True
|
||||
entry.unique_id = cast(Optional[str], unique_id)
|
||||
|
||||
if title is not _UNDEF and entry.title != title:
|
||||
if title is not UNDEFINED and entry.title != title:
|
||||
changed = True
|
||||
entry.title = cast(str, title)
|
||||
|
||||
if data is not _UNDEF and entry.data != data: # type: ignore
|
||||
if data is not UNDEFINED and entry.data != data: # type: ignore
|
||||
changed = True
|
||||
entry.data = MappingProxyType(data)
|
||||
|
||||
if options is not _UNDEF and entry.options != options: # type: ignore
|
||||
if options is not UNDEFINED and entry.options != options: # type: ignore
|
||||
changed = True
|
||||
entry.options = MappingProxyType(options)
|
||||
|
||||
if (
|
||||
system_options is not _UNDEF
|
||||
system_options is not UNDEFINED
|
||||
and entry.system_options.as_dict() != system_options
|
||||
):
|
||||
changed = True
|
||||
|
||||
Reference in New Issue
Block a user