repo stringlengths 7 90 | file_url stringlengths 81 315 | file_path stringlengths 4 228 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:38:15 2026-01-05 02:33:18 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_package_loaded_executor/config_flow.py | tests/testing_config/custom_components/test_package_loaded_executor/config_flow.py | """Config flow."""
from homeassistant.core import HomeAssistant
async def _async_has_devices(hass: HomeAssistant) -> bool:
return True
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_package_loaded_loop/const.py | tests/testing_config/custom_components/test_package_loaded_loop/const.py | """Constants for test_package custom component."""
TEST = 5
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_package_loaded_loop/__init__.py | tests/testing_config/custom_components/test_package_loaded_loop/__init__.py | """Provide a mock package component."""
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
from .const import TEST # noqa: F401
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Mock a successful setup."""
return True
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_package_loaded_loop/config_flow.py | tests/testing_config/custom_components/test_package_loaded_loop/config_flow.py | """Config flow."""
from homeassistant.core import HomeAssistant
async def _async_has_devices(hass: HomeAssistant) -> bool:
return True
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/hue/comp_path_test.py | tests/testing_config/custom_components/hue/comp_path_test.py | """Custom platform for a built-in component, should not be allowed."""
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/switch/test_legacy.py | tests/testing_config/custom_components/switch/test_legacy.py | """Test switch platform for test_embedded component."""
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_package_raises_cancelled_error_config_entry/__init__.py | tests/testing_config/custom_components/test_package_raises_cancelled_error_config_entry/__init__.py | """Provide a mock package component."""
import asyncio
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Mock a successful setup."""
... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_package_raises_cancelled_error_config_entry/config_flow.py | tests/testing_config/custom_components/test_package_raises_cancelled_error_config_entry/config_flow.py | """Config flow."""
from homeassistant.config_entries import ConfigFlow
from homeassistant.core import HomeAssistant
class MockConfigFlow(
ConfigFlow, domain="test_package_raises_cancelled_error_config_entry"
):
"""Mock config flow."""
async def _async_has_devices(hass: HomeAssistant) -> bool:
"""Return... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test/weather.py | tests/testing_config/custom_components/test/weather.py | """Provide a mock weather platform.
Call init before using it in your tests to ensure clean test data.
"""
from __future__ import annotations
from typing import Any
from homeassistant.components.weather import (
ATTR_FORECAST_CLOUD_COVERAGE,
ATTR_FORECAST_HUMIDITY,
ATTR_FORECAST_IS_DAYTIME,
ATTR_FOR... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test/image_processing.py | tests/testing_config/custom_components/test/image_processing.py | """Provide a mock image processing."""
from homeassistant.components.image_processing import ImageProcessingEntity
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
async def async_... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test/switch.py | tests/testing_config/custom_components/test/switch.py | """Stub switch platform for translation tests."""
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test/lock.py | tests/testing_config/custom_components/test/lock.py | """Provide a mock lock platform.
Call init before using it in your tests to ensure clean test data.
"""
from homeassistant.components.lock import LockEntity, LockEntityFeature
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test/__init__.py | tests/testing_config/custom_components/test/__init__.py | """An integration with several platforms used with unit tests."""
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test/remote.py | tests/testing_config/custom_components/test/remote.py | """Provide a mock remote platform.
Call init before using it in your tests to ensure clean test data.
"""
from homeassistant.components.remote import RemoteEntity
from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntit... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test/light.py | tests/testing_config/custom_components/test/light.py | """Provide a mock light platform.
Call init before using it in your tests to ensure clean test data.
"""
from typing import Any, Literal
from homeassistant.components.light import ColorMode, LightEntity
from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant
from homeassistan... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_with_services/__init__.py | tests/testing_config/custom_components/test_with_services/__init__.py | """Provide a mock integration."""
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_package_raises_cancelled_error/__init__.py | tests/testing_config/custom_components/test_package_raises_cancelled_error/__init__.py | """Provide a mock package component."""
import asyncio
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Mock a successful setup."""
asyncio.current_task().cancel()
await asyncio.sle... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_no_version/__init__.py | tests/testing_config/custom_components/test_no_version/__init__.py | """Provide a mock integration."""
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_integration_frame/__init__.py | tests/testing_config/custom_components/test_integration_frame/__init__.py | """An integration which calls helpers.frame.get_integration_frame."""
import logging
from homeassistant.helpers import frame
def call_get_integration_logger(fallback_name: str) -> logging.Logger:
"""Call get_integration_logger."""
return frame.get_integration_logger(fallback_name)
def call_get_integration... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_constant_deprecation/__init__.py | tests/testing_config/custom_components/test_constant_deprecation/__init__.py | """Test deprecated constants custom integration."""
from types import ModuleType
from typing import Any
def import_deprecated_constant(module: ModuleType, constant_name: str) -> Any:
"""Import and return deprecated constant."""
return getattr(module, constant_name)
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_bad_version/__init__.py | tests/testing_config/custom_components/test_bad_version/__init__.py | """Provide a mock integration."""
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_package/const.py | tests/testing_config/custom_components/test_package/const.py | """Constants for test_package custom component."""
TEST = 5
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_package/__init__.py | tests/testing_config/custom_components/test_package/__init__.py | """Provide a mock package component."""
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
from .const import TEST # noqa: F401
DOMAIN = "test_package"
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Mock a successful setup."""
retur... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_integration_platform/const.py | tests/testing_config/custom_components/test_integration_platform/const.py | """Constants for test_package custom component."""
TEST = 5
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_integration_platform/group.py | tests/testing_config/custom_components/test_integration_platform/group.py | """Group."""
MAGIC = 1
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_integration_platform/__init__.py | tests/testing_config/custom_components/test_integration_platform/__init__.py | """Provide a mock package component."""
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
from .const import TEST # noqa: F401
DOMAIN = "test_integration_platform"
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Mock a successful setup.... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_integration_platform/config_flow.py | tests/testing_config/custom_components/test_integration_platform/config_flow.py | """Config flow."""
from homeassistant.core import HomeAssistant
async def _async_has_devices(hass: HomeAssistant) -> bool:
return True
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_legacy_state_translations/__init__.py | tests/testing_config/custom_components/test_legacy_state_translations/__init__.py | """Provide a mock package component."""
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_legacy_state_translations_bad_data/__init__.py | tests/testing_config/custom_components/test_legacy_state_translations_bad_data/__init__.py | """Provide a mock package component."""
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_embedded/switch.py | tests/testing_config/custom_components/test_embedded/switch.py | """Switch platform for the embedded component."""
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/testing_config/custom_components/test_embedded/__init__.py | tests/testing_config/custom_components/test_embedded/__init__.py | """Component with embedded platforms."""
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
DOMAIN = "test_embedded"
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Mock config."""
return True
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/script/__init__.py | tests/script/__init__.py | """Tests for scripts."""
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/tests/script/test_gen_requirements_all.py | tests/script/test_gen_requirements_all.py | """Tests for the gen_requirements_all script."""
from unittest.mock import patch
from script import gen_requirements_all
def test_overrides_normalized() -> None:
"""Test override lists are using normalized package names."""
for req in gen_requirements_all.EXCLUDED_REQUIREMENTS_ALL:
assert req == gen... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/pylint/plugins/hass_inheritance.py | pylint/plugins/hass_inheritance.py | """Plugin to enforce type hints on specific functions."""
from __future__ import annotations
import re
from astroid import nodes
from pylint.checkers import BaseChecker
from pylint.lint import PyLinter
_MODULE_REGEX: re.Pattern[str] = re.compile(r"^homeassistant\.components\.\w+(\.\w+)?$")
def _get_module_platfor... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/pylint/plugins/hass_decorator.py | pylint/plugins/hass_decorator.py | """Plugin to check decorators."""
from __future__ import annotations
from astroid import nodes
from pylint.checkers import BaseChecker
from pylint.lint import PyLinter
class HassDecoratorChecker(BaseChecker):
"""Checker for decorators."""
name = "hass_decorator"
priority = -1
msgs = {
"W747... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/pylint/plugins/hass_enforce_greek_micro_char.py | pylint/plugins/hass_enforce_greek_micro_char.py | """Plugin for checking preferred coding of μ is used."""
from __future__ import annotations
from typing import Any
from astroid import nodes
from pylint.checkers import BaseChecker
from pylint.lint import PyLinter
class HassEnforceGreekMicroCharChecker(BaseChecker):
"""Checker for micro char."""
name = "h... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/pylint/plugins/hass_async_load_fixtures.py | pylint/plugins/hass_async_load_fixtures.py | """Plugin for logger invocations."""
from __future__ import annotations
from astroid import nodes
from pylint.checkers import BaseChecker
from pylint.lint import PyLinter
FUNCTION_NAMES = (
"load_fixture",
"load_json_array_fixture",
"load_json_object_fixture",
)
class HassLoadFixturesChecker(BaseChecke... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/pylint/plugins/hass_imports.py | pylint/plugins/hass_imports.py | """Plugin for checking imports."""
from __future__ import annotations
from dataclasses import dataclass
import re
from astroid import nodes
from pylint.checkers import BaseChecker
from pylint.lint import PyLinter
@dataclass
class ObsoleteImportMatch:
"""Class for pattern matching."""
constant: re.Pattern[... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/pylint/plugins/hass_enforce_class_module.py | pylint/plugins/hass_enforce_class_module.py | """Plugin for checking if class is in correct module."""
from __future__ import annotations
from astroid import nodes
from pylint.checkers import BaseChecker
from pylint.lint import PyLinter
from homeassistant.const import Platform
_BASE_ENTITY_MODULES: set[str] = {
"BaseCoordinatorEntity",
"CoordinatorEnti... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/pylint/plugins/hass_enforce_sorted_platforms.py | pylint/plugins/hass_enforce_sorted_platforms.py | """Plugin for checking sorted platforms list."""
from __future__ import annotations
from astroid import nodes
from pylint.checkers import BaseChecker
from pylint.lint import PyLinter
class HassEnforceSortedPlatformsChecker(BaseChecker):
"""Checker for sorted platforms list."""
name = "hass_enforce_sorted_p... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/pylint/plugins/hass_enforce_type_hints.py | pylint/plugins/hass_enforce_type_hints.py | """Plugin to enforce type hints on specific functions."""
from __future__ import annotations
from dataclasses import dataclass
from enum import Enum
import re
from typing import TYPE_CHECKING
from astroid import nodes
from astroid.exceptions import NameInferenceError
from pylint.checkers import BaseChecker
from pyli... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | true |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/pylint/plugins/hass_enforce_super_call.py | pylint/plugins/hass_enforce_super_call.py | """Plugin for checking super calls."""
from __future__ import annotations
from astroid import nodes
from pylint.checkers import BaseChecker
from pylint.interfaces import INFERENCE
from pylint.lint import PyLinter
METHODS = {
"async_added_to_hass",
}
class HassEnforceSuperCallChecker(BaseChecker):
"""Checke... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/pylint/plugins/hass_logger.py | pylint/plugins/hass_logger.py | """Plugin for logger invocations."""
from __future__ import annotations
from astroid import nodes
from pylint.checkers import BaseChecker
from pylint.lint import PyLinter
LOGGER_NAMES = ("LOGGER", "_LOGGER")
LOG_LEVEL_ALLOWED_LOWER_START = ("debug",)
class HassLoggerFormatChecker(BaseChecker):
"""Checker for l... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/runner.py | homeassistant/runner.py | """Run Home Assistant."""
from __future__ import annotations
import asyncio
from collections.abc import Generator
from contextlib import contextmanager
import dataclasses
from datetime import datetime
import errno
import fcntl
from io import TextIOWrapper
import json
import logging
import os
from pathlib import Path
... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/core_config.py | homeassistant/core_config.py | """Module to help with parsing and generating configuration files."""
from __future__ import annotations
from collections import OrderedDict
from collections.abc import Sequence
from contextlib import suppress
import enum
import logging
import os
import pathlib
from typing import TYPE_CHECKING, Any, Final
from urllib... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/loader.py | homeassistant/loader.py | """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 collections.abc import Callable, Iterable
from contextlib import suppress
from ... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | true |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/setup.py | homeassistant/setup.py | """All methods needed to bootstrap a Home Assistant instance."""
from __future__ import annotations
import asyncio
from collections import defaultdict
from collections.abc import Awaitable, Callable, Generator, Mapping
import contextlib
import contextvars
from enum import StrEnum
from functools import partial
import ... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/exceptions.py | homeassistant/exceptions.py | """The exceptions used by Home Assistant."""
from __future__ import annotations
from collections.abc import Callable, Generator, Sequence
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any
from .util.event_type import EventType
if TYPE_CHECKING:
from .core import Context
_function_cache: ... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/core.py | homeassistant/core.py | """Core components of Home Assistant.
Home Assistant is a Home Automation framework for observing the state
of entities and react to changes.
"""
from __future__ import annotations
import asyncio
from collections import UserDict, defaultdict
from collections.abc import (
Callable,
Collection,
Coroutine,
... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | true |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/block_async_io.py | homeassistant/block_async_io.py | """Block blocking calls being done in asyncio."""
import builtins
from collections.abc import Callable
from contextlib import suppress
from dataclasses import dataclass
import glob
from http.client import HTTPConnection
import importlib
import os
from pathlib import Path
from ssl import SSLContext
import sys
import th... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/__main__.py | homeassistant/__main__.py | """Start Home Assistant."""
from __future__ import annotations
import argparse
from contextlib import suppress
import faulthandler
import os
import sys
import threading
from .backup_restore import restore_backup
from .const import REQUIRED_PYTHON_VER, RESTART_EXIT_CODE, __version__
FAULT_LOG_FILENAME = "home-assist... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/const.py | homeassistant/const.py | """Constants used by Home Assistant components."""
from __future__ import annotations
from enum import StrEnum
from typing import TYPE_CHECKING, Final
from .generated.entity_platforms import EntityPlatforms
from .util.event_type import EventType
from .util.hass_dict import HassKey
from .util.signal_type import Signa... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/requirements.py | homeassistant/requirements.py | """Module to handle installing requirements."""
from __future__ import annotations
import asyncio
from collections.abc import Iterable
import contextlib
import logging
import os
from typing import Any
from packaging.requirements import Requirement
from .core import HomeAssistant, callback
from .exceptions import Ho... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/config.py | homeassistant/config.py | """Module to help with parsing and generating configuration files."""
from __future__ import annotations
import asyncio
from collections import OrderedDict
from collections.abc import Callable, Hashable, Iterable, Sequence
from contextlib import suppress
from dataclasses import dataclass
from enum import StrEnum
from... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | true |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/data_entry_flow.py | homeassistant/data_entry_flow.py | """Classes to help gather user submissions."""
from __future__ import annotations
import abc
import asyncio
from collections import defaultdict
from collections.abc import Callable, Container, Coroutine, Hashable, Iterable, Mapping
from contextlib import suppress
import copy
from dataclasses import dataclass
from enu... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | true |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/__init__.py | homeassistant/__init__.py | """Init file for Home Assistant."""
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/bootstrap.py | homeassistant/bootstrap.py | """Provide methods to bootstrap a Home Assistant instance."""
from __future__ import annotations
import asyncio
from collections import defaultdict
import contextlib
from functools import partial
from itertools import chain
import logging
from logging.handlers import RotatingFileHandler, TimedRotatingFileHandler
impo... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | true |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/backup_restore.py | homeassistant/backup_restore.py | """Home Assistant module to handle restoring backups."""
from __future__ import annotations
from collections.abc import Iterable
from dataclasses import dataclass
import hashlib
import json
import logging
from pathlib import Path
import shutil
import sys
from tempfile import TemporaryDirectory
from awesomeversion im... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/config_entries.py | homeassistant/config_entries.py | """Manage config entries in Home Assistant."""
from __future__ import annotations
import asyncio
from collections import UserDict, defaultdict
from collections.abc import (
Callable,
Coroutine,
Generator,
Hashable,
Iterable,
Mapping,
ValuesView,
)
from contextvars import ContextVar
from co... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | true |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/scripts/ensure_config.py | homeassistant/scripts/ensure_config.py | """Script to ensure a configuration file exists."""
import argparse
import asyncio
import os
from homeassistant import config as config_util
from homeassistant.core import HomeAssistant
# mypy: allow-untyped-calls, allow-untyped-defs
def run(args):
"""Handle ensure config commandline script."""
parser = ar... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/scripts/check_config.py | homeassistant/scripts/check_config.py | """Script to check the configuration file."""
from __future__ import annotations
import argparse
import asyncio
from collections import OrderedDict
from collections.abc import Callable, Mapping, Sequence
from glob import glob
import json
import logging
import os
from typing import Any
from unittest.mock import patch
... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/scripts/__init__.py | homeassistant/scripts/__init__.py | """Home Assistant command line scripts."""
from __future__ import annotations
import argparse
import asyncio
from collections.abc import Sequence
import importlib
import logging
import os
import sys
from homeassistant import runner
from homeassistant.bootstrap import async_mount_local_lib_path
from homeassistant.con... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/scripts/auth.py | homeassistant/scripts/auth.py | """Script to manage users for the Home Assistant auth provider."""
import argparse
import asyncio
from collections.abc import Sequence
import logging
import os
from typing import TYPE_CHECKING
from homeassistant import runner
from homeassistant.auth import auth_manager_from_config
from homeassistant.auth.providers im... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/scripts/benchmark/__init__.py | homeassistant/scripts/benchmark/__init__.py | """Script to run benchmarks."""
from __future__ import annotations
import argparse
import asyncio
from collections.abc import Callable
from contextlib import suppress
import logging
from timeit import default_timer as timer
from homeassistant import core
from homeassistant.const import EVENT_STATE_CHANGED
from homea... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/scripts/macos/__init__.py | homeassistant/scripts/macos/__init__.py | """Script to install/uninstall HA into OS X."""
import os
import time
# mypy: allow-untyped-calls, allow-untyped-defs
def install_osx():
"""Set up to run via launchd on OS X."""
with os.popen("which hass") as inp:
hass_path = inp.read().strip()
with os.popen("whoami") as inp:
user = inp... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/enum.py | homeassistant/util/enum.py | """Helpers for working with enums."""
from collections.abc import Callable
import contextlib
from enum import Enum
from typing import TYPE_CHECKING, Any
# https://github.com/python/mypy/issues/5107
if TYPE_CHECKING:
def lru_cache[_T: Callable[..., Any]](func: _T) -> _T:
"""Stub for lru_cache."""
else:
... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/limited_size_dict.py | homeassistant/util/limited_size_dict.py | """Helpers for script and automation tracing and debugging."""
from __future__ import annotations
from collections import OrderedDict
from typing import Any
class LimitedSizeDict[_KT, _VT](OrderedDict[_KT, _VT]):
"""OrderedDict limited in size."""
def __init__(self, *args: Any, **kwds: Any) -> None:
... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/file.py | homeassistant/util/file.py | """File utility functions."""
from __future__ import annotations
import logging
import os
import tempfile
from atomicwrites import AtomicWriter
from homeassistant.exceptions import HomeAssistantError
_LOGGER = logging.getLogger(__name__)
class WriteError(HomeAssistantError):
"""Error writing the data."""
d... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/scaling.py | homeassistant/util/scaling.py | """Scaling util functions."""
from __future__ import annotations
def scale_ranged_value_to_int_range(
source_low_high_range: tuple[float, float],
target_low_high_range: tuple[float, float],
value: float,
) -> int:
"""Given a range of low and high values convert a single value to another range.
G... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/dt.py | homeassistant/util/dt.py | """Helper methods to handle the time in Home Assistant."""
from __future__ import annotations
import bisect
from contextlib import suppress
import datetime as dt
from functools import lru_cache, partial
import re
from typing import Any, Literal, overload
import zoneinfo
from aiozoneinfo import async_get_time_zone as... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/ssl.py | homeassistant/util/ssl.py | """Helper to create SSL contexts."""
import contextlib
from enum import StrEnum
from functools import cache
from os import environ
import ssl
import certifi
class SSLCipherList(StrEnum):
"""SSL cipher lists."""
PYTHON_DEFAULT = "python_default"
INTERMEDIATE = "intermediate"
MODERN = "modern"
IN... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/thread.py | homeassistant/util/thread.py | """Threading util helpers."""
import ctypes
import inspect
import logging
import threading
from typing import Any
THREADING_SHUTDOWN_TIMEOUT = 10
_LOGGER = logging.getLogger(__name__)
def deadlock_safe_shutdown() -> None:
"""Shutdown that will not deadlock."""
# threading._shutdown can deadlock forever
... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/timeout.py | homeassistant/util/timeout.py | """Advanced timeout handling.
Set of helper classes to handle timeouts of tasks with advanced options
like zones and freezing of timeouts.
"""
from __future__ import annotations
import asyncio
import enum
from types import TracebackType
from typing import Any, Self
from .async_ import run_callback_threadsafe
ZONE_... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/async_iterator.py | homeassistant/util/async_iterator.py | """Async iterator utilities."""
from __future__ import annotations
import asyncio
from collections.abc import AsyncIterator
from concurrent.futures import CancelledError, Future
from typing import Self
class Abort(Exception):
"""Raised when abort is requested."""
class AsyncIteratorReader:
"""Allow readin... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/system_info.py | homeassistant/util/system_info.py | """Util to gather system info."""
from __future__ import annotations
from functools import cache
import os
@cache
def is_official_image() -> bool:
"""Return True if Home Assistant is running in an official container."""
return os.path.isfile("/OFFICIAL_IMAGE")
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/network.py | homeassistant/util/network.py | """Network utilities."""
from __future__ import annotations
from ipaddress import IPv4Address, IPv6Address, ip_address, ip_network
import re
import yarl
# RFC6890 - IP addresses of loopback interfaces
IPV6_IPV4_LOOPBACK = ip_network("::ffff:127.0.0.0/104")
LOOPBACK_NETWORKS = (
ip_network("127.0.0.0/8"),
i... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/uuid.py | homeassistant/util/uuid.py | """Helpers to generate uuids."""
from random import getrandbits
def random_uuid_hex() -> str:
"""Generate a random UUID hex.
This uuid should not be used for cryptographically secure
operations.
"""
return f"{getrandbits(32 * 4):032x}"
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/pil.py | homeassistant/util/pil.py | """PIL utilities.
Can only be used by integrations that have pillow in their requirements.
"""
from __future__ import annotations
from PIL.ImageDraw import ImageDraw
def draw_box(
draw: ImageDraw,
box: tuple[float, float, float, float],
img_width: int,
img_height: int,
text: str = "",
color... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/async_.py | homeassistant/util/async_.py | """Asyncio utilities."""
from __future__ import annotations
from asyncio import (
AbstractEventLoop,
Future,
Semaphore,
Task,
TimerHandle,
gather,
get_running_loop,
)
from collections.abc import Awaitable, Callable, Coroutine
import concurrent.futures
import logging
import threading
from t... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/language.py | homeassistant/util/language.py | """Helper methods for language selection in Home Assistant."""
from __future__ import annotations
from collections.abc import Iterable
from dataclasses import dataclass
import math
import operator
import re
from homeassistant.const import MATCH_ALL
SEPARATOR_RE = re.compile(r"[-_]")
SAME_LANGUAGES = (
# no = sp... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/signal_type.py | homeassistant/util/signal_type.py | """Define SignalTypes for dispatcher."""
from __future__ import annotations
class _SignalTypeBase[*_Ts](str):
"""Generic base class for SignalType."""
__slots__ = ()
class SignalType[*_Ts](_SignalTypeBase[*_Ts]):
"""Generic string class for signal to improve typing."""
__slots__ = ()
class Sign... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/executor.py | homeassistant/util/executor.py | """Executor util helpers."""
from __future__ import annotations
from concurrent.futures import ThreadPoolExecutor
import contextlib
import logging
import sys
from threading import Thread
import time
import traceback
from typing import Any
from .thread import async_raise
_LOGGER = logging.getLogger(__name__)
MAX_LO... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/aiohttp.py | homeassistant/util/aiohttp.py | """Utilities to help with aiohttp."""
from __future__ import annotations
from http import HTTPStatus
import io
from typing import Any
from urllib.parse import parse_qsl
from aiohttp import payload, web
from aiohttp.typedefs import JSONDecoder
from multidict import CIMultiDict, MultiDict
from .json import json_loads... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/percentage.py | homeassistant/util/percentage.py | """Percentage util functions."""
from __future__ import annotations
from .scaling import ( # noqa: F401
int_states_in_range,
scale_ranged_value_to_int_range,
scale_to_ranged_value,
states_in_range,
)
def ordered_list_item_to_percentage[_T](ordered_list: list[_T], item: _T) -> int:
"""Determine ... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/location.py | homeassistant/util/location.py | """Module with location helpers.
detect_location_info and elevation are mocked by default during tests.
"""
from __future__ import annotations
from functools import lru_cache
import math
from typing import Any, NamedTuple
import aiohttp
from homeassistant.const import __version__ as HA_VERSION
WHOAMI_URL = "https... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/resource.py | homeassistant/util/resource.py | """Resource management utilities for Home Assistant."""
from __future__ import annotations
import logging
import os
import resource
from typing import Final
_LOGGER = logging.getLogger(__name__)
# Default soft file descriptor limit to set
DEFAULT_SOFT_FILE_LIMIT: Final = 2048
def set_open_file_descriptor_limit() ... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/variance.py | homeassistant/util/variance.py | """Util functions to help filter out similar results."""
from __future__ import annotations
from collections.abc import Callable
from datetime import datetime, timedelta
import functools
from typing import Any, overload
@overload
def ignore_variance[**_P](
func: Callable[_P, int], ignored_variance: int
) -> Cal... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/unit_conversion.py | homeassistant/util/unit_conversion.py | """Typing Helpers for Home Assistant."""
from __future__ import annotations
from collections.abc import Callable
from functools import lru_cache
from math import floor, log10
from homeassistant.const import (
CONCENTRATION_GRAMS_PER_CUBIC_METER,
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_MIL... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/frozen_dataclass_compat.py | homeassistant/util/frozen_dataclass_compat.py | """Utility to create classes from which frozen or mutable dataclasses can be derived.
This module enabled a non-breaking transition from mutable to frozen dataclasses
derived from EntityDescription and sub classes thereof.
"""
from __future__ import annotations
import dataclasses
import sys
from typing import TYPE_... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/logging.py | homeassistant/util/logging.py | """Logging utilities."""
from __future__ import annotations
from collections import defaultdict
from collections.abc import Callable, Coroutine
from functools import partial, wraps
import inspect
import logging
import logging.handlers
from queue import SimpleQueue
import time
import traceback
from typing import Any, ... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/read_only_dict.py | homeassistant/util/read_only_dict.py | """Read only dictionary."""
from copy import deepcopy
from typing import Any, final
def _readonly(*args: Any, **kwargs: Any) -> Any:
"""Raise an exception when a read only dict is modified."""
raise RuntimeError("Cannot modify ReadOnlyDict")
@final # Final to allow direct checking of the type instead of u... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/__init__.py | homeassistant/util/__init__.py | """Helper methods for various modules."""
from __future__ import annotations
from collections.abc import Callable, Coroutine, Iterable, KeysView, Mapping
from datetime import datetime, timedelta
from functools import wraps
import inspect
import random
import re
import string
import threading
from typing import Any
i... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/package.py | homeassistant/util/package.py | """Helpers to install PyPi packages."""
from __future__ import annotations
import asyncio
from functools import cache
from importlib.metadata import PackageNotFoundError, version
import logging
import os
from pathlib import Path
import site
from subprocess import PIPE, Popen
import sys
from urllib.parse import urlpar... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/collection.py | homeassistant/util/collection.py | """Helpers for working with collections."""
from collections.abc import Collection, Iterable
from functools import partial
from itertools import islice
from typing import Any
def take(take_num: int, iterable: Iterable) -> list[Any]:
"""Return first n items of the iterable as a list.
From itertools recipes
... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/hass_dict.py | homeassistant/util/hass_dict.py | """Implementation for HassDict and custom HassKey types.
Custom for type checking. See stub file.
"""
from __future__ import annotations
class HassKey[_T](str):
"""Generic Hass key type.
At runtime this is a generic subclass of str.
"""
__slots__ = ()
class HassEntryKey[_T](str):
"""Key type... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/json.py | homeassistant/util/json.py | """JSON utility functions."""
from __future__ import annotations
import logging
from os import PathLike
from typing import Any
import orjson
from homeassistant.exceptions import HomeAssistantError
_SENTINEL = object()
_LOGGER = logging.getLogger(__name__)
type JsonValueType = (
dict[str, JsonValueType] | list... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/color.py | homeassistant/util/color.py | """Color util methods."""
from __future__ import annotations
import colorsys
import math
from typing import NamedTuple
import attr
from .scaling import scale_to_ranged_value
class RGBColor(NamedTuple):
"""RGB hex values."""
r: int
g: int
b: int
# Official CSS3 colors from w3.org:
# https://www.... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/decorator.py | homeassistant/util/decorator.py | """Decorator utility functions."""
from __future__ import annotations
from collections.abc import Callable, Hashable
from typing import Any
class Registry[_KT: Hashable, _VT: Callable[..., Any]](dict[_KT, _VT]):
"""Registry of items."""
def register(self, name: _KT) -> Callable[[_VT], _VT]:
"""Retu... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/ulid.py | homeassistant/util/ulid.py | """Helpers to generate ulids."""
from __future__ import annotations
from ulid_transform import (
bytes_to_ulid,
bytes_to_ulid_or_none,
ulid_at_time,
ulid_hex,
ulid_now,
ulid_to_bytes,
ulid_to_bytes_or_none,
)
__all__ = [
"bytes_to_ulid",
"bytes_to_ulid_or_none",
"ulid",
"u... | python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
home-assistant/core | https://github.com/home-assistant/core/blob/6cae1821fb77e785a8aebb48dfc72ea5081b8975/homeassistant/util/process.py | homeassistant/util/process.py | """Util to handle processes."""
from __future__ import annotations
import subprocess
from typing import Any
def kill_subprocess(process: subprocess.Popen[Any]) -> None:
"""Force kill a subprocess and wait for it to exit."""
process.kill()
process.communicate()
process.wait()
del process
| python | Apache-2.0 | 6cae1821fb77e785a8aebb48dfc72ea5081b8975 | 2026-01-04T14:38:15.504802Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.