From c81a5de2a202bc1ed610c45e719c784057649698 Mon Sep 17 00:00:00 2001 From: jkerdreux-imt <jerome.kerdreux@imt-atlantique.fr> Date: Fri, 6 Dec 2024 23:53:17 +0100 Subject: [PATCH] Format stuff --- apps/homeassistant/xaal/bridge.py | 23 ++++++++++------------- apps/homeassistant/xaal/const.py | 19 +++++++++++-------- apps/homeassistant/xaal/light.py | 16 +++++++++++----- apps/homeassistant/xaal/pyproject.toml | 9 +++++++++ 4 files changed, 41 insertions(+), 26 deletions(-) create mode 100644 apps/homeassistant/xaal/pyproject.toml diff --git a/apps/homeassistant/xaal/bridge.py b/apps/homeassistant/xaal/bridge.py index 0deaf1d6..6994eb7f 100644 --- a/apps/homeassistant/xaal/bridge.py +++ b/apps/homeassistant/xaal/bridge.py @@ -1,25 +1,22 @@ import asyncio import functools +import logging +from typing import Any, Dict, List -from typing import Dict, List, Any - -from .const import DOMAIN -from . import utils - -from homeassistant.core import HomeAssistant, Event -from homeassistant.helpers.entity import Entity, DeviceInfo -from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.config_entries import ConfigEntry -from homeassistant.helpers import device_registry -from homeassistant.helpers.device_registry import DeviceEntry, EVENT_DEVICE_REGISTRY_UPDATED -from homeassistant.helpers import entity_registry +from homeassistant.core import Event, HomeAssistant +from homeassistant.helpers import device_registry, entity_registry +from homeassistant.helpers.device_registry import EVENT_DEVICE_REGISTRY_UPDATED, DeviceEntry +from homeassistant.helpers.entity import DeviceInfo, Entity +from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_registry import EVENT_ENTITY_REGISTRY_UPDATED -from xaal.lib import AsyncEngine, tools, Device, Message, bindings +from xaal.lib import AsyncEngine, Device, Message, bindings, tools from xaal.monitor import Monitor, Notification from xaal.monitor.monitor import Device as MonitorDevice -import logging +from . import utils +from .const import DOMAIN _LOGGER = logging.getLogger(__name__) UNSUPPORTED_TYPES = ['cli', 'hmi', 'logger'] diff --git a/apps/homeassistant/xaal/const.py b/apps/homeassistant/xaal/const.py index fa474cf3..4cbb11ab 100644 --- a/apps/homeassistant/xaal/const.py +++ b/apps/homeassistant/xaal/const.py @@ -4,12 +4,15 @@ import voluptuous as vol DOMAIN = "xaal" CONF_DB_SERVER = "db_server" -XAAL_TTS_SCHEMA = vol.Schema({ - vol.Optional("title"): cv.template, - vol.Required("message"): cv.template, -}) - -XAAL_TTS_SCHEMA = vol.Schema({ - vol.Required("message"): cv.template, -}) +XAAL_TTS_SCHEMA = vol.Schema( + { + vol.Optional("title"): cv.template, + vol.Required("message"): cv.template, + } +) +XAAL_TTS_SCHEMA = vol.Schema( + { + vol.Required("message"): cv.template, + } +) diff --git a/apps/homeassistant/xaal/light.py b/apps/homeassistant/xaal/light.py index 0958f7d0..49c24354 100644 --- a/apps/homeassistant/xaal/light.py +++ b/apps/homeassistant/xaal/light.py @@ -1,18 +1,24 @@ import logging +from homeassistant.components.light import ( + ATTR_BRIGHTNESS, + ATTR_COLOR_TEMP_KELVIN, + ATTR_HS_COLOR, + ColorMode, + LightEntity, +) from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.components.light import LightEntity, ColorMode, ATTR_BRIGHTNESS, ATTR_HS_COLOR, ATTR_COLOR_TEMP_KELVIN from .bridge import XAALEntity, async_setup_factory _LOGGER = logging.getLogger(__name__) -async def async_setup_entry(hass: HomeAssistant, - config_entry: ConfigEntry, - async_add_entities: AddEntitiesCallback) -> None: +async def async_setup_entry( + hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: AddEntitiesCallback +) -> None: binding = {'lamp.': [Lamp]} return async_setup_factory(hass, config_entry, async_add_entities, binding) @@ -47,7 +53,7 @@ class Lamp(XAALEntity, LightEntity): def hs_color(self) -> tuple[float, float] | None: hsv = self.get_attribute('hsv') if hsv: - return (hsv[0], hsv[1]*100) + return (hsv[0], hsv[1] * 100) @property def color_temp_kelvin(self) -> int | None: diff --git a/apps/homeassistant/xaal/pyproject.toml b/apps/homeassistant/xaal/pyproject.toml new file mode 100644 index 00000000..f855e0fd --- /dev/null +++ b/apps/homeassistant/xaal/pyproject.toml @@ -0,0 +1,9 @@ +[tool.ruff] +line-length = 110 + +[tool.ruff.format] +quote-style = "preserve" + +[tool.black] +line-length = 110 +skip-string-normalization = true -- GitLab