mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Type hint improvements (#32793)
This commit is contained in:
parent
d04479044c
commit
e86919a997
@ -20,6 +20,7 @@ from homeassistant.const import (
|
||||
REQUIRED_NEXT_PYTHON_VER,
|
||||
)
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.setup import DATA_SETUP, async_setup_component
|
||||
from homeassistant.util.logging import AsyncHandler
|
||||
from homeassistant.util.package import async_get_user_site, is_virtual_env
|
||||
@ -133,7 +134,7 @@ async def async_setup_hass(
|
||||
|
||||
|
||||
async def async_from_config_dict(
|
||||
config: Dict[str, Any], hass: core.HomeAssistant
|
||||
config: ConfigType, hass: core.HomeAssistant
|
||||
) -> Optional[core.HomeAssistant]:
|
||||
"""Try to configure Home Assistant from a configuration dictionary.
|
||||
|
||||
|
@ -74,7 +74,7 @@ async def _async_get_custom_components(
|
||||
except ImportError:
|
||||
return {}
|
||||
|
||||
def get_sub_directories(paths: List) -> List:
|
||||
def get_sub_directories(paths: List[str]) -> List[pathlib.Path]:
|
||||
"""Return all sub directories in a set of paths."""
|
||||
return [
|
||||
entry
|
||||
@ -506,7 +506,7 @@ async def async_component_dependencies(hass: "HomeAssistant", domain: str) -> Se
|
||||
|
||||
|
||||
async def _async_component_dependencies(
|
||||
hass: "HomeAssistant", domain: str, loaded: Set[str], loading: Set
|
||||
hass: "HomeAssistant", domain: str, loaded: Set[str], loading: Set[str]
|
||||
) -> Set[str]:
|
||||
"""Recursive function to get component dependencies.
|
||||
|
||||
|
@ -3,12 +3,13 @@ import asyncio
|
||||
import logging.handlers
|
||||
from timeit import default_timer as timer
|
||||
from types import ModuleType
|
||||
from typing import Awaitable, Callable, Dict, List, Optional
|
||||
from typing import Awaitable, Callable, List, Optional
|
||||
|
||||
from homeassistant import config as conf_util, core, loader, requirements
|
||||
from homeassistant.config import async_notify_setup_error
|
||||
from homeassistant.const import EVENT_COMPONENT_LOADED, PLATFORM_FORMAT
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -20,7 +21,7 @@ DATA_DEPS_REQS = "deps_reqs_processed"
|
||||
SLOW_SETUP_WARNING = 10
|
||||
|
||||
|
||||
def setup_component(hass: core.HomeAssistant, domain: str, config: Dict) -> bool:
|
||||
def setup_component(hass: core.HomeAssistant, domain: str, config: ConfigType) -> bool:
|
||||
"""Set up a component and all its dependencies."""
|
||||
return asyncio.run_coroutine_threadsafe(
|
||||
async_setup_component(hass, domain, config), hass.loop
|
||||
@ -28,7 +29,7 @@ def setup_component(hass: core.HomeAssistant, domain: str, config: Dict) -> bool
|
||||
|
||||
|
||||
async def async_setup_component(
|
||||
hass: core.HomeAssistant, domain: str, config: Dict
|
||||
hass: core.HomeAssistant, domain: str, config: ConfigType
|
||||
) -> bool:
|
||||
"""Set up a component and all its dependencies.
|
||||
|
||||
@ -50,7 +51,7 @@ async def async_setup_component(
|
||||
|
||||
|
||||
async def _async_process_dependencies(
|
||||
hass: core.HomeAssistant, config: Dict, name: str, dependencies: List[str]
|
||||
hass: core.HomeAssistant, config: ConfigType, name: str, dependencies: List[str]
|
||||
) -> bool:
|
||||
"""Ensure all dependencies are set up."""
|
||||
blacklisted = [dep for dep in dependencies if dep in loader.DEPENDENCY_BLACKLIST]
|
||||
@ -85,7 +86,7 @@ async def _async_process_dependencies(
|
||||
|
||||
|
||||
async def _async_setup_component(
|
||||
hass: core.HomeAssistant, domain: str, config: Dict
|
||||
hass: core.HomeAssistant, domain: str, config: ConfigType
|
||||
) -> bool:
|
||||
"""Set up a component for Home Assistant.
|
||||
|
||||
@ -212,7 +213,7 @@ async def _async_setup_component(
|
||||
|
||||
|
||||
async def async_prepare_setup_platform(
|
||||
hass: core.HomeAssistant, hass_config: Dict, domain: str, platform_name: str
|
||||
hass: core.HomeAssistant, hass_config: ConfigType, domain: str, platform_name: str
|
||||
) -> Optional[ModuleType]:
|
||||
"""Load a platform and makes sure dependencies are setup.
|
||||
|
||||
@ -267,7 +268,7 @@ async def async_prepare_setup_platform(
|
||||
|
||||
|
||||
async def async_process_deps_reqs(
|
||||
hass: core.HomeAssistant, config: Dict, integration: loader.Integration
|
||||
hass: core.HomeAssistant, config: ConfigType, integration: loader.Integration
|
||||
) -> None:
|
||||
"""Process all dependencies and requirements for a module.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user