Skip to content

Commit

Permalink
Run formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jul 8, 2023
1 parent ea73ce7 commit ddca17d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
4 changes: 3 additions & 1 deletion custom_components/powercalc/__init__.py
Expand Up @@ -222,7 +222,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
await discovery_manager.start_discovery()

sensors: list = domain_config.get(CONF_SENSORS, [])
sorted_sensors = sorted(sensors, key=lambda x: (CONF_INCLUDE in x, x.get(CONF_INCLUDE, False)))
sorted_sensors = sorted(
sensors, key=lambda x: (CONF_INCLUDE in x, x.get(CONF_INCLUDE, False))

Check failure on line 226 in custom_components/powercalc/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (COM812)

custom_components/powercalc/__init__.py:226:79: COM812 Trailing comma missing
)
for sensor_config in sorted_sensors:
sensor_config.update({DISCOVERY_TYPE: PowercalcDiscoveryType.USER_YAML})
hass.async_create_task(
Expand Down
4 changes: 3 additions & 1 deletion custom_components/powercalc/sensor.py
Expand Up @@ -604,7 +604,9 @@ async def create_sensors( # noqa: C901
_LOGGER.debug("Found include entities: %s", include_entities)
for source_entity in include_entities:
if source_entity.entity_id in hass.data[DOMAIN][DATA_CONFIGURED_ENTITIES]:
entities_to_add.existing.extend(hass.data[DOMAIN][DATA_CONFIGURED_ENTITIES][source_entity.entity_id])
entities_to_add.existing.extend(
hass.data[DOMAIN][DATA_CONFIGURED_ENTITIES][source_entity.entity_id]

Check failure on line 608 in custom_components/powercalc/sensor.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (COM812)

custom_components/powercalc/sensor.py:608:89: COM812 Trailing comma missing
)

# Create sensors for each entity
for sensor_config in sensor_configs.values():
Expand Down
17 changes: 13 additions & 4 deletions tests/group_include/test_include.py
Expand Up @@ -3,7 +3,13 @@

import pytest
from homeassistant.components import light
from homeassistant.const import CONF_DOMAIN, CONF_ENTITIES, CONF_ENTITY_ID, CONF_UNIQUE_ID, STATE_OFF
from homeassistant.const import (
CONF_DOMAIN,
CONF_ENTITIES,
CONF_ENTITY_ID,
CONF_UNIQUE_ID,
STATE_OFF,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.area_registry import AreaRegistry
from homeassistant.helpers.device_registry import DeviceEntry
Expand Down Expand Up @@ -343,8 +349,9 @@ async def test_include_filter_domain(
assert group_state.attributes.get(ATTR_ENTITIES) == {"sensor.test_light_power"}


async def test_include_yaml_configured_entity(hass: HomeAssistant, entity_reg: EntityRegistry,
area_reg: AreaRegistry) -> None:
async def test_include_yaml_configured_entity(
hass: HomeAssistant, entity_reg: EntityRegistry, area_reg: AreaRegistry
) -> None:
"""Test that include also includes entities that the user configured with YAML"""

light_a = MockLight("light_a")
Expand Down Expand Up @@ -393,7 +400,9 @@ async def test_include_yaml_configured_entity(hass: HomeAssistant, entity_reg: E
}


def _create_powercalc_config_entry(hass: HomeAssistant, source_entity_id: str) -> MockConfigEntry:
def _create_powercalc_config_entry(
hass: HomeAssistant, source_entity_id: str
) -> MockConfigEntry:
unique_id = str(uuid.uuid4())
entry = MockConfigEntry(
domain=DOMAIN,
Expand Down

0 comments on commit ddca17d

Please sign in to comment.