From 17d754dbbf0e59170e219fd213ff224ca367ea5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 21 Jul 2019 20:59:51 +0300 Subject: [PATCH] Optional and Union simplifications (#25365) --- homeassistant/auth/permissions/util.py | 4 ++-- homeassistant/helpers/storage.py | 2 +- homeassistant/loader.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/auth/permissions/util.py b/homeassistant/auth/permissions/util.py index 0d334c4a3ba..3173c179817 100644 --- a/homeassistant/auth/permissions/util.py +++ b/homeassistant/auth/permissions/util.py @@ -1,7 +1,7 @@ """Helpers to deal with permissions.""" from functools import wraps -from typing import Callable, Dict, List, Optional, Union, cast # noqa: F401 +from typing import Callable, Dict, List, Optional, cast # noqa: F401 from .const import SUBCAT_ALL from .models import PermissionLookup @@ -44,7 +44,7 @@ def compile_policy( assert isinstance(policy, dict) - funcs = [] # type: List[Callable[[str, str], Union[None, bool]]] + funcs = [] # type: List[Callable[[str, str], Optional[bool]]] for key, lookup_func in subcategories.items(): lookup_value = policy.get(key) diff --git a/homeassistant/helpers/storage.py b/homeassistant/helpers/storage.py index 6c2af8f77b0..4ca6448066c 100644 --- a/homeassistant/helpers/storage.py +++ b/homeassistant/helpers/storage.py @@ -70,7 +70,7 @@ class Store: """Return the config path.""" return self.hass.config.path(STORAGE_DIR, self.key) - async def async_load(self) -> Optional[Union[Dict, List]]: + async def async_load(self) -> Union[Dict, List, None]: """Load data. If the expected version does not match the given version, the migrate diff --git a/homeassistant/loader.py b/homeassistant/loader.py index 8b1bf588aa4..9bb5bd8bd01 100644 --- a/homeassistant/loader.py +++ b/homeassistant/loader.py @@ -236,7 +236,7 @@ async def async_get_integration(hass: 'HomeAssistant', domain: str)\ cache = hass.data[DATA_INTEGRATIONS] = {} int_or_evt = cache.get( - domain, _UNDEF) # type: Optional[Union[Integration, asyncio.Event]] + domain, _UNDEF) # type: Union[Integration, asyncio.Event, None] if isinstance(int_or_evt, asyncio.Event): await int_or_evt.wait()