mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Fix pylint warnings in testing config custom components (#119370)
This commit is contained in:
parent
2c7022950c
commit
d376371c25
@ -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()]
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
"""Component with embedded platforms."""
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
DOMAIN = "test_embedded"
|
||||
|
||||
|
||||
async def async_setup(hass, config):
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Mock config."""
|
||||
return True
|
||||
|
@ -1,7 +1,14 @@
|
||||
"""Switch platform for the embedded component."""
|
||||
|
||||
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:
|
||||
"""Find and return test switches."""
|
||||
|
@ -1,10 +1,13 @@
|
||||
"""Provide a mock package component."""
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import TEST # noqa: F401
|
||||
|
||||
DOMAIN = "test_integration_platform"
|
||||
|
||||
|
||||
async def async_setup(hass, config):
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Mock a successful setup."""
|
||||
return True
|
||||
|
@ -1,10 +1,13 @@
|
||||
"""Provide a mock package component."""
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import TEST # noqa: F401
|
||||
|
||||
DOMAIN = "test_package"
|
||||
|
||||
|
||||
async def async_setup(hass, config):
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Mock a successful setup."""
|
||||
return True
|
||||
|
@ -1,10 +1,13 @@
|
||||
"""Provide a mock package component."""
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import TEST # noqa: F401
|
||||
|
||||
DOMAIN = "test_package"
|
||||
|
||||
|
||||
async def async_setup(hass, config):
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Mock a successful setup."""
|
||||
return True
|
||||
|
@ -1,8 +1,11 @@
|
||||
"""Provide a mock package component."""
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import TEST # noqa: F401
|
||||
|
||||
|
||||
async def async_setup(hass, config):
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Mock a successful setup."""
|
||||
return True
|
||||
|
@ -2,8 +2,11 @@
|
||||
|
||||
import asyncio
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
async def async_setup(hass, config):
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Mock a successful setup."""
|
||||
asyncio.current_task().cancel()
|
||||
await asyncio.sleep(0)
|
||||
|
@ -2,13 +2,17 @@
|
||||
|
||||
import asyncio
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
async def async_setup(hass, config):
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Mock a successful setup."""
|
||||
return True
|
||||
|
||||
|
||||
async def async_setup_entry(hass, entry):
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||
"""Mock an unsuccessful entry setup."""
|
||||
asyncio.current_task().cancel()
|
||||
await asyncio.sleep(0)
|
||||
|
@ -1,8 +1,11 @@
|
||||
"""Provide a mock standalone component."""
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
DOMAIN = "test_standalone"
|
||||
|
||||
|
||||
async def async_setup(hass, config):
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Mock a successful setup."""
|
||||
return True
|
||||
|
Loading…
x
Reference in New Issue
Block a user