mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 06:58:11 +01:00
[code-quality] Organise core imports (#7149)
This commit is contained in:
parent
20c2246533
commit
e64709c37e
32 changed files with 190 additions and 186 deletions
|
@ -1,12 +1,12 @@
|
||||||
# PYTHON_ARGCOMPLETE_OK
|
# PYTHON_ARGCOMPLETE_OK
|
||||||
import argparse
|
import argparse
|
||||||
|
from datetime import datetime
|
||||||
import functools
|
import functools
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
import argcomplete
|
import argcomplete
|
||||||
|
|
||||||
|
@ -39,14 +39,14 @@ from esphome.const import (
|
||||||
)
|
)
|
||||||
from esphome.core import CORE, EsphomeError, coroutine
|
from esphome.core import CORE, EsphomeError, coroutine
|
||||||
from esphome.helpers import indent, is_ip_address
|
from esphome.helpers import indent, is_ip_address
|
||||||
|
from esphome.log import Fore, color, setup_log
|
||||||
from esphome.util import (
|
from esphome.util import (
|
||||||
|
get_serial_ports,
|
||||||
|
list_yaml_files,
|
||||||
run_external_command,
|
run_external_command,
|
||||||
run_external_process,
|
run_external_process,
|
||||||
safe_print,
|
safe_print,
|
||||||
list_yaml_files,
|
|
||||||
get_serial_ports,
|
|
||||||
)
|
)
|
||||||
from esphome.log import color, setup_log, Fore
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -116,6 +116,7 @@ def get_port_type(port):
|
||||||
|
|
||||||
def run_miniterm(config, port):
|
def run_miniterm(config, port):
|
||||||
import serial
|
import serial
|
||||||
|
|
||||||
from esphome import platformio_api
|
from esphome import platformio_api
|
||||||
|
|
||||||
if CONF_LOGGER not in config:
|
if CONF_LOGGER not in config:
|
||||||
|
@ -596,9 +597,10 @@ def command_update_all(args):
|
||||||
|
|
||||||
|
|
||||||
def command_idedata(args, config):
|
def command_idedata(args, config):
|
||||||
from esphome import platformio_api
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from esphome import platformio_api
|
||||||
|
|
||||||
logging.disable(logging.INFO)
|
logging.disable(logging.INFO)
|
||||||
logging.disable(logging.WARNING)
|
logging.disable(logging.WARNING)
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,10 @@ from esphome.const import (
|
||||||
CONF_ELSE,
|
CONF_ELSE,
|
||||||
CONF_ID,
|
CONF_ID,
|
||||||
CONF_THEN,
|
CONF_THEN,
|
||||||
|
CONF_TIME,
|
||||||
CONF_TIMEOUT,
|
CONF_TIMEOUT,
|
||||||
CONF_TRIGGER_ID,
|
CONF_TRIGGER_ID,
|
||||||
CONF_TYPE_ID,
|
CONF_TYPE_ID,
|
||||||
CONF_TIME,
|
|
||||||
CONF_UPDATE_INTERVAL,
|
CONF_UPDATE_INTERVAL,
|
||||||
)
|
)
|
||||||
from esphome.schema_extractors import SCHEMA_EXTRACT, schema_extractor
|
from esphome.schema_extractors import SCHEMA_EXTRACT, schema_extractor
|
||||||
|
|
|
@ -8,55 +8,78 @@
|
||||||
# want to break suddenly due to a rename (this file will get backports for features).
|
# want to break suddenly due to a rename (this file will get backports for features).
|
||||||
|
|
||||||
# pylint: disable=unused-import
|
# pylint: disable=unused-import
|
||||||
from esphome.cpp_generator import ( # noqa
|
from esphome.cpp_generator import ( # noqa: F401
|
||||||
|
ArrayInitializer,
|
||||||
Expression,
|
Expression,
|
||||||
|
LineComment,
|
||||||
|
MockObj,
|
||||||
|
MockObjClass,
|
||||||
|
Pvariable,
|
||||||
RawExpression,
|
RawExpression,
|
||||||
RawStatement,
|
RawStatement,
|
||||||
TemplateArguments,
|
|
||||||
StructInitializer,
|
|
||||||
ArrayInitializer,
|
|
||||||
safe_exp,
|
|
||||||
Statement,
|
Statement,
|
||||||
LineComment,
|
StructInitializer,
|
||||||
progmem_array,
|
TemplateArguments,
|
||||||
static_const_array,
|
|
||||||
statement,
|
|
||||||
variable,
|
|
||||||
with_local_variable,
|
|
||||||
new_variable,
|
|
||||||
Pvariable,
|
|
||||||
new_Pvariable,
|
|
||||||
add,
|
add,
|
||||||
add_global,
|
|
||||||
add_library,
|
|
||||||
add_build_flag,
|
add_build_flag,
|
||||||
add_define,
|
add_define,
|
||||||
|
add_global,
|
||||||
|
add_library,
|
||||||
add_platformio_option,
|
add_platformio_option,
|
||||||
get_variable,
|
get_variable,
|
||||||
get_variable_with_full_id,
|
get_variable_with_full_id,
|
||||||
process_lambda,
|
|
||||||
is_template,
|
is_template,
|
||||||
|
new_Pvariable,
|
||||||
|
new_variable,
|
||||||
|
process_lambda,
|
||||||
|
progmem_array,
|
||||||
|
safe_exp,
|
||||||
|
statement,
|
||||||
|
static_const_array,
|
||||||
templatable,
|
templatable,
|
||||||
MockObj,
|
variable,
|
||||||
MockObjClass,
|
with_local_variable,
|
||||||
)
|
)
|
||||||
from esphome.cpp_helpers import ( # noqa
|
from esphome.cpp_helpers import ( # noqa: F401
|
||||||
gpio_pin_expression,
|
|
||||||
register_component,
|
|
||||||
build_registry_entry,
|
build_registry_entry,
|
||||||
build_registry_list,
|
build_registry_list,
|
||||||
extract_registry_entry_config,
|
extract_registry_entry_config,
|
||||||
register_parented,
|
gpio_pin_expression,
|
||||||
past_safe_mode,
|
past_safe_mode,
|
||||||
|
register_component,
|
||||||
|
register_parented,
|
||||||
)
|
)
|
||||||
from esphome.cpp_types import ( # noqa
|
from esphome.cpp_types import ( # noqa: F401
|
||||||
global_ns,
|
NAN,
|
||||||
void,
|
App,
|
||||||
nullptr,
|
Application,
|
||||||
float_,
|
Component,
|
||||||
double,
|
ComponentPtr,
|
||||||
|
Controller,
|
||||||
|
EntityBase,
|
||||||
|
EntityCategory,
|
||||||
|
ESPTime,
|
||||||
|
GPIOPin,
|
||||||
|
InternalGPIOPin,
|
||||||
|
JsonObject,
|
||||||
|
JsonObjectConst,
|
||||||
|
Parented,
|
||||||
|
PollingComponent,
|
||||||
|
arduino_json_ns,
|
||||||
bool_,
|
bool_,
|
||||||
|
const_char_ptr,
|
||||||
|
double,
|
||||||
|
esphome_ns,
|
||||||
|
float_,
|
||||||
|
global_ns,
|
||||||
|
gpio_Flags,
|
||||||
|
int16,
|
||||||
|
int32,
|
||||||
|
int64,
|
||||||
int_,
|
int_,
|
||||||
|
nullptr,
|
||||||
|
optional,
|
||||||
|
size_t,
|
||||||
std_ns,
|
std_ns,
|
||||||
std_shared_ptr,
|
std_shared_ptr,
|
||||||
std_string,
|
std_string,
|
||||||
|
@ -66,28 +89,5 @@ from esphome.cpp_types import ( # noqa
|
||||||
uint16,
|
uint16,
|
||||||
uint32,
|
uint32,
|
||||||
uint64,
|
uint64,
|
||||||
int16,
|
void,
|
||||||
int32,
|
|
||||||
int64,
|
|
||||||
size_t,
|
|
||||||
const_char_ptr,
|
|
||||||
NAN,
|
|
||||||
esphome_ns,
|
|
||||||
App,
|
|
||||||
EntityBase,
|
|
||||||
Component,
|
|
||||||
ComponentPtr,
|
|
||||||
PollingComponent,
|
|
||||||
Application,
|
|
||||||
optional,
|
|
||||||
arduino_json_ns,
|
|
||||||
JsonObject,
|
|
||||||
JsonObjectConst,
|
|
||||||
Controller,
|
|
||||||
GPIOPin,
|
|
||||||
InternalGPIOPin,
|
|
||||||
gpio_Flags,
|
|
||||||
EntityCategory,
|
|
||||||
Parented,
|
|
||||||
ESPTime,
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,40 +1,38 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
from contextlib import contextmanager
|
||||||
|
import contextvars
|
||||||
import functools
|
import functools
|
||||||
import heapq
|
import heapq
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
from typing import Any, Union
|
||||||
from typing import Union, Any
|
|
||||||
|
|
||||||
from contextlib import contextmanager
|
|
||||||
import contextvars
|
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from esphome import core, yaml_util, loader, pins
|
from esphome import core, loader, pins, yaml_util
|
||||||
import esphome.core.config as core_config
|
from esphome.config_helpers import Extend, Remove
|
||||||
|
import esphome.config_validation as cv
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
CONF_ESPHOME,
|
CONF_ESPHOME,
|
||||||
CONF_ID,
|
|
||||||
CONF_PLATFORM,
|
|
||||||
CONF_PACKAGES,
|
|
||||||
CONF_SUBSTITUTIONS,
|
|
||||||
CONF_EXTERNAL_COMPONENTS,
|
CONF_EXTERNAL_COMPONENTS,
|
||||||
|
CONF_ID,
|
||||||
|
CONF_PACKAGES,
|
||||||
|
CONF_PLATFORM,
|
||||||
|
CONF_SUBSTITUTIONS,
|
||||||
TARGET_PLATFORMS,
|
TARGET_PLATFORMS,
|
||||||
)
|
)
|
||||||
from esphome.core import CORE, EsphomeError, DocumentRange
|
from esphome.core import CORE, DocumentRange, EsphomeError
|
||||||
from esphome.helpers import indent
|
import esphome.core.config as core_config
|
||||||
from esphome.util import safe_print, OrderedDict
|
|
||||||
|
|
||||||
from esphome.config_helpers import Extend, Remove
|
|
||||||
from esphome.loader import get_component, get_platform, ComponentManifest
|
|
||||||
from esphome.yaml_util import is_secret, ESPHomeDataBase, ESPForceValue
|
|
||||||
from esphome.voluptuous_schema import ExtraKeysInvalid
|
|
||||||
from esphome.log import color, Fore
|
|
||||||
import esphome.final_validate as fv
|
import esphome.final_validate as fv
|
||||||
import esphome.config_validation as cv
|
from esphome.helpers import indent
|
||||||
from esphome.types import ConfigType, ConfigFragmentType
|
from esphome.loader import ComponentManifest, get_component, get_platform
|
||||||
|
from esphome.log import Fore, color
|
||||||
|
from esphome.types import ConfigFragmentType, ConfigType
|
||||||
|
from esphome.util import OrderedDict, safe_print
|
||||||
|
from esphome.voluptuous_schema import ExtraKeysInvalid
|
||||||
|
from esphome.yaml_util import ESPForceValue, ESPHomeDataBase, is_secret
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
"""Helpers for config validation using voluptuous."""
|
"""Helpers for config validation using voluptuous."""
|
||||||
|
|
||||||
|
from contextlib import contextmanager
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
from datetime import datetime
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from contextlib import contextmanager
|
|
||||||
import uuid as uuid_
|
|
||||||
from datetime import datetime
|
|
||||||
from string import ascii_letters, digits
|
from string import ascii_letters, digits
|
||||||
|
import uuid as uuid_
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
@ -17,37 +17,37 @@ from esphome.config_helpers import Extend, Remove
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
ALLOWED_NAME_CHARS,
|
ALLOWED_NAME_CHARS,
|
||||||
CONF_AVAILABILITY,
|
CONF_AVAILABILITY,
|
||||||
CONF_COMMAND_TOPIC,
|
|
||||||
CONF_COMMAND_RETAIN,
|
CONF_COMMAND_RETAIN,
|
||||||
|
CONF_COMMAND_TOPIC,
|
||||||
|
CONF_DAY,
|
||||||
CONF_DISABLED_BY_DEFAULT,
|
CONF_DISABLED_BY_DEFAULT,
|
||||||
CONF_DISCOVERY,
|
CONF_DISCOVERY,
|
||||||
CONF_ENTITY_CATEGORY,
|
CONF_ENTITY_CATEGORY,
|
||||||
|
CONF_HOUR,
|
||||||
CONF_ICON,
|
CONF_ICON,
|
||||||
CONF_ID,
|
CONF_ID,
|
||||||
CONF_INTERNAL,
|
CONF_INTERNAL,
|
||||||
|
CONF_MINUTE,
|
||||||
|
CONF_MONTH,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
|
CONF_PASSWORD,
|
||||||
|
CONF_PATH,
|
||||||
CONF_PAYLOAD_AVAILABLE,
|
CONF_PAYLOAD_AVAILABLE,
|
||||||
CONF_PAYLOAD_NOT_AVAILABLE,
|
CONF_PAYLOAD_NOT_AVAILABLE,
|
||||||
CONF_RETAIN,
|
|
||||||
CONF_QOS,
|
CONF_QOS,
|
||||||
|
CONF_REF,
|
||||||
|
CONF_RETAIN,
|
||||||
|
CONF_SECOND,
|
||||||
CONF_SETUP_PRIORITY,
|
CONF_SETUP_PRIORITY,
|
||||||
CONF_STATE_TOPIC,
|
CONF_STATE_TOPIC,
|
||||||
CONF_TOPIC,
|
CONF_TOPIC,
|
||||||
CONF_YEAR,
|
|
||||||
CONF_MONTH,
|
|
||||||
CONF_DAY,
|
|
||||||
CONF_HOUR,
|
|
||||||
CONF_MINUTE,
|
|
||||||
CONF_SECOND,
|
|
||||||
CONF_VALUE,
|
|
||||||
CONF_UPDATE_INTERVAL,
|
|
||||||
CONF_TYPE_ID,
|
|
||||||
CONF_TYPE,
|
CONF_TYPE,
|
||||||
CONF_REF,
|
CONF_TYPE_ID,
|
||||||
|
CONF_UPDATE_INTERVAL,
|
||||||
CONF_URL,
|
CONF_URL,
|
||||||
CONF_PATH,
|
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
CONF_PASSWORD,
|
CONF_VALUE,
|
||||||
|
CONF_YEAR,
|
||||||
ENTITY_CATEGORY_CONFIG,
|
ENTITY_CATEGORY_CONFIG,
|
||||||
ENTITY_CATEGORY_DIAGNOSTIC,
|
ENTITY_CATEGORY_DIAGNOSTIC,
|
||||||
ENTITY_CATEGORY_NONE,
|
ENTITY_CATEGORY_NONE,
|
||||||
|
@ -71,15 +71,15 @@ from esphome.core import (
|
||||||
TimePeriod,
|
TimePeriod,
|
||||||
TimePeriodMicroseconds,
|
TimePeriodMicroseconds,
|
||||||
TimePeriodMilliseconds,
|
TimePeriodMilliseconds,
|
||||||
|
TimePeriodMinutes,
|
||||||
TimePeriodNanoseconds,
|
TimePeriodNanoseconds,
|
||||||
TimePeriodSeconds,
|
TimePeriodSeconds,
|
||||||
TimePeriodMinutes,
|
|
||||||
)
|
)
|
||||||
from esphome.helpers import list_starts_with, add_class_to_obj
|
from esphome.helpers import add_class_to_obj, list_starts_with
|
||||||
from esphome.schema_extractors import (
|
from esphome.schema_extractors import (
|
||||||
SCHEMA_EXTRACT,
|
SCHEMA_EXTRACT,
|
||||||
schema_extractor_list,
|
|
||||||
schema_extractor,
|
schema_extractor,
|
||||||
|
schema_extractor_list,
|
||||||
schema_extractor_registry,
|
schema_extractor_registry,
|
||||||
schema_extractor_typed,
|
schema_extractor_typed,
|
||||||
)
|
)
|
||||||
|
@ -1686,9 +1686,9 @@ class SplitDefault(Optional):
|
||||||
if CORE.is_esp32:
|
if CORE.is_esp32:
|
||||||
from esphome.components.esp32 import get_esp32_variant
|
from esphome.components.esp32 import get_esp32_variant
|
||||||
from esphome.components.esp32.const import (
|
from esphome.components.esp32.const import (
|
||||||
|
VARIANT_ESP32C3,
|
||||||
VARIANT_ESP32S2,
|
VARIANT_ESP32S2,
|
||||||
VARIANT_ESP32S3,
|
VARIANT_ESP32S3,
|
||||||
VARIANT_ESP32C3,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
variant = get_esp32_variant()
|
variant = get_esp32_variant()
|
||||||
|
|
|
@ -7,26 +7,29 @@ from typing import TYPE_CHECKING, Optional, Union
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
CONF_COMMENT,
|
CONF_COMMENT,
|
||||||
CONF_ESPHOME,
|
CONF_ESPHOME,
|
||||||
CONF_USE_ADDRESS,
|
|
||||||
CONF_ETHERNET,
|
CONF_ETHERNET,
|
||||||
|
CONF_PORT,
|
||||||
|
CONF_USE_ADDRESS,
|
||||||
CONF_WEB_SERVER,
|
CONF_WEB_SERVER,
|
||||||
CONF_WIFI,
|
CONF_WIFI,
|
||||||
CONF_PORT,
|
|
||||||
KEY_CORE,
|
KEY_CORE,
|
||||||
KEY_TARGET_FRAMEWORK,
|
KEY_TARGET_FRAMEWORK,
|
||||||
KEY_TARGET_PLATFORM,
|
KEY_TARGET_PLATFORM,
|
||||||
|
PLATFORM_BK72XX,
|
||||||
PLATFORM_ESP32,
|
PLATFORM_ESP32,
|
||||||
PLATFORM_ESP8266,
|
PLATFORM_ESP8266,
|
||||||
PLATFORM_BK72XX,
|
|
||||||
PLATFORM_RTL87XX,
|
|
||||||
PLATFORM_RP2040,
|
|
||||||
PLATFORM_HOST,
|
PLATFORM_HOST,
|
||||||
|
PLATFORM_RP2040,
|
||||||
|
PLATFORM_RTL87XX,
|
||||||
)
|
)
|
||||||
from esphome.coroutine import FakeAwaitable as _FakeAwaitable
|
|
||||||
from esphome.coroutine import FakeEventLoop as _FakeEventLoop
|
|
||||||
|
|
||||||
# pylint: disable=unused-import
|
# pylint: disable=unused-import
|
||||||
from esphome.coroutine import coroutine, coroutine_with_priority # noqa
|
from esphome.coroutine import ( # noqa: F401
|
||||||
|
FakeAwaitable as _FakeAwaitable,
|
||||||
|
FakeEventLoop as _FakeEventLoop,
|
||||||
|
coroutine,
|
||||||
|
coroutine_with_priority,
|
||||||
|
)
|
||||||
from esphome.helpers import ensure_unique_string, get_str_env, is_ha_addon
|
from esphome.helpers import ensure_unique_string, get_str_env, is_ha_addon
|
||||||
from esphome.util import OrderedDict
|
from esphome.util import OrderedDict
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@ import multiprocessing
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from esphome import automation
|
||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome import automation
|
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
CONF_ARDUINO_VERSION,
|
CONF_ARDUINO_VERSION,
|
||||||
CONF_AREA,
|
CONF_AREA,
|
||||||
|
@ -16,11 +16,11 @@ from esphome.const import (
|
||||||
CONF_COMPILE_PROCESS_LIMIT,
|
CONF_COMPILE_PROCESS_LIMIT,
|
||||||
CONF_ESPHOME,
|
CONF_ESPHOME,
|
||||||
CONF_FRAMEWORK,
|
CONF_FRAMEWORK,
|
||||||
|
CONF_FRIENDLY_NAME,
|
||||||
CONF_INCLUDES,
|
CONF_INCLUDES,
|
||||||
CONF_LIBRARIES,
|
CONF_LIBRARIES,
|
||||||
CONF_MIN_VERSION,
|
CONF_MIN_VERSION,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_FRIENDLY_NAME,
|
|
||||||
CONF_ON_BOOT,
|
CONF_ON_BOOT,
|
||||||
CONF_ON_LOOP,
|
CONF_ON_LOOP,
|
||||||
CONF_ON_SHUTDOWN,
|
CONF_ON_SHUTDOWN,
|
||||||
|
@ -34,8 +34,8 @@ from esphome.const import (
|
||||||
CONF_TYPE,
|
CONF_TYPE,
|
||||||
CONF_VERSION,
|
CONF_VERSION,
|
||||||
KEY_CORE,
|
KEY_CORE,
|
||||||
TARGET_PLATFORMS,
|
|
||||||
PLATFORM_ESP8266,
|
PLATFORM_ESP8266,
|
||||||
|
TARGET_PLATFORMS,
|
||||||
__version__ as ESPHOME_VERSION,
|
__version__ as ESPHOME_VERSION,
|
||||||
)
|
)
|
||||||
from esphome.core import CORE, coroutine_with_priority
|
from esphome.core import CORE, coroutine_with_priority
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import esphome.final_validate as fv
|
|
||||||
|
|
||||||
from esphome.const import CONF_ID
|
from esphome.const import CONF_ID
|
||||||
|
import esphome.final_validate as fv
|
||||||
|
|
||||||
|
|
||||||
def inherit_property_from(property_to_inherit, parent_id_property, transform=None):
|
def inherit_property_from(property_to_inherit, parent_id_property, transform=None):
|
||||||
|
|
|
@ -43,13 +43,13 @@ the last `yield` expression defines what is returned.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
|
from collections.abc import Awaitable, Generator, Iterator
|
||||||
import functools
|
import functools
|
||||||
import heapq
|
import heapq
|
||||||
import inspect
|
import inspect
|
||||||
import logging
|
import logging
|
||||||
import types
|
import types
|
||||||
from typing import Any, Callable
|
from typing import Any, Callable
|
||||||
from collections.abc import Awaitable, Generator, Iterator
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import abc
|
import abc
|
||||||
|
from collections.abc import Sequence
|
||||||
import inspect
|
import inspect
|
||||||
import math
|
import math
|
||||||
import re
|
import re
|
||||||
from collections.abc import Sequence
|
|
||||||
from typing import Any, Callable, Optional, Union
|
from typing import Any, Callable, Optional, Union
|
||||||
|
|
||||||
from esphome.core import (
|
from esphome.core import (
|
||||||
|
|
|
@ -12,15 +12,13 @@ from esphome.const import (
|
||||||
CONF_UPDATE_INTERVAL,
|
CONF_UPDATE_INTERVAL,
|
||||||
KEY_PAST_SAFE_MODE,
|
KEY_PAST_SAFE_MODE,
|
||||||
)
|
)
|
||||||
|
from esphome.core import CORE, ID, coroutine
|
||||||
from esphome.core import coroutine, ID, CORE
|
|
||||||
from esphome.coroutine import FakeAwaitable
|
from esphome.coroutine import FakeAwaitable
|
||||||
from esphome.types import ConfigType, ConfigFragmentType
|
|
||||||
from esphome.cpp_generator import add, get_variable
|
from esphome.cpp_generator import add, get_variable
|
||||||
from esphome.cpp_types import App
|
from esphome.cpp_types import App
|
||||||
|
from esphome.helpers import sanitize, snake_case
|
||||||
|
from esphome.types import ConfigFragmentType, ConfigType
|
||||||
from esphome.util import Registry, RegistryEntry
|
from esphome.util import Registry, RegistryEntry
|
||||||
from esphome.helpers import snake_case, sanitize
|
|
||||||
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from collections.abc import Coroutine
|
||||||
import contextlib
|
import contextlib
|
||||||
import logging
|
|
||||||
import threading
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
import logging
|
||||||
|
import threading
|
||||||
from typing import TYPE_CHECKING, Any, Callable
|
from typing import TYPE_CHECKING, Any, Callable
|
||||||
from collections.abc import Coroutine
|
|
||||||
|
|
||||||
from ..zeroconf import DiscoveredImport
|
from ..zeroconf import DiscoveredImport
|
||||||
from .dns import DNSCache
|
from .dns import DNSCache
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from asyncio import events
|
||||||
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import threading
|
import threading
|
||||||
import traceback
|
|
||||||
from asyncio import events
|
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
|
||||||
from time import monotonic
|
from time import monotonic
|
||||||
|
import traceback
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from esphome.storage_json import EsphomeStorageJSON, esphome_storage_path
|
from esphome.storage_json import EsphomeStorageJSON, esphome_storage_path
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from collections import defaultdict
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from collections import defaultdict
|
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
from esphome import const, util
|
from esphome import const, util
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import tempfile
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import tempfile
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import base64
|
import base64
|
||||||
|
from collections.abc import Iterable
|
||||||
import datetime
|
import datetime
|
||||||
import functools
|
import functools
|
||||||
import gzip
|
import gzip
|
||||||
|
@ -9,13 +10,12 @@ import hashlib
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
from pathlib import Path
|
||||||
import secrets
|
import secrets
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
from collections.abc import Iterable
|
|
||||||
from pathlib import Path
|
|
||||||
from typing import TYPE_CHECKING, Any, Callable, TypeVar
|
from typing import TYPE_CHECKING, Any, Callable, TypeVar
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
@ -26,13 +26,13 @@ import tornado.httpserver
|
||||||
import tornado.httputil
|
import tornado.httputil
|
||||||
import tornado.ioloop
|
import tornado.ioloop
|
||||||
import tornado.iostream
|
import tornado.iostream
|
||||||
|
from tornado.log import access_log
|
||||||
import tornado.netutil
|
import tornado.netutil
|
||||||
import tornado.process
|
import tornado.process
|
||||||
import tornado.queues
|
import tornado.queues
|
||||||
import tornado.web
|
import tornado.web
|
||||||
import tornado.websocket
|
import tornado.websocket
|
||||||
import yaml
|
import yaml
|
||||||
from tornado.log import access_log
|
|
||||||
from yaml.nodes import Node
|
from yaml.nodes import Node
|
||||||
|
|
||||||
from esphome import const, platformio_api, yaml_util
|
from esphome import const, platformio_api, yaml_util
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
|
||||||
from pathlib import Path
|
|
||||||
import os
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.core import CORE, TimePeriodSeconds
|
|
||||||
from esphome.const import __version__
|
from esphome.const import __version__
|
||||||
|
from esphome.core import CORE, TimePeriodSeconds
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
CODEOWNERS = ["@landonr"]
|
CODEOWNERS = ["@landonr"]
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from typing import Any
|
|
||||||
import contextvars
|
import contextvars
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from esphome.types import ConfigFragmentType, ID, ConfigPathType
|
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
|
from esphome.types import ID, ConfigFragmentType, ConfigPathType
|
||||||
|
|
||||||
|
|
||||||
class FinalValidateConfig(ABC):
|
class FinalValidateConfig(ABC):
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import hashlib
|
|
||||||
import logging
|
|
||||||
import re
|
|
||||||
import subprocess
|
|
||||||
import urllib.parse
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import hashlib
|
||||||
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
from typing import Callable, Optional
|
from typing import Callable, Optional
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.core import CORE, TimePeriodSeconds
|
from esphome.core import CORE, TimePeriodSeconds
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
import codecs
|
import codecs
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import platform
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Union
|
import platform
|
||||||
import tempfile
|
|
||||||
from urllib.parse import urlparse
|
|
||||||
import re
|
import re
|
||||||
|
import tempfile
|
||||||
|
from typing import Union
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -129,9 +128,10 @@ def _resolve_with_zeroconf(host):
|
||||||
|
|
||||||
|
|
||||||
def resolve_ip_address(host):
|
def resolve_ip_address(host):
|
||||||
from esphome.core import EsphomeError
|
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
|
from esphome.core import EsphomeError
|
||||||
|
|
||||||
errs = []
|
errs = []
|
||||||
|
|
||||||
if host.endswith(".local"):
|
if host.endswith(".local"):
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
import ssl
|
import ssl
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import json
|
|
||||||
|
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
|
|
||||||
|
@ -24,9 +24,9 @@ from esphome.const import (
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
)
|
)
|
||||||
from esphome.core import CORE, EsphomeError
|
from esphome.core import CORE, EsphomeError
|
||||||
from esphome.log import color, Fore
|
from esphome.helpers import get_int_env, get_str_env
|
||||||
|
from esphome.log import Fore, color
|
||||||
from esphome.util import safe_print
|
from esphome.util import safe_print
|
||||||
from esphome.helpers import get_str_env, get_int_env
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
import operator
|
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
import esphome.config_validation as cv
|
import operator
|
||||||
from esphome.core import CORE
|
|
||||||
|
|
||||||
|
import esphome.config_validation as cv
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
|
CONF_ALLOW_OTHER_USES,
|
||||||
|
CONF_IGNORE_STRAPPING_WARNING,
|
||||||
CONF_INPUT,
|
CONF_INPUT,
|
||||||
|
CONF_INVERTED,
|
||||||
CONF_MODE,
|
CONF_MODE,
|
||||||
CONF_NUMBER,
|
CONF_NUMBER,
|
||||||
CONF_OPEN_DRAIN,
|
CONF_OPEN_DRAIN,
|
||||||
CONF_OUTPUT,
|
CONF_OUTPUT,
|
||||||
CONF_PULLDOWN,
|
CONF_PULLDOWN,
|
||||||
CONF_PULLUP,
|
CONF_PULLUP,
|
||||||
CONF_IGNORE_STRAPPING_WARNING,
|
|
||||||
CONF_ALLOW_OTHER_USES,
|
|
||||||
CONF_INVERTED,
|
|
||||||
)
|
)
|
||||||
|
from esphome.core import CORE
|
||||||
|
|
||||||
|
|
||||||
class PinRegistry(dict):
|
class PinRegistry(dict):
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import json
|
import json
|
||||||
from typing import Union
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
from pathlib import Path
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
from esphome.const import CONF_COMPILE_PROCESS_LIMIT, CONF_ESPHOME, KEY_CORE
|
from esphome.const import CONF_COMPILE_PROCESS_LIMIT, CONF_ESPHOME, KEY_CORE
|
||||||
from esphome.core import CORE, EsphomeError
|
from esphome.core import CORE, EsphomeError
|
||||||
|
@ -20,9 +19,10 @@ def patch_structhash():
|
||||||
# removed/added. This might have unintended consequences, but this improves compile
|
# removed/added. This might have unintended consequences, but this improves compile
|
||||||
# times greatly when adding/removing components and a simple clean build solves
|
# times greatly when adding/removing components and a simple clean build solves
|
||||||
# all issues
|
# all issues
|
||||||
from platformio.run import helpers, cli
|
|
||||||
from os.path import join, isdir, getmtime
|
|
||||||
from os import makedirs
|
from os import makedirs
|
||||||
|
from os.path import getmtime, isdir, join
|
||||||
|
|
||||||
|
from platformio.run import cli, helpers
|
||||||
|
|
||||||
def patched_clean_build_dir(build_dir, *args):
|
def patched_clean_build_dir(build_dir, *args):
|
||||||
from platformio import fs
|
from platformio import fs
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import binascii
|
import binascii
|
||||||
import codecs
|
import codecs
|
||||||
|
from datetime import datetime
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
from esphome import const
|
from esphome import const
|
||||||
from esphome.const import CONF_DISABLED, CONF_MDNS
|
from esphome.const import CONF_DISABLED, CONF_MDNS
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
from esphome.core import ID, Lambda, EsphomeCore
|
from esphome.core import ID, EsphomeCore, Lambda
|
||||||
|
|
||||||
ConfigFragmentType = Union[
|
ConfigFragmentType = Union[
|
||||||
str,
|
str,
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
from typing import Union
|
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
from pathlib import Path
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from typing import Union
|
||||||
|
|
||||||
from esphome import const
|
from esphome import const
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import difflib
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from esphome.schema_extractors import schema_extractor_extended
|
from esphome.schema_extractors import schema_extractor_extended
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from io import StringIO
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from io import StringIO
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from esphome.yaml_util import parse_yaml
|
from esphome.config import Config, _format_vol_invalid, validate_config
|
||||||
from esphome.config import validate_config, _format_vol_invalid, Config
|
|
||||||
from esphome.core import CORE, DocumentRange
|
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
|
from esphome.core import CORE, DocumentRange
|
||||||
|
from esphome.yaml_util import parse_yaml
|
||||||
|
|
||||||
|
|
||||||
def _get_invalid_range(res: Config, invalid: cv.Invalid) -> DocumentRange | None:
|
def _get_invalid_range(res: Config, invalid: cv.Invalid) -> DocumentRange | None:
|
||||||
|
|
|
@ -276,8 +276,8 @@ def wizard(path):
|
||||||
from esphome.components.bk72xx import boards as bk72xx_boards
|
from esphome.components.bk72xx import boards as bk72xx_boards
|
||||||
from esphome.components.esp32 import boards as esp32_boards
|
from esphome.components.esp32 import boards as esp32_boards
|
||||||
from esphome.components.esp8266 import boards as esp8266_boards
|
from esphome.components.esp8266 import boards as esp8266_boards
|
||||||
from esphome.components.rtl87xx import boards as rtl87xx_boards
|
|
||||||
from esphome.components.rp2040 import boards as rp2040_boards
|
from esphome.components.rp2040 import boards as rp2040_boards
|
||||||
|
from esphome.components.rtl87xx import boards as rtl87xx_boards
|
||||||
|
|
||||||
if not path.endswith(".yaml") and not path.endswith(".yml"):
|
if not path.endswith(".yaml") and not path.endswith(".yml"):
|
||||||
safe_print(
|
safe_print(
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import re
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
from esphome.config import iter_components, iter_component_configs
|
from esphome import loader
|
||||||
|
from esphome.config import iter_component_configs, iter_components
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
|
ENV_NOGITIGNORE,
|
||||||
HEADER_FILE_EXTENSIONS,
|
HEADER_FILE_EXTENSIONS,
|
||||||
SOURCE_FILE_EXTENSIONS,
|
SOURCE_FILE_EXTENSIONS,
|
||||||
__version__,
|
__version__,
|
||||||
ENV_NOGITIGNORE,
|
|
||||||
)
|
)
|
||||||
from esphome.core import CORE, EsphomeError
|
from esphome.core import CORE, EsphomeError
|
||||||
from esphome.helpers import (
|
from esphome.helpers import (
|
||||||
mkdir_p,
|
|
||||||
read_file,
|
|
||||||
write_file_if_changed,
|
|
||||||
walk_files,
|
|
||||||
copy_file_if_changed,
|
copy_file_if_changed,
|
||||||
get_bool_env,
|
get_bool_env,
|
||||||
|
mkdir_p,
|
||||||
|
read_file,
|
||||||
|
walk_files,
|
||||||
|
write_file_if_changed,
|
||||||
)
|
)
|
||||||
from esphome.storage_json import StorageJSON, storage_path
|
from esphome.storage_json import StorageJSON, storage_path
|
||||||
from esphome import loader
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -3,16 +3,16 @@ from __future__ import annotations
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import functools
|
import functools
|
||||||
import inspect
|
import inspect
|
||||||
|
from io import TextIOWrapper
|
||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
import os
|
import os
|
||||||
import uuid
|
|
||||||
from io import TextIOWrapper
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
import uuid
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
import yaml.constructor
|
|
||||||
from yaml import SafeLoader as PurePythonLoader
|
from yaml import SafeLoader as PurePythonLoader
|
||||||
|
import yaml.constructor
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from yaml import CSafeLoader as FastestAvailableSafeLoader
|
from yaml import CSafeLoader as FastestAvailableSafeLoader
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
import logging
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
from zeroconf import IPVersion, ServiceInfo, ServiceStateChange, Zeroconf
|
from zeroconf import IPVersion, ServiceInfo, ServiceStateChange, Zeroconf
|
||||||
|
|
Loading…
Reference in a new issue