mirror of
https://github.com/esphome/esphome.git
synced 2025-10-30 14:43:51 +00:00
Ruff format for CI (#8276)
This commit is contained in:
committed by
GitHub
parent
31e90e5544
commit
3020083564
@@ -128,7 +128,6 @@ VISUAL_TEMPERATURE_STEP_SCHEMA = cv.Schema(
|
||||
|
||||
|
||||
def visual_temperature_step(value):
|
||||
|
||||
# Allow defining target/current temperature steps separately
|
||||
if isinstance(value, dict):
|
||||
return VISUAL_TEMPERATURE_STEP_SCHEMA(value)
|
||||
|
||||
@@ -66,7 +66,9 @@ FINAL_VALIDATE_SCHEMA = esp32_ble.validate_variant
|
||||
|
||||
async def to_code(config):
|
||||
uuid = config[CONF_UUID].hex
|
||||
uuid_arr = [cg.RawExpression(f"0x{uuid[i:i + 2]}") for i in range(0, len(uuid), 2)]
|
||||
uuid_arr = [
|
||||
cg.RawExpression(f"0x{uuid[i : i + 2]}") for i in range(0, len(uuid), 2)
|
||||
]
|
||||
var = cg.new_Pvariable(config[CONF_ID], uuid_arr)
|
||||
|
||||
parent = await cg.get_variable(config[esp32_ble.CONF_BLE_ID])
|
||||
|
||||
@@ -112,8 +112,7 @@ def validate_supports(value):
|
||||
)
|
||||
if is_pullup and num == 16:
|
||||
raise cv.Invalid(
|
||||
"GPIO Pin 16 does not support pullup pin mode. "
|
||||
"Please choose another pin.",
|
||||
"GPIO Pin 16 does not support pullup pin mode. Please choose another pin.",
|
||||
[CONF_MODE, CONF_PULLUP],
|
||||
)
|
||||
if is_pulldown and num != 16:
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
import logging
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
import esphome.final_validate as fv
|
||||
from esphome.components import uart, climate, logger
|
||||
import logging
|
||||
|
||||
from esphome import automation
|
||||
import esphome.codegen as cg
|
||||
from esphome.components import climate, logger, uart
|
||||
from esphome.components.climate import (
|
||||
CONF_CURRENT_TEMPERATURE,
|
||||
ClimateMode,
|
||||
ClimatePreset,
|
||||
ClimateSwingMode,
|
||||
)
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
CONF_BEEPER,
|
||||
CONF_DISPLAY,
|
||||
@@ -24,12 +30,7 @@ from esphome.const import (
|
||||
CONF_VISUAL,
|
||||
CONF_WIFI,
|
||||
)
|
||||
from esphome.components.climate import (
|
||||
ClimateMode,
|
||||
ClimatePreset,
|
||||
ClimateSwingMode,
|
||||
CONF_CURRENT_TEMPERATURE,
|
||||
)
|
||||
import esphome.final_validate as fv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ from esphome.const import (
|
||||
CONF_PAYLOAD_AVAILABLE,
|
||||
CONF_PAYLOAD_NOT_AVAILABLE,
|
||||
CONF_PORT,
|
||||
CONF_PUBLISH_NAN_AS_NONE,
|
||||
CONF_QOS,
|
||||
CONF_REBOOT_TIMEOUT,
|
||||
CONF_RETAIN,
|
||||
@@ -49,7 +50,6 @@ from esphome.const import (
|
||||
CONF_USE_ABBREVIATIONS,
|
||||
CONF_USERNAME,
|
||||
CONF_WILL_MESSAGE,
|
||||
CONF_PUBLISH_NAN_AS_NONE,
|
||||
PLATFORM_BK72XX,
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_ESP8266,
|
||||
@@ -406,7 +406,7 @@ async def to_code(config):
|
||||
if CONF_SSL_FINGERPRINTS in config:
|
||||
for fingerprint in config[CONF_SSL_FINGERPRINTS]:
|
||||
arr = [
|
||||
cg.RawExpression(f"0x{fingerprint[i:i + 2]}") for i in range(0, 40, 2)
|
||||
cg.RawExpression(f"0x{fingerprint[i : i + 2]}") for i in range(0, 40, 2)
|
||||
]
|
||||
cg.add(var.add_ssl_fingerprint(arr))
|
||||
cg.add_build_flag("-DASYNC_TCP_SSL_ENABLED=1")
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import binary_sensor
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_UID
|
||||
from esphome.core import HexInt
|
||||
from .. import nfc_ns, Nfcc, NfcTagListener
|
||||
|
||||
from .. import Nfcc, NfcTagListener, nfc_ns
|
||||
|
||||
DEPENDENCIES = ["nfc"]
|
||||
|
||||
@@ -25,8 +26,7 @@ def validate_uid(value):
|
||||
for x in value.split("-"):
|
||||
if len(x) != 2:
|
||||
raise cv.Invalid(
|
||||
"Each part (separated by '-') of the UID must be two characters "
|
||||
"long."
|
||||
"Each part (separated by '-') of the UID must be two characters long."
|
||||
)
|
||||
try:
|
||||
x = int(x, 16)
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from typing import Any
|
||||
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import binary_sensor
|
||||
from .. import const, schema, validate, generate
|
||||
import esphome.config_validation as cv
|
||||
|
||||
from .. import const, generate, schema, validate
|
||||
|
||||
DEPENDENCIES = [const.OPENTHERM]
|
||||
COMPONENT_TYPE = const.BINARY_SENSOR
|
||||
@@ -11,8 +12,7 @@ COMPONENT_TYPE = const.BINARY_SENSOR
|
||||
def get_entity_validation_schema(entity: schema.BinarySensorSchema) -> cv.Schema:
|
||||
return binary_sensor.binary_sensor_schema(
|
||||
device_class=(
|
||||
entity.device_class
|
||||
or binary_sensor._UNDEF # pylint: disable=protected-access
|
||||
entity.device_class or binary_sensor._UNDEF # pylint: disable=protected-access
|
||||
),
|
||||
icon=(entity.icon or binary_sensor._UNDEF), # pylint: disable=protected-access
|
||||
)
|
||||
|
||||
@@ -3,8 +3,9 @@ from typing import Any, Callable, Optional
|
||||
|
||||
import esphome.codegen as cg
|
||||
from esphome.const import CONF_ID
|
||||
|
||||
from . import const
|
||||
from .schema import TSchema, SettingSchema
|
||||
from .schema import SettingSchema, TSchema
|
||||
|
||||
opentherm_ns = cg.esphome_ns.namespace("opentherm")
|
||||
OpenthermHub = opentherm_ns.class_("OpenthermHub", cg.Component)
|
||||
@@ -112,11 +113,10 @@ def add_messages(hub: cg.MockObj, keys: list[str], schemas: dict[str, TSchema]):
|
||||
msg_expr = cg.RawExpression(f"esphome::opentherm::MessageId::{msg}")
|
||||
if keep_updated:
|
||||
cg.add(hub.add_repeating_message(msg_expr))
|
||||
elif order is not None:
|
||||
cg.add(hub.add_initial_message(msg_expr, order))
|
||||
else:
|
||||
if order is not None:
|
||||
cg.add(hub.add_initial_message(msg_expr, order))
|
||||
else:
|
||||
cg.add(hub.add_initial_message(msg_expr))
|
||||
cg.add(hub.add_initial_message(msg_expr))
|
||||
|
||||
|
||||
def add_property_set(var: cg.MockObj, config_key: str, config: dict[str, Any]) -> None:
|
||||
@@ -128,7 +128,7 @@ Create = Callable[[dict[str, Any], str, cg.MockObj], Awaitable[cg.Pvariable]]
|
||||
|
||||
|
||||
def create_only_conf(
|
||||
create: Callable[[dict[str, Any]], Awaitable[cg.Pvariable]]
|
||||
create: Callable[[dict[str, Any]], Awaitable[cg.Pvariable]],
|
||||
) -> Create:
|
||||
return lambda conf, _key, _hub: create(conf)
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from typing import Any
|
||||
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import sensor
|
||||
from .. import const, schema, validate, generate
|
||||
import esphome.config_validation as cv
|
||||
|
||||
from .. import const, generate, schema, validate
|
||||
|
||||
DEPENDENCIES = [const.OPENTHERM]
|
||||
COMPONENT_TYPE = const.SENSOR
|
||||
@@ -22,11 +23,9 @@ MSG_DATA_TYPES = {
|
||||
|
||||
def get_entity_validation_schema(entity: schema.SensorSchema) -> cv.Schema:
|
||||
return sensor.sensor_schema(
|
||||
unit_of_measurement=entity.unit_of_measurement
|
||||
or sensor._UNDEF, # pylint: disable=protected-access
|
||||
unit_of_measurement=entity.unit_of_measurement or sensor._UNDEF, # pylint: disable=protected-access
|
||||
accuracy_decimals=entity.accuracy_decimals,
|
||||
device_class=entity.device_class
|
||||
or sensor._UNDEF, # pylint: disable=protected-access
|
||||
device_class=entity.device_class or sensor._UNDEF, # pylint: disable=protected-access
|
||||
icon=entity.icon or sensor._UNDEF, # pylint: disable=protected-access
|
||||
state_class=entity.state_class,
|
||||
).extend(
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import binary_sensor
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_UID
|
||||
from esphome.core import HexInt
|
||||
from . import pn532_ns, PN532, CONF_PN532_ID
|
||||
|
||||
from . import CONF_PN532_ID, PN532, pn532_ns
|
||||
|
||||
DEPENDENCIES = ["pn532"]
|
||||
|
||||
@@ -13,8 +14,7 @@ def validate_uid(value):
|
||||
for x in value.split("-"):
|
||||
if len(x) != 2:
|
||||
raise cv.Invalid(
|
||||
"Each part (separated by '-') of the UID must be two characters "
|
||||
"long."
|
||||
"Each part (separated by '-') of the UID must be two characters long."
|
||||
)
|
||||
try:
|
||||
x = int(x, 16)
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import binary_sensor
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_UID
|
||||
from esphome.core import HexInt
|
||||
from . import rc522_ns, RC522, CONF_RC522_ID
|
||||
|
||||
from . import CONF_RC522_ID, RC522, rc522_ns
|
||||
|
||||
DEPENDENCIES = ["rc522"]
|
||||
|
||||
@@ -13,8 +14,7 @@ def validate_uid(value):
|
||||
for x in value.split("-"):
|
||||
if len(x) != 2:
|
||||
raise cv.Invalid(
|
||||
"Each part (separated by '-') of the UID must be two characters "
|
||||
"long."
|
||||
"Each part (separated by '-') of the UID must be two characters long."
|
||||
)
|
||||
try:
|
||||
x = int(x, 16)
|
||||
|
||||
@@ -137,7 +137,7 @@ def validate_temperature_preset(preset, root_config, name, requirements):
|
||||
|
||||
|
||||
def generate_comparable_preset(config, name):
|
||||
comparable_preset = f"{CONF_PRESET}:\n" f" - {CONF_NAME}: {name}\n"
|
||||
comparable_preset = f"{CONF_PRESET}:\n - {CONF_NAME}: {name}\n"
|
||||
|
||||
if CONF_DEFAULT_TARGET_TEMPERATURE_LOW in config:
|
||||
comparable_preset += f" {CONF_DEFAULT_TARGET_TEMPERATURE_LOW}: {config[CONF_DEFAULT_TARGET_TEMPERATURE_LOW]}\n"
|
||||
|
||||
Reference in New Issue
Block a user