1
mirror of https://github.com/home-assistant/core synced 2024-08-02 23:40:32 +02:00

Optional and Union simplifications (#25365)

This commit is contained in:
Ville Skyttä 2019-07-21 20:59:51 +03:00 committed by Paulus Schoutsen
parent 5e29d4d098
commit 17d754dbbf
3 changed files with 4 additions and 4 deletions

View File

@ -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)

View File

@ -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

View File

@ -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()