Add constructor return type in integrations T-Z (#50899)

pull/50090/head
Michael 2021-05-20 17:00:19 +02:00 committed by GitHub
parent c650deef98
commit 9eecd90afc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 77 additions and 63 deletions

View File

@ -106,7 +106,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class OptionsFlowHandler(config_entries.OptionsFlow):
"""Handle a option flow for tado."""
def __init__(self, config_entry: config_entries.ConfigEntry):
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
"""Initialize options flow."""
self.config_entry = config_entry

View File

@ -41,7 +41,7 @@ UPDATE_FIELDS = {
class TagIDExistsError(HomeAssistantError):
"""Raised when an item is not found."""
def __init__(self, item_id: str):
def __init__(self, item_id: str) -> None:
"""Initialize tag ID exists error."""
super().__init__(f"Tag with ID {item_id} already exists.")
self.item_id = item_id

View File

@ -224,7 +224,7 @@ class SensorTemplate(TemplateEntity, SensorEntity):
device_class: str | None,
attribute_templates: dict[str, template.Template],
unique_id: str | None,
):
) -> None:
"""Initialize the sensor."""
super().__init__(
attribute_templates=attribute_templates,

View File

@ -33,7 +33,7 @@ class _TemplateAttribute:
validator: Callable[[Any], Any] = None,
on_update: Callable[[Any], None] | None = None,
none_on_template_error: bool | None = False,
):
) -> None:
"""Template attribute."""
self._entity = entity
self._attribute = attribute

View File

@ -29,7 +29,7 @@ class TriggerEntity(update_coordinator.CoordinatorEntity):
hass: HomeAssistant,
coordinator: TriggerUpdateCoordinator,
config: dict,
):
) -> None:
"""Initialize the entity."""
super().__init__(coordinator)

View File

@ -36,7 +36,7 @@ class TeslaConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
VERSION = 1
def __init__(self):
def __init__(self) -> None:
"""Initialize the tesla flow."""
self.username = None
self.reauth = False

View File

@ -188,7 +188,7 @@ class TimerStorageCollection(collection.StorageCollection):
class Timer(RestoreEntity):
"""Representation of a timer."""
def __init__(self, config: dict):
def __init__(self, config: dict) -> None:
"""Initialize a timer."""
self._config: dict = config
self.editable: bool = True

View File

@ -27,7 +27,7 @@ class ToonDataUpdateCoordinator(DataUpdateCoordinator[Status]):
def __init__(
self, hass: HomeAssistant, *, entry: ConfigEntry, session: OAuth2Session
):
) -> None:
"""Initialize global Toon data updater."""
self.session = session
self.entry = entry

View File

@ -58,7 +58,7 @@ class ToonLocalOAuth2Implementation(config_entry_oauth2_flow.LocalOAuth2Implemen
name: str,
tenant_id: str,
issuer: str | None = None,
):
) -> None:
"""Local Toon Oauth Implementation."""
self._name = name
self.tenant_id = tenant_id

View File

@ -32,7 +32,7 @@ class SmartDevices:
def __init__(
self, lights: list[SmartDevice] = None, switches: list[SmartDevice] = None
):
) -> None:
"""Initialize device holder."""
self._lights = lights or []
self._switches = switches or []

View File

@ -46,7 +46,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entitie
class SmartPlugSwitch(SwitchEntity):
"""Representation of a TPLink Smart Plug switch."""
def __init__(self, smartplug: SmartPlug):
def __init__(self, smartplug: SmartPlug) -> None:
"""Initialize the switch."""
self.smartplug = smartplug
self._sysinfo = None

View File

@ -60,7 +60,7 @@ class ActionTrace:
config: dict[str, Any],
blueprint_inputs: dict[str, Any],
context: Context,
):
) -> None:
"""Container for script trace."""
self._trace: dict[str, deque[TraceElement]] | None = None
self._config: dict[str, Any] = config

View File

@ -83,7 +83,7 @@ class TuyaConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
VERSION = 1
def __init__(self):
def __init__(self) -> None:
"""Initialize flow."""
self._country_code = None
self._password = None
@ -151,7 +151,7 @@ class TuyaConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class OptionsFlowHandler(config_entries.OptionsFlow):
"""Handle a option flow for Tuya."""
def __init__(self, config_entry: config_entries.ConfigEntry):
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
"""Initialize options flow."""
self.config_entry = config_entry
self._conf_devs_id = None

View File

@ -47,7 +47,7 @@ class TwinklyLight(LightEntity):
self,
conf: ConfigEntry,
hass: HomeAssistant,
):
) -> None:
"""Initialize a TwinklyLight entity."""
self._id = conf.data[CONF_ENTRY_ID]
self._hass = hass

View File

@ -54,7 +54,7 @@ async def async_get_scanner(hass, config):
class UPCDeviceScanner(DeviceScanner):
"""This class queries a router running UPC ConnectBox firmware."""
def __init__(self, connect_box: ConnectBox):
def __init__(self, connect_box: ConnectBox) -> None:
"""Initialize the scanner."""
self.connect_box: ConnectBox = connect_box

View File

@ -101,7 +101,7 @@ class UpCloudConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class UpCloudOptionsFlow(config_entries.OptionsFlow):
"""UpCloud options flow."""
def __init__(self, config_entry: config_entries.ConfigEntry):
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
"""Initialize options flow."""
self.config_entry = config_entry

View File

@ -44,7 +44,9 @@ RESPONSE_SCHEMA = vol.Schema(
class Updater:
"""Updater class for data exchange."""
def __init__(self, update_available: bool, newest_version: str, release_notes: str):
def __init__(
self, update_available: bool, newest_version: str, release_notes: str
) -> None:
"""Initialize attributes."""
self.update_available = update_available
self.release_notes = release_notes

View File

@ -212,7 +212,9 @@ DeviceType = TypeVar("DeviceType", bound=veraApi.VeraDevice)
class VeraDevice(Generic[DeviceType], Entity):
"""Representation of a Vera device entity."""
def __init__(self, vera_device: DeviceType, controller_data: ControllerData):
def __init__(
self, vera_device: DeviceType, controller_data: ControllerData
) -> None:
"""Initialize the device."""
self.vera_device = vera_device
self.controller = controller_data.controller

View File

@ -37,7 +37,7 @@ class VeraBinarySensor(VeraDevice[veraApi.VeraBinarySensor], BinarySensorEntity)
def __init__(
self, vera_device: veraApi.VeraBinarySensor, controller_data: ControllerData
):
) -> None:
"""Initialize the binary_sensor."""
self._state = False
VeraDevice.__init__(self, vera_device, controller_data)

View File

@ -56,7 +56,7 @@ class VeraThermostat(VeraDevice[veraApi.VeraThermostat], ClimateEntity):
def __init__(
self, vera_device: veraApi.VeraThermostat, controller_data: ControllerData
):
) -> None:
"""Initialize the Vera device."""
VeraDevice.__init__(self, vera_device, controller_data)
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)

View File

@ -67,7 +67,7 @@ def options_data(user_input: dict) -> dict:
class OptionsFlowHandler(config_entries.OptionsFlow):
"""Options for the component."""
def __init__(self, config_entry: ConfigEntry):
def __init__(self, config_entry: ConfigEntry) -> None:
"""Init object."""
self.config_entry = config_entry

View File

@ -40,7 +40,7 @@ class VeraCover(VeraDevice[veraApi.VeraCurtain], CoverEntity):
def __init__(
self, vera_device: veraApi.VeraCurtain, controller_data: ControllerData
):
) -> None:
"""Initialize the Vera device."""
VeraDevice.__init__(self, vera_device, controller_data)
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)

View File

@ -44,7 +44,7 @@ class VeraLight(VeraDevice[veraApi.VeraDimmer], LightEntity):
def __init__(
self, vera_device: veraApi.VeraDimmer, controller_data: ControllerData
):
) -> None:
"""Initialize the light."""
self._state = False
self._color = None

View File

@ -41,7 +41,9 @@ async def async_setup_entry(
class VeraLock(VeraDevice[veraApi.VeraLock], LockEntity):
"""Representation of a Vera lock."""
def __init__(self, vera_device: veraApi.VeraLock, controller_data: ControllerData):
def __init__(
self, vera_device: veraApi.VeraLock, controller_data: ControllerData
) -> None:
"""Initialize the Vera device."""
self._state = None
VeraDevice.__init__(self, vera_device, controller_data)

View File

@ -30,7 +30,9 @@ async def async_setup_entry(
class VeraScene(Scene):
"""Representation of a Vera scene entity."""
def __init__(self, vera_scene: veraApi.VeraScene, controller_data: ControllerData):
def __init__(
self, vera_scene: veraApi.VeraScene, controller_data: ControllerData
) -> None:
"""Initialize the scene."""
self.vera_scene = vera_scene
self.controller = controller_data.controller

View File

@ -44,7 +44,7 @@ class VeraSensor(VeraDevice[veraApi.VeraSensor], SensorEntity):
def __init__(
self, vera_device: veraApi.VeraSensor, controller_data: ControllerData
):
) -> None:
"""Initialize the sensor."""
self.current_value = None
self._temperature_units = None

View File

@ -40,7 +40,7 @@ class VeraSwitch(VeraDevice[veraApi.VeraSwitch], SwitchEntity):
def __init__(
self, vera_device: veraApi.VeraSwitch, controller_data: ControllerData
):
) -> None:
"""Initialize the Vera device."""
self._state = False
VeraDevice.__init__(self, vera_device, controller_data)

View File

@ -53,7 +53,7 @@ class VerisureSmartcam(CoordinatorEntity, Camera):
coordinator: VerisureDataUpdateCoordinator,
serial_number: str,
directory_path: str,
):
) -> None:
"""Initialize Verisure File Camera component."""
super().__init__(coordinator)
Camera.__init__(self)

View File

@ -111,7 +111,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
class VersionData:
"""Get the latest data and update the states."""
def __init__(self, api: HaVersion):
def __init__(self, api: HaVersion) -> None:
"""Initialize the data object."""
self.api = api
@ -131,7 +131,7 @@ class VersionData:
class VersionSensor(SensorEntity):
"""Representation of a Home Assistant version sensor."""
def __init__(self, data: VersionData, name: str):
def __init__(self, data: VersionData, name: str) -> None:
"""Initialize the Version sensor."""
self.data = data
self._name = name

View File

@ -131,7 +131,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
class WemoDispatcher:
"""Dispatch WeMo devices to the correct platform."""
def __init__(self, config_entry: ConfigEntry):
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize the WemoDispatcher."""
self._config_entry = config_entry
self._added_serial_numbers = set()

View File

@ -480,7 +480,7 @@ class ConfigEntryWithingsApi(AbstractWithingsApi):
hass: HomeAssistant,
config_entry: ConfigEntry,
implementation: AbstractOAuth2Implementation,
):
) -> None:
"""Initialize object."""
self._hass = hass
self._config_entry = config_entry
@ -564,7 +564,7 @@ class DataManager:
api: ConfigEntryWithingsApi,
user_id: int,
webhook_config: WebhookConfig,
):
) -> None:
"""Initialize the data manager."""
self._hass = hass
self._api = api

View File

@ -102,7 +102,7 @@ class WLEDDataUpdateCoordinator(DataUpdateCoordinator[WLEDDevice]):
hass: HomeAssistant,
*,
host: str,
):
) -> None:
"""Initialize global WLED data updater."""
self.wled = WLED(host, session=async_get_clientsession(hass))

View File

@ -96,7 +96,7 @@ async def async_setup_entry(
class WLEDMasterLight(LightEntity, WLEDDeviceEntity):
"""Defines a WLED master light."""
def __init__(self, entry_id: str, coordinator: WLEDDataUpdateCoordinator):
def __init__(self, entry_id: str, coordinator: WLEDDataUpdateCoordinator) -> None:
"""Initialize WLED master light."""
super().__init__(
entry_id=entry_id,
@ -177,7 +177,7 @@ class WLEDSegmentLight(LightEntity, WLEDDeviceEntity):
def __init__(
self, entry_id: str, coordinator: WLEDDataUpdateCoordinator, segment: int
):
) -> None:
"""Initialize WLED segment light."""
self._rgbw = coordinator.data.info.leds.rgbw
self._segment = segment

View File

@ -135,7 +135,7 @@ class WLEDSyncSendSwitch(WLEDSwitch):
class WLEDSyncReceiveSwitch(WLEDSwitch):
"""Defines a WLED sync receive switch."""
def __init__(self, entry_id: str, coordinator: WLEDDataUpdateCoordinator):
def __init__(self, entry_id: str, coordinator: WLEDDataUpdateCoordinator) -> None:
"""Initialize WLED sync receive switch."""
super().__init__(
coordinator=coordinator,

View File

@ -74,7 +74,7 @@ class WUSensorConfig:
icon: str = "mdi:gauge",
extra_state_attributes=None,
device_class=None,
):
) -> None:
"""Initialize sensor configuration.
:param friendly_name: Friendly name
@ -106,7 +106,7 @@ class WUCurrentConditionsSensorConfig(WUSensorConfig):
icon: str | None = "mdi:gauge",
unit_of_measurement: str | None = None,
device_class=None,
):
) -> None:
"""Initialize current conditions sensor configuration.
:param friendly_name: Friendly name of sensor
@ -133,7 +133,9 @@ class WUCurrentConditionsSensorConfig(WUSensorConfig):
class WUDailyTextForecastSensorConfig(WUSensorConfig):
"""Helper for defining sensor configurations for daily text forecasts."""
def __init__(self, period: int, field: str, unit_of_measurement: str | None = None):
def __init__(
self, period: int, field: str, unit_of_measurement: str | None = None
) -> None:
"""Initialize daily text forecast sensor configuration.
:param period: forecast period number
@ -170,7 +172,7 @@ class WUDailySimpleForecastSensorConfig(WUSensorConfig):
ha_unit: str | None = None,
icon=None,
device_class=None,
):
) -> None:
"""Initialize daily simple forecast sensor configuration.
:param friendly_name: friendly_name of the sensor
@ -213,7 +215,7 @@ class WUDailySimpleForecastSensorConfig(WUSensorConfig):
class WUHourlyForecastSensorConfig(WUSensorConfig):
"""Helper for defining sensor configurations for hourly text forecasts."""
def __init__(self, period: int, field: int):
def __init__(self, period: int, field: int) -> None:
"""Initialize hourly forecast sensor configuration.
:param period: forecast period number
@ -280,7 +282,7 @@ class WUAlmanacSensorConfig(WUSensorConfig):
unit_of_measurement: str,
icon: str,
device_class=None,
):
) -> None:
"""Initialize almanac sensor configuration.
:param friendly_name: Friendly name
@ -303,7 +305,7 @@ class WUAlmanacSensorConfig(WUSensorConfig):
class WUAlertsSensorConfig(WUSensorConfig):
"""Helper for defining field configuration for alerts."""
def __init__(self, friendly_name: str | Callable):
def __init__(self, friendly_name: str | Callable) -> None:
"""Initialiize alerts sensor configuration.
:param friendly_name: Friendly name
@ -1120,7 +1122,9 @@ async def async_setup_platform(
class WUndergroundSensor(SensorEntity):
"""Implementing the WUnderground sensor."""
def __init__(self, hass: HomeAssistant, rest, condition, unique_id_base: str):
def __init__(
self, hass: HomeAssistant, rest, condition, unique_id_base: str
) -> None:
"""Initialize the sensor."""
self.rest = rest
self._condition = condition

View File

@ -14,7 +14,7 @@ class AsyncConfigEntryAuth(AuthenticationManager):
self,
websession: ClientSession,
oauth_session: config_entry_oauth2_flow.OAuth2Session,
):
) -> None:
"""Initialize xbox auth."""
# Leaving out client credentials as they are handled by Home Assistant
super().__init__(websession, "", "", "")

View File

@ -12,7 +12,9 @@ from .const import DOMAIN
class XboxBaseSensorEntity(CoordinatorEntity):
"""Base Sensor for the Xbox Integration."""
def __init__(self, coordinator: XboxUpdateCoordinator, xuid: str, attribute: str):
def __init__(
self, coordinator: XboxUpdateCoordinator, xuid: str, attribute: str
) -> None:
"""Initialize Xbox binary sensor."""
super().__init__(coordinator)
self.xuid = xuid

View File

@ -74,7 +74,7 @@ class XboxSource(MediaSource):
name: str = "Xbox Game Media"
def __init__(self, hass: HomeAssistant, client: XboxLiveClient):
def __init__(self, hass: HomeAssistant, client: XboxLiveClient) -> None:
"""Initialize Xbox source."""
super().__init__(DOMAIN)

View File

@ -77,7 +77,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
class YamahaConfigInfo:
"""Configuration Info for Yamaha Receivers."""
def __init__(self, config: None, discovery_info: None):
def __init__(self, config: None, discovery_info: None) -> None:
"""Initialize the Configuration Info for Yamaha Receiver."""
self.name = config.get(CONF_NAME)
self.host = config.get(CONF_HOST)

View File

@ -316,7 +316,7 @@ class YeelightScanner:
cls._scanner = cls(hass)
return cls._scanner
def __init__(self, hass: HomeAssistant):
def __init__(self, hass: HomeAssistant) -> None:
"""Initialize class."""
self._hass = hass
self._seen = {}
@ -573,7 +573,7 @@ class YeelightDevice:
class YeelightEntity(Entity):
"""Represents single Yeelight entity."""
def __init__(self, device: YeelightDevice, entry: ConfigEntry):
def __init__(self, device: YeelightDevice, entry: ConfigEntry) -> None:
"""Initialize the entity."""
self._device = device
self._unique_id = entry.entry_id

View File

@ -176,7 +176,7 @@ class Channels:
class ChannelPool:
"""All channels of an endpoint."""
def __init__(self, channels: Channels, ep_id: int):
def __init__(self, channels: Channels, ep_id: int) -> None:
"""Initialize instance."""
self._all_channels: ChannelsDict = {}
self._channels: Channels = channels

View File

@ -258,7 +258,7 @@ class RadioType(enum.Enum):
return radio.name
raise ValueError
def __init__(self, description: str, controller_cls: CALLABLE_T):
def __init__(self, description: str, controller_cls: CALLABLE_T) -> None:
"""Init instance."""
self._desc = description
self._ctrl_cls = controller_cls

View File

@ -91,7 +91,7 @@ class ZHADevice(LogMixin):
hass: HomeAssistant,
zigpy_device: zha_typing.ZigpyDeviceType,
zha_gateway: zha_typing.ZhaGatewayType,
):
) -> None:
"""Initialize the gateway."""
self.hass = hass
self._zigpy_device = zigpy_device

View File

@ -33,7 +33,7 @@ class ZHAGroupMember(LogMixin):
def __init__(
self, zha_group: ZhaGroupType, zha_device: ZhaDeviceType, endpoint_id: int
):
) -> None:
"""Initialize the group member."""
self._zha_group: ZhaGroupType = zha_group
self._zha_device: ZhaDeviceType = zha_device
@ -116,7 +116,7 @@ class ZHAGroup(LogMixin):
hass: HomeAssistant,
zha_gateway: ZhaGatewayType,
zigpy_group: ZigpyGroupType,
):
) -> None:
"""Initialize the group."""
self.hass: HomeAssistant = hass
self._zigpy_group: ZigpyGroupType = zigpy_group

View File

@ -183,7 +183,7 @@ class Shade(ZhaEntity, CoverEntity):
zha_device: ZhaDeviceType,
channels: list[ChannelType],
**kwargs,
):
) -> None:
"""Initialize the ZHA light."""
super().__init__(unique_id, zha_device, channels, **kwargs)
self._on_off_channel = self.cluster_channels[CHANNEL_ON_OFF]

View File

@ -40,7 +40,7 @@ UPDATE_GROUP_FROM_CHILD_DELAY = 0.2
class BaseZhaEntity(LogMixin, entity.Entity):
"""A base class for ZHA entities."""
def __init__(self, unique_id: str, zha_device: ZhaDeviceType, **kwargs):
def __init__(self, unique_id: str, zha_device: ZhaDeviceType, **kwargs) -> None:
"""Init ZHA entity."""
self._name: str = ""
self._force_update: bool = False
@ -147,7 +147,7 @@ class ZhaEntity(BaseZhaEntity, RestoreEntity):
zha_device: ZhaDeviceType,
channels: list[ChannelType],
**kwargs,
):
) -> None:
"""Init ZHA entity."""
super().__init__(unique_id, zha_device, **kwargs)
ieeetail = "".join([f"{o:02x}" for o in zha_device.ieee[:4]])

View File

@ -109,7 +109,7 @@ class Sensor(ZhaEntity, SensorEntity):
zha_device: ZhaDeviceType,
channels: list[ChannelType],
**kwargs,
):
) -> None:
"""Init this sensor."""
super().__init__(unique_id, zha_device, channels, **kwargs)
self._channel: ChannelType = channels[0]

View File

@ -279,7 +279,7 @@ async def async_unload_entry(
class Zone(entity.Entity):
"""Representation of a Zone."""
def __init__(self, config: dict):
def __init__(self, config: dict) -> None:
"""Initialize the zone."""
self._config = config
self.editable = True

View File

@ -55,7 +55,7 @@ BITMASK_SCHEMA = vol.All(
class ZWaveServices:
"""Class that holds our services (Zwave Commands) that should be published to hass."""
def __init__(self, hass: HomeAssistant, ent_reg: EntityRegistry):
def __init__(self, hass: HomeAssistant, ent_reg: EntityRegistry) -> None:
"""Initialize with hass object."""
self._hass = hass
self._ent_reg = ent_reg