mirror of
https://github.com/home-assistant/core.git
synced 2026-04-27 20:23:58 +01:00
Fix pylint warnings in testing config custom components (#119370)
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
"""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_setup_platform(
|
||||
hass, config, async_add_entities_callback, discovery_info=None
|
||||
):
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
async_add_entities_callback: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the test image_processing platform."""
|
||||
async_add_entities_callback([TestImageProcessing("camera.demo_camera", "Test")])
|
||||
|
||||
@@ -13,7 +19,7 @@ async def async_setup_platform(
|
||||
class TestImageProcessing(ImageProcessingEntity):
|
||||
"""Test image processing entity."""
|
||||
|
||||
def __init__(self, camera_entity, name):
|
||||
def __init__(self, camera_entity, name) -> None:
|
||||
"""Initialize test image processing."""
|
||||
self._name = name
|
||||
self._camera = camera_entity
|
||||
|
||||
@@ -5,6 +5,9 @@ Call init before using it in your tests to ensure clean test data.
|
||||
|
||||
from homeassistant.components.light import ColorMode, LightEntity
|
||||
from homeassistant.const import STATE_OFF, STATE_ON
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
from tests.common import MockToggleEntity
|
||||
|
||||
@@ -13,6 +16,7 @@ ENTITIES = []
|
||||
|
||||
def init(empty=False):
|
||||
"""Initialize the platform with entities."""
|
||||
# pylint: disable-next=global-statement
|
||||
global ENTITIES # noqa: PLW0603
|
||||
|
||||
ENTITIES = (
|
||||
@@ -27,8 +31,11 @@ def init(empty=False):
|
||||
|
||||
|
||||
async def async_setup_platform(
|
||||
hass, config, async_add_entities_callback, discovery_info=None
|
||||
):
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
async_add_entities_callback: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Return mock entities."""
|
||||
async_add_entities_callback(ENTITIES)
|
||||
|
||||
@@ -64,7 +71,7 @@ class MockLight(MockToggleEntity, LightEntity):
|
||||
state,
|
||||
unique_id=None,
|
||||
supported_color_modes: set[ColorMode] | None = None,
|
||||
):
|
||||
) -> None:
|
||||
"""Initialize the mock light."""
|
||||
super().__init__(name, state, unique_id)
|
||||
if supported_color_modes is None:
|
||||
|
||||
@@ -4,6 +4,9 @@ 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.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
from tests.common import MockEntity
|
||||
|
||||
@@ -12,6 +15,7 @@ ENTITIES = {}
|
||||
|
||||
def init(empty=False):
|
||||
"""Initialize the platform with entities."""
|
||||
# pylint: disable-next=global-statement
|
||||
global ENTITIES # noqa: PLW0603
|
||||
|
||||
ENTITIES = (
|
||||
@@ -35,8 +39,11 @@ def init(empty=False):
|
||||
|
||||
|
||||
async def async_setup_platform(
|
||||
hass, config, async_add_entities_callback, discovery_info=None
|
||||
):
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
async_add_entities_callback: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Return mock entities."""
|
||||
async_add_entities_callback(list(ENTITIES.values()))
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@ 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 AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
from tests.common import MockToggleEntity
|
||||
|
||||
@@ -13,6 +16,7 @@ ENTITIES = []
|
||||
|
||||
def init(empty=False):
|
||||
"""Initialize the platform with entities."""
|
||||
# pylint: disable-next=global-statement
|
||||
global ENTITIES # noqa: PLW0603
|
||||
|
||||
ENTITIES = (
|
||||
@@ -27,8 +31,11 @@ def init(empty=False):
|
||||
|
||||
|
||||
async def async_setup_platform(
|
||||
hass, config, async_add_entities_callback, discovery_info=None
|
||||
):
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
async_add_entities_callback: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Return mock entities."""
|
||||
async_add_entities_callback(ENTITIES)
|
||||
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
"""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, config, async_add_entities_callback, discovery_info=None
|
||||
):
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
async_add_entities_callback: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Stub setup for translation tests."""
|
||||
async_add_entities_callback([])
|
||||
|
||||
@@ -33,6 +33,7 @@ ENTITIES = []
|
||||
|
||||
def init(empty=False):
|
||||
"""Initialize the platform with entities."""
|
||||
# pylint: disable-next=global-statement
|
||||
global ENTITIES # noqa: PLW0603
|
||||
ENTITIES = [] if empty else [MockWeather()]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user