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