<commit_before>"""
The methods for loading Home Assistant integrations.

This module has quite some complex parts. I have tried to add as much
documentation as possible to keep it understandable.
"""
from __future__ import annotations

import asyncio
from contextlib import suppress
import functools as ft
import importlib
import json
import logging
import pathlib
import sys
from types import ModuleType
from typing import TYPE_CHECKING, Any, Callable, Dict, TypedDict, TypeVar, cast

from awesomeversion import AwesomeVersion, AwesomeVersionStrategy

from homeassistant.generated.dhcp import DHCP
from homeassistant.generated.mqtt import MQTT
from homeassistant.generated.ssdp import SSDP
from homeassistant.generated.zeroconf import HOMEKIT, ZEROCONF

# Typing imports that create a circular dependency
if TYPE_CHECKING:
    from homeassistant.core import HomeAssistant

# mypy: disallow-any-generics

CALLABLE_T = TypeVar(  # pylint: disable=invalid-name
    "CALLABLE_T", bound=Callable[..., Any]
)

_LOGGER = logging.getLogger(__name__)

DATA_COMPONENTS = "components"
DATA_INTEGRATIONS = "integrations"
DATA_CUSTOM_COMPONENTS = "custom_components"
PACKAGE_CUSTOM_COMPONENTS = "custom_components"
PACKAGE_BUILTIN = "homeassistant.components"
CUSTOM_WARNING = (
    "You are using a custom integration %s which has not "
    "been tested by Home Assistant. This component might "
    "cause stability problems, be sure to disable it if you "
    "experience issues with Home Assistant"
)
CUSTOM_WARNING_VERSION_MISSING = (
    "No 'version' key in the manifest file for "
    "custom integration '%s'. This will not be "
    "allowed in a future version of Home "
    "Assistant. Please report this to the "
    "maintainer of '%s'"
)
CUSTOM_WARNING_VERSION_TYPE = (
    "'%s' is not a valid version for "
    "custom integration '%s'. "
    "Please report this to the maintainer of '%s'"
)
_UNDEF = object()  # Internal; not helpers.typing.UNDEFINED due to circular dependency

MAX_LOAD_CONCURRENTLY = 4<commit_msg>Add target version to log about missing version (#48520)<commit_after>"""
The methods for loading Home Assistant integrations.

This module has quite some complex parts. I have tried to add as much
documentation as possible to keep it understandable.
"""
from __future__ import annotations

import asyncio
from contextlib import suppress
import functools as ft
import importlib
import json
import logging
import pathlib
import sys
from types import ModuleType
from typing import TYPE_CHECKING, Any, Callable, Dict, TypedDict, TypeVar, cast

from awesomeversion import AwesomeVersion, AwesomeVersionStrategy

from homeassistant.generated.dhcp import DHCP
from homeassistant.generated.mqtt import MQTT
from homeassistant.generated.ssdp import SSDP
from homeassistant.generated.zeroconf import HOMEKIT, ZEROCONF

# Typing imports that create a circular dependency
if TYPE_CHECKING:
    from homeassistant.core import HomeAssistant

# mypy: disallow-any-generics

CALLABLE_T = TypeVar(  # pylint: disable=invalid-name
    "CALLABLE_T", bound=Callable[..., Any]
)

_LOGGER = logging.getLogger(__name__)

DATA_COMPONENTS = "components"
DATA_INTEGRATIONS = "integrations"
DATA_CUSTOM_COMPONENTS = "custom_components"
PACKAGE_CUSTOM_COMPONENTS = "custom_components"
PACKAGE_BUILTIN = "homeassistant.components"
CUSTOM_WARNING = (
    "You are using a custom integration %s which has not "
    "been tested by Home Assistant. This component might "
    "cause stability problems, be sure to disable it if you "
    "experience issues with Home Assistant"
)
CUSTOM_WARNING_VERSION_MISSING = (
    "No 'version' key in the manifest file for "
    "custom integration '%s'. As of Home Assistant "
    "2021.6, this integration will no longer be "
    "loaded. Please report this to the maintainer of '%s'"
)
CUSTOM_WARNING_VERSION_TYPE = (
    "'%s' is not a valid version for "
    "custom integration '%s'. "
    "Please report this to the maintainer of '%s'"
)
_UNDEF = object()  # Internal; not helpers.typing.UNDEFINED due to circular dependency

MAX_LOAD_CONCURRENTLY = 4
{'fraction_non_alphanumeric': 0.06730298580518845, 'fraction_numerical': 0.002936857562408223, 'mean_word_length': 4.880575539568345, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1037380', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1175, 'n_words': 445}