mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Add strict typing to LaMetric (#63891)
* Add strict typing to LaMetric
* Forgot about Pylint 🙈
This commit is contained in:
parent
1d9318233d
commit
7a699480d4
@ -100,6 +100,7 @@ homeassistant.components.jellyfin.*
|
||||
homeassistant.components.jewish_calendar.*
|
||||
homeassistant.components.knx.*
|
||||
homeassistant.components.kraken.*
|
||||
homeassistant.components.lametric.*
|
||||
homeassistant.components.lcn.*
|
||||
homeassistant.components.light.*
|
||||
homeassistant.components.local_ip.*
|
||||
|
@ -50,7 +50,7 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
class HassLaMetricManager:
|
||||
"""A class that encapsulated requests to the LaMetric manager."""
|
||||
|
||||
def __init__(self, client_id, client_secret):
|
||||
def __init__(self, client_id: str, client_secret: str) -> None:
|
||||
"""Initialize HassLaMetricManager and connect to LaMetric."""
|
||||
|
||||
_LOGGER.debug("Connecting to LaMetric")
|
||||
|
@ -1,5 +1,8 @@
|
||||
"""Support for LaMetric notifications."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from lmnotify import Model, SimpleFrame, Sound
|
||||
from oauthlib.oauth2 import TokenExpiredError
|
||||
@ -13,9 +16,11 @@ from homeassistant.components.notify import (
|
||||
BaseNotificationService,
|
||||
)
|
||||
from homeassistant.const import CONF_ICON
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
from . import DOMAIN as LAMETRIC_DOMAIN
|
||||
from . import DOMAIN, HassLaMetricManager
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -38,11 +43,14 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
)
|
||||
|
||||
|
||||
def get_service(hass, config, discovery_info=None):
|
||||
def get_service(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> LaMetricNotificationService:
|
||||
"""Get the LaMetric notification service."""
|
||||
hlmn = hass.data.get(LAMETRIC_DOMAIN)
|
||||
return LaMetricNotificationService(
|
||||
hlmn,
|
||||
hass.data[DOMAIN],
|
||||
config[CONF_ICON],
|
||||
config[CONF_LIFETIME] * 1000,
|
||||
config[CONF_CYCLES],
|
||||
@ -55,8 +63,14 @@ class LaMetricNotificationService(BaseNotificationService):
|
||||
"""Implement the notification service for LaMetric."""
|
||||
|
||||
def __init__(
|
||||
self, hasslametricmanager, icon, lifetime, cycles, priority, icon_type
|
||||
):
|
||||
self,
|
||||
hasslametricmanager: HassLaMetricManager,
|
||||
icon: str,
|
||||
lifetime: int,
|
||||
cycles: int,
|
||||
priority: str,
|
||||
icon_type: str,
|
||||
) -> None:
|
||||
"""Initialize the service."""
|
||||
self.hasslametricmanager = hasslametricmanager
|
||||
self._icon = icon
|
||||
@ -64,9 +78,9 @@ class LaMetricNotificationService(BaseNotificationService):
|
||||
self._cycles = cycles
|
||||
self._priority = priority
|
||||
self._icon_type = icon_type
|
||||
self._devices = []
|
||||
self._devices: list[dict[str, Any]] = []
|
||||
|
||||
def send_message(self, message="", **kwargs):
|
||||
def send_message(self, message: str = "", **kwargs: Any) -> None:
|
||||
"""Send a message to some LaMetric device."""
|
||||
|
||||
targets = kwargs.get(ATTR_TARGET)
|
||||
|
11
mypy.ini
11
mypy.ini
@ -912,6 +912,17 @@ no_implicit_optional = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.lametric.*]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
disallow_subclassing_any = true
|
||||
disallow_untyped_calls = true
|
||||
disallow_untyped_decorators = true
|
||||
disallow_untyped_defs = true
|
||||
no_implicit_optional = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.lcn.*]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
|
Loading…
x
Reference in New Issue
Block a user