mirror of
https://github.com/home-assistant/core.git
synced 2025-06-25 01:21:51 +02:00
Static typing for no_ip integration (#51694)
* no_ip type hints * type import change * change Any to datetime
This commit is contained in:
@ -50,6 +50,7 @@ homeassistant.components.media_player.*
|
||||
homeassistant.components.mysensors.*
|
||||
homeassistant.components.nam.*
|
||||
homeassistant.components.network.*
|
||||
homeassistant.components.no_ip.*
|
||||
homeassistant.components.notify.*
|
||||
homeassistant.components.number.*
|
||||
homeassistant.components.onewire.*
|
||||
|
@ -1,7 +1,7 @@
|
||||
"""Integrate with NO-IP Dynamic DNS service."""
|
||||
import asyncio
|
||||
import base64
|
||||
from datetime import timedelta
|
||||
from datetime import datetime, timedelta
|
||||
import logging
|
||||
|
||||
import aiohttp
|
||||
@ -10,8 +10,10 @@ import async_timeout
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import CONF_DOMAIN, CONF_PASSWORD, CONF_TIMEOUT, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.aiohttp_client import SERVER_SOFTWARE
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -51,7 +53,7 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
)
|
||||
|
||||
|
||||
async def async_setup(hass, config):
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Initialize the NO-IP component."""
|
||||
domain = config[DOMAIN].get(CONF_DOMAIN)
|
||||
user = config[DOMAIN].get(CONF_USERNAME)
|
||||
@ -67,7 +69,7 @@ async def async_setup(hass, config):
|
||||
if not result:
|
||||
return False
|
||||
|
||||
async def update_domain_interval(now):
|
||||
async def update_domain_interval(now: datetime) -> None:
|
||||
"""Update the NO-IP entry."""
|
||||
await _update_no_ip(hass, session, domain, auth_str, timeout)
|
||||
|
||||
@ -76,7 +78,13 @@ async def async_setup(hass, config):
|
||||
return True
|
||||
|
||||
|
||||
async def _update_no_ip(hass, session, domain, auth_str, timeout):
|
||||
async def _update_no_ip(
|
||||
hass: HomeAssistant,
|
||||
session: aiohttp.ClientSession,
|
||||
domain: str,
|
||||
auth_str: bytes,
|
||||
timeout: int,
|
||||
) -> bool:
|
||||
"""Update NO-IP."""
|
||||
url = UPDATE_URL
|
||||
|
||||
|
11
mypy.ini
11
mypy.ini
@ -561,6 +561,17 @@ no_implicit_optional = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.no_ip.*]
|
||||
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.notify.*]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
|
Reference in New Issue
Block a user