Optional and Union simplifications (#25365)
parent
5e29d4d098
commit
17d754dbbf
|
@ -1,7 +1,7 @@
|
||||||
"""Helpers to deal with permissions."""
|
"""Helpers to deal with permissions."""
|
||||||
from functools import wraps
|
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 .const import SUBCAT_ALL
|
||||||
from .models import PermissionLookup
|
from .models import PermissionLookup
|
||||||
|
@ -44,7 +44,7 @@ def compile_policy(
|
||||||
|
|
||||||
assert isinstance(policy, dict)
|
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():
|
for key, lookup_func in subcategories.items():
|
||||||
lookup_value = policy.get(key)
|
lookup_value = policy.get(key)
|
||||||
|
|
|
@ -70,7 +70,7 @@ class Store:
|
||||||
"""Return the config path."""
|
"""Return the config path."""
|
||||||
return self.hass.config.path(STORAGE_DIR, self.key)
|
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.
|
"""Load data.
|
||||||
|
|
||||||
If the expected version does not match the given version, the migrate
|
If the expected version does not match the given version, the migrate
|
||||||
|
|
|
@ -236,7 +236,7 @@ async def async_get_integration(hass: 'HomeAssistant', domain: str)\
|
||||||
cache = hass.data[DATA_INTEGRATIONS] = {}
|
cache = hass.data[DATA_INTEGRATIONS] = {}
|
||||||
|
|
||||||
int_or_evt = cache.get(
|
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):
|
if isinstance(int_or_evt, asyncio.Event):
|
||||||
await int_or_evt.wait()
|
await int_or_evt.wait()
|
||||||
|
|
Loading…
Reference in New Issue