Type check various base components (#25878)
* Type check various component base classes, disabling bunch of checks for now * Type hint fixes * Help mypy out some * Add more type hints
This commit is contained in:
parent
cf90e49b50
commit
b738082dad
59 changed files with 233 additions and 34 deletions
|
@ -7,6 +7,7 @@ from typing import ( # noqa: F401
|
||||||
Dict,
|
Dict,
|
||||||
List,
|
List,
|
||||||
Mapping,
|
Mapping,
|
||||||
|
Optional,
|
||||||
Set,
|
Set,
|
||||||
Tuple,
|
Tuple,
|
||||||
Union,
|
Union,
|
||||||
|
@ -31,7 +32,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
class AbstractPermissions:
|
class AbstractPermissions:
|
||||||
"""Default permissions class."""
|
"""Default permissions class."""
|
||||||
|
|
||||||
_cached_entity_func = None
|
_cached_entity_func: Optional[Callable[[str, str], bool]] = None
|
||||||
|
|
||||||
def _entity_func(self) -> Callable[[str, str], bool]:
|
def _entity_func(self) -> Callable[[str, str], bool]:
|
||||||
"""Return a function that can test entity access."""
|
"""Return a function that can test entity access."""
|
||||||
|
|
|
@ -11,6 +11,9 @@ import logging
|
||||||
|
|
||||||
from homeassistant.core import split_entity_id
|
from homeassistant.core import split_entity_id
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,10 @@ from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
from homeassistant.loader import bind_hass
|
from homeassistant.loader import bind_hass
|
||||||
from homeassistant.util.dt import parse_datetime, utcnow
|
from homeassistant.util.dt import parse_datetime, utcnow
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-incomplete-defs, allow-untyped-calls, allow-untyped-defs
|
||||||
|
# mypy: no-check-untyped-defs, no-warn-return-any
|
||||||
|
|
||||||
DOMAIN = "automation"
|
DOMAIN = "automation"
|
||||||
ENTITY_ID_FORMAT = DOMAIN + ".{}"
|
ENTITY_ID_FORMAT = DOMAIN + ".{}"
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ from homeassistant.const import CONF_DOMAIN, CONF_PLATFORM
|
||||||
from homeassistant.loader import async_get_integration
|
from homeassistant.loader import async_get_integration
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
TRIGGER_SCHEMA = vol.Schema(
|
TRIGGER_SCHEMA = vol.Schema(
|
||||||
{vol.Required(CONF_PLATFORM): "device", vol.Required(CONF_DOMAIN): str},
|
{vol.Required(CONF_PLATFORM): "device", vol.Required(CONF_DOMAIN): str},
|
||||||
extra=vol.ALLOW_EXTRA,
|
extra=vol.ALLOW_EXTRA,
|
||||||
|
|
|
@ -7,6 +7,9 @@ from homeassistant.core import callback
|
||||||
from homeassistant.const import CONF_PLATFORM
|
from homeassistant.const import CONF_PLATFORM
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs
|
||||||
|
|
||||||
CONF_EVENT_TYPE = "event_type"
|
CONF_EVENT_TYPE = "event_type"
|
||||||
CONF_EVENT_DATA = "event_data"
|
CONF_EVENT_DATA = "event_data"
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@ from homeassistant.const import (
|
||||||
from homeassistant.helpers import condition, config_validation as cv
|
from homeassistant.helpers import condition, config_validation as cv
|
||||||
from homeassistant.helpers.config_validation import entity_domain
|
from homeassistant.helpers.config_validation import entity_domain
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
EVENT_ENTER = "enter"
|
EVENT_ENTER = "enter"
|
||||||
EVENT_LEAVE = "leave"
|
EVENT_LEAVE = "leave"
|
||||||
DEFAULT_EVENT = EVENT_ENTER
|
DEFAULT_EVENT = EVENT_ENTER
|
||||||
|
|
|
@ -6,6 +6,9 @@ import voluptuous as vol
|
||||||
from homeassistant.core import callback, CoreState
|
from homeassistant.core import callback, CoreState
|
||||||
from homeassistant.const import CONF_PLATFORM, CONF_EVENT, EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import CONF_PLATFORM, CONF_EVENT, EVENT_HOMEASSISTANT_STOP
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs
|
||||||
|
|
||||||
EVENT_START = "start"
|
EVENT_START = "start"
|
||||||
EVENT_SHUTDOWN = "shutdown"
|
EVENT_SHUTDOWN = "shutdown"
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
|
@ -9,6 +9,9 @@ import homeassistant.helpers.config_validation as cv
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
from homeassistant.helpers.event import track_point_in_utc_time
|
from homeassistant.helpers.event import track_point_in_utc_time
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
CONF_NUMBER = "number"
|
CONF_NUMBER = "number"
|
||||||
|
|
|
@ -8,6 +8,9 @@ from homeassistant.components import mqtt
|
||||||
from homeassistant.const import CONF_PLATFORM, CONF_PAYLOAD
|
from homeassistant.const import CONF_PLATFORM, CONF_PAYLOAD
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs
|
||||||
|
|
||||||
CONF_ENCODING = "encoding"
|
CONF_ENCODING = "encoding"
|
||||||
CONF_TOPIC = "topic"
|
CONF_TOPIC = "topic"
|
||||||
DEFAULT_ENCODING = "utf-8"
|
DEFAULT_ENCODING = "utf-8"
|
||||||
|
|
|
@ -16,6 +16,9 @@ from homeassistant.const import (
|
||||||
from homeassistant.helpers.event import async_track_state_change, async_track_same_state
|
from homeassistant.helpers.event import async_track_state_change, async_track_same_state
|
||||||
from homeassistant.helpers import condition, config_validation as cv, template
|
from homeassistant.helpers import condition, config_validation as cv, template
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
TRIGGER_SCHEMA = vol.All(
|
TRIGGER_SCHEMA = vol.All(
|
||||||
vol.Schema(
|
vol.Schema(
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,9 @@ from homeassistant.const import MATCH_ALL, CONF_PLATFORM, CONF_FOR
|
||||||
from homeassistant.helpers import config_validation as cv, template
|
from homeassistant.helpers import config_validation as cv, template
|
||||||
from homeassistant.helpers.event import async_track_state_change, async_track_same_state
|
from homeassistant.helpers.event import async_track_state_change, async_track_same_state
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
CONF_ENTITY_ID = "entity_id"
|
CONF_ENTITY_ID = "entity_id"
|
||||||
|
|
|
@ -14,6 +14,9 @@ from homeassistant.const import (
|
||||||
from homeassistant.helpers.event import async_track_sunrise, async_track_sunset
|
from homeassistant.helpers.event import async_track_sunrise, async_track_sunset
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
TRIGGER_SCHEMA = vol.Schema(
|
TRIGGER_SCHEMA = vol.Schema(
|
||||||
|
|
|
@ -10,6 +10,9 @@ from homeassistant.helpers import condition
|
||||||
from homeassistant.helpers.event import async_track_same_state, async_track_template
|
from homeassistant.helpers.event import async_track_same_state, async_track_template
|
||||||
from homeassistant.helpers import config_validation as cv, template
|
from homeassistant.helpers import config_validation as cv, template
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
TRIGGER_SCHEMA = IF_ACTION_SCHEMA = vol.Schema(
|
TRIGGER_SCHEMA = IF_ACTION_SCHEMA = vol.Schema(
|
||||||
|
|
|
@ -8,6 +8,9 @@ from homeassistant.const import CONF_AT, CONF_PLATFORM
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.event import async_track_time_change
|
from homeassistant.helpers.event import async_track_time_change
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
TRIGGER_SCHEMA = vol.Schema(
|
TRIGGER_SCHEMA = vol.Schema(
|
||||||
|
|
|
@ -8,6 +8,9 @@ from homeassistant.const import CONF_PLATFORM
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.event import async_track_time_change
|
from homeassistant.helpers.event import async_track_time_change
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
CONF_HOURS = "hours"
|
CONF_HOURS = "hours"
|
||||||
CONF_MINUTES = "minutes"
|
CONF_MINUTES = "minutes"
|
||||||
CONF_SECONDS = "seconds"
|
CONF_SECONDS = "seconds"
|
||||||
|
|
|
@ -11,6 +11,9 @@ import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
from . import DOMAIN as AUTOMATION_DOMAIN
|
from . import DOMAIN as AUTOMATION_DOMAIN
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs
|
||||||
|
|
||||||
DEPENDENCIES = ("webhook",)
|
DEPENDENCIES = ("webhook",)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
|
@ -12,6 +12,9 @@ from homeassistant.const import (
|
||||||
from homeassistant.helpers.event import async_track_state_change
|
from homeassistant.helpers.event import async_track_state_change
|
||||||
from homeassistant.helpers import condition, config_validation as cv, location
|
from homeassistant.helpers import condition, config_validation as cv, location
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
EVENT_ENTER = "enter"
|
EVENT_ENTER = "enter"
|
||||||
EVENT_LEAVE = "leave"
|
EVENT_LEAVE = "leave"
|
||||||
DEFAULT_EVENT = EVENT_ENTER
|
DEFAULT_EVENT = EVENT_ENTER
|
||||||
|
|
|
@ -13,6 +13,9 @@ from homeassistant.helpers.config_validation import ( # noqa
|
||||||
PLATFORM_SCHEMA_BASE,
|
PLATFORM_SCHEMA_BASE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
DOMAIN = "binary_sensor"
|
DOMAIN = "binary_sensor"
|
||||||
SCAN_INTERVAL = timedelta(seconds=30)
|
SCAN_INTERVAL = timedelta(seconds=30)
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,9 @@ from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.template import DATE_STR_FORMAT
|
from homeassistant.helpers.template import DATE_STR_FORMAT
|
||||||
from homeassistant.util import dt
|
from homeassistant.util import dt
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DOMAIN = "calendar"
|
DOMAIN = "calendar"
|
||||||
|
|
|
@ -7,6 +7,7 @@ from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
import hashlib
|
import hashlib
|
||||||
from random import SystemRandom
|
from random import SystemRandom
|
||||||
|
from typing import Deque
|
||||||
|
|
||||||
import attr
|
import attr
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
@ -52,6 +53,9 @@ from homeassistant.setup import async_when_setup
|
||||||
from .const import DOMAIN, DATA_CAMERA_PREFS
|
from .const import DOMAIN, DATA_CAMERA_PREFS
|
||||||
from .prefs import CameraPreferences
|
from .prefs import CameraPreferences
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-calls, allow-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
SERVICE_ENABLE_MOTION = "enable_motion_detection"
|
SERVICE_ENABLE_MOTION = "enable_motion_detection"
|
||||||
|
@ -311,7 +315,7 @@ class Camera(Entity):
|
||||||
"""Initialize a camera."""
|
"""Initialize a camera."""
|
||||||
self.is_streaming = False
|
self.is_streaming = False
|
||||||
self.content_type = DEFAULT_CONTENT_TYPE
|
self.content_type = DEFAULT_CONTENT_TYPE
|
||||||
self.access_tokens = collections.deque([], 2)
|
self.access_tokens: Deque[str] = collections.deque([], 2)
|
||||||
self.async_update_token()
|
self.async_update_token()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
"""Preference management for camera component."""
|
"""Preference management for camera component."""
|
||||||
from .const import DOMAIN, PREF_PRELOAD_STREAM
|
from .const import DOMAIN, PREF_PRELOAD_STREAM
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
STORAGE_KEY = DOMAIN
|
STORAGE_KEY = DOMAIN
|
||||||
STORAGE_VERSION = 1
|
STORAGE_VERSION = 1
|
||||||
_UNDEF = object()
|
_UNDEF = object()
|
||||||
|
|
|
@ -32,6 +32,9 @@ from homeassistant.const import (
|
||||||
STATE_CLOSING,
|
STATE_CLOSING,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-calls, allow-incomplete-defs, allow-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DOMAIN = "cover"
|
DOMAIN = "cover"
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import functools as ft
|
import functools as ft
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ FAN_SET_DIRECTION_SCHEMA = ENTITY_SERVICE_SCHEMA.extend(
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
@bind_hass
|
||||||
def is_on(hass, entity_id: str = None) -> bool:
|
def is_on(hass, entity_id: Optional[str] = None) -> bool:
|
||||||
"""Return if the fans are on based on the statemachine."""
|
"""Return if the fans are on based on the statemachine."""
|
||||||
entity_id = entity_id or ENTITY_ID_ALL_FANS
|
entity_id = entity_id or ENTITY_ID_ALL_FANS
|
||||||
state = hass.states.get(entity_id)
|
state = hass.states.get(entity_id)
|
||||||
|
@ -149,12 +150,12 @@ class FanEntity(ToggleEntity):
|
||||||
return self.hass.async_add_job(self.set_direction, direction)
|
return self.hass.async_add_job(self.set_direction, direction)
|
||||||
|
|
||||||
# pylint: disable=arguments-differ
|
# pylint: disable=arguments-differ
|
||||||
def turn_on(self, speed: str = None, **kwargs) -> None:
|
def turn_on(self, speed: Optional[str] = None, **kwargs) -> None:
|
||||||
"""Turn on the fan."""
|
"""Turn on the fan."""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
# pylint: disable=arguments-differ
|
# pylint: disable=arguments-differ
|
||||||
def async_turn_on(self, speed: str = None, **kwargs):
|
def async_turn_on(self, speed: Optional[str] = None, **kwargs):
|
||||||
"""Turn on the fan.
|
"""Turn on the fan.
|
||||||
|
|
||||||
This method must be run in the event loop and returns a coroutine.
|
This method must be run in the event loop and returns a coroutine.
|
||||||
|
@ -180,7 +181,7 @@ class FanEntity(ToggleEntity):
|
||||||
return self.speed not in [SPEED_OFF, None]
|
return self.speed not in [SPEED_OFF, None]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def speed(self) -> str:
|
def speed(self) -> Optional[str]:
|
||||||
"""Return the current speed."""
|
"""Return the current speed."""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -190,7 +191,7 @@ class FanEntity(ToggleEntity):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_direction(self) -> str:
|
def current_direction(self) -> Optional[str]:
|
||||||
"""Return the current direction of the fan."""
|
"""Return the current direction of the fan."""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@ from homeassistant.loader import bind_hass
|
||||||
from .storage import async_setup_frontend_storage
|
from .storage import async_setup_frontend_storage
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-incomplete-defs, allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
# Fix mimetypes for borked Windows machines
|
# Fix mimetypes for borked Windows machines
|
||||||
# https://github.com/home-assistant/home-assistant-polymer/issues/3336
|
# https://github.com/home-assistant/home-assistant-polymer/issues/3336
|
||||||
mimetypes.add_type("text/css", ".css")
|
mimetypes.add_type("text/css", ".css")
|
||||||
|
@ -45,7 +47,14 @@ MANIFEST_JSON = {
|
||||||
"description": "Home automation platform that puts local control and privacy first.",
|
"description": "Home automation platform that puts local control and privacy first.",
|
||||||
"dir": "ltr",
|
"dir": "ltr",
|
||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
"icons": [],
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "/static/icons/favicon-{size}x{size}.png".format(size=size),
|
||||||
|
"sizes": "{size}x{size}".format(size=size),
|
||||||
|
"type": "image/png",
|
||||||
|
}
|
||||||
|
for size in (192, 384, 512, 1024)
|
||||||
|
],
|
||||||
"lang": "en-US",
|
"lang": "en-US",
|
||||||
"name": "Home Assistant",
|
"name": "Home Assistant",
|
||||||
"short_name": "Assistant",
|
"short_name": "Assistant",
|
||||||
|
@ -53,15 +62,6 @@ MANIFEST_JSON = {
|
||||||
"theme_color": DEFAULT_THEME_COLOR,
|
"theme_color": DEFAULT_THEME_COLOR,
|
||||||
}
|
}
|
||||||
|
|
||||||
for size in (192, 384, 512, 1024):
|
|
||||||
MANIFEST_JSON["icons"].append(
|
|
||||||
{
|
|
||||||
"src": "/static/icons/favicon-{size}x{size}.png".format(size=size),
|
|
||||||
"sizes": "{size}x{size}".format(size=size),
|
|
||||||
"type": "image/png",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
DATA_PANELS = "frontend_panels"
|
DATA_PANELS = "frontend_panels"
|
||||||
DATA_JS_VERSION = "frontend_js_version"
|
DATA_JS_VERSION = "frontend_js_version"
|
||||||
DATA_EXTRA_HTML_URL = "frontend_extra_html_url"
|
DATA_EXTRA_HTML_URL = "frontend_extra_html_url"
|
||||||
|
|
|
@ -4,6 +4,9 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import websocket_api
|
from homeassistant.components import websocket_api
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-calls, allow-untyped-defs
|
||||||
|
|
||||||
DATA_STORAGE = "frontend_storage"
|
DATA_STORAGE = "frontend_storage"
|
||||||
STORAGE_VERSION_USER_DATA = 1
|
STORAGE_VERSION_USER_DATA = 1
|
||||||
STORAGE_KEY_USER_DATA = "frontend.user_data_{}"
|
STORAGE_KEY_USER_DATA = "frontend.user_data_{}"
|
||||||
|
|
|
@ -11,6 +11,9 @@ from homeassistant.helpers.config_validation import ( # noqa
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ATTR_DISTANCE = "distance"
|
ATTR_DISTANCE = "distance"
|
||||||
|
|
|
@ -21,6 +21,9 @@ from homeassistant.const import ATTR_HIDDEN
|
||||||
from homeassistant.components.recorder.util import session_scope, execute
|
from homeassistant.components.recorder.util import session_scope, execute
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DOMAIN = "history"
|
DOMAIN = "history"
|
||||||
|
|
|
@ -27,6 +27,9 @@ from .real_ip import setup_real_ip
|
||||||
from .static import CACHE_HEADERS, CachingStaticResource
|
from .static import CACHE_HEADERS, CachingStaticResource
|
||||||
from .view import HomeAssistantView # noqa
|
from .view import HomeAssistantView # noqa
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
DOMAIN = "http"
|
DOMAIN = "http"
|
||||||
|
|
||||||
CONF_API_PASSWORD = "api_password"
|
CONF_API_PASSWORD = "api_password"
|
||||||
|
|
|
@ -14,6 +14,9 @@ from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
from .const import KEY_AUTHENTICATED, KEY_HASS_USER, KEY_REAL_IP
|
from .const import KEY_AUTHENTICATED, KEY_HASS_USER, KEY_REAL_IP
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DATA_API_PASSWORD = "api_password"
|
DATA_API_PASSWORD = "api_password"
|
||||||
|
|
|
@ -3,6 +3,7 @@ from collections import defaultdict
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from ipaddress import ip_address
|
from ipaddress import ip_address
|
||||||
import logging
|
import logging
|
||||||
|
from typing import List, Optional
|
||||||
|
|
||||||
from aiohttp.web import middleware
|
from aiohttp.web import middleware
|
||||||
from aiohttp.web_exceptions import HTTPForbidden, HTTPUnauthorized
|
from aiohttp.web_exceptions import HTTPForbidden, HTTPUnauthorized
|
||||||
|
@ -16,6 +17,9 @@ from homeassistant.util.yaml import dump
|
||||||
|
|
||||||
from .const import KEY_REAL_IP
|
from .const import KEY_REAL_IP
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-incomplete-defs, allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
KEY_BANNED_IPS = "ha_banned_ips"
|
KEY_BANNED_IPS = "ha_banned_ips"
|
||||||
|
@ -155,7 +159,7 @@ async def process_success_login(request):
|
||||||
class IpBan:
|
class IpBan:
|
||||||
"""Represents banned IP address."""
|
"""Represents banned IP address."""
|
||||||
|
|
||||||
def __init__(self, ip_ban: str, banned_at: datetime = None) -> None:
|
def __init__(self, ip_ban: str, banned_at: Optional[datetime] = None) -> None:
|
||||||
"""Initialize IP Ban object."""
|
"""Initialize IP Ban object."""
|
||||||
self.ip_address = ip_address(ip_ban)
|
self.ip_address = ip_address(ip_ban)
|
||||||
self.banned_at = banned_at or datetime.utcnow()
|
self.banned_at = banned_at or datetime.utcnow()
|
||||||
|
@ -163,7 +167,7 @@ class IpBan:
|
||||||
|
|
||||||
async def async_load_ip_bans_config(hass: HomeAssistant, path: str):
|
async def async_load_ip_bans_config(hass: HomeAssistant, path: str):
|
||||||
"""Load list of banned IPs from config file."""
|
"""Load list of banned IPs from config file."""
|
||||||
ip_list = []
|
ip_list: List[IpBan] = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
list_ = await hass.async_add_executor_job(load_yaml_config_file, path)
|
list_ = await hass.async_add_executor_job(load_yaml_config_file, path)
|
||||||
|
|
|
@ -5,6 +5,9 @@ from aiohttp.hdrs import ACCEPT, CONTENT_TYPE, ORIGIN, AUTHORIZATION
|
||||||
from homeassistant.const import HTTP_HEADER_HA_AUTH, HTTP_HEADER_X_REQUESTED_WITH
|
from homeassistant.const import HTTP_HEADER_HA_AUTH, HTTP_HEADER_X_REQUESTED_WITH
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
ALLOWED_CORS_HEADERS = [
|
ALLOWED_CORS_HEADERS = [
|
||||||
ORIGIN,
|
ORIGIN,
|
||||||
ACCEPT,
|
ACCEPT,
|
||||||
|
|
|
@ -4,6 +4,9 @@ import logging
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,9 @@ from homeassistant.core import callback
|
||||||
from .const import KEY_REAL_IP
|
from .const import KEY_REAL_IP
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs
|
||||||
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def setup_real_ip(app, use_x_forwarded_for, trusted_proxies):
|
def setup_real_ip(app, use_x_forwarded_for, trusted_proxies):
|
||||||
"""Create IP Ban middleware for the app."""
|
"""Create IP Ban middleware for the app."""
|
||||||
|
|
|
@ -6,6 +6,9 @@ from aiohttp.web import FileResponse
|
||||||
from aiohttp.web_exceptions import HTTPNotFound, HTTPForbidden
|
from aiohttp.web_exceptions import HTTPNotFound, HTTPForbidden
|
||||||
from aiohttp.web_urldispatcher import StaticResource
|
from aiohttp.web_urldispatcher import StaticResource
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs
|
||||||
|
|
||||||
CACHE_TIME = 31 * 86400 # = 1 month
|
CACHE_TIME = 31 * 86400 # = 1 month
|
||||||
CACHE_HEADERS = {hdrs.CACHE_CONTROL: "public, max-age={}".format(CACHE_TIME)}
|
CACHE_HEADERS = {hdrs.CACHE_CONTROL: "public, max-age={}".format(CACHE_TIME)}
|
||||||
|
|
||||||
|
@ -39,7 +42,8 @@ class CachingStaticResource(StaticResource):
|
||||||
if filepath.is_dir():
|
if filepath.is_dir():
|
||||||
return await super()._handle(request)
|
return await super()._handle(request)
|
||||||
if filepath.is_file():
|
if filepath.is_file():
|
||||||
return FileResponse(
|
# type ignore: https://github.com/aio-libs/aiohttp/pull/3976
|
||||||
|
return FileResponse( # type: ignore
|
||||||
filepath, chunk_size=self._chunk_size, headers=CACHE_HEADERS
|
filepath, chunk_size=self._chunk_size, headers=CACHE_HEADERS
|
||||||
)
|
)
|
||||||
raise HTTPNotFound
|
raise HTTPNotFound
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
from typing import List, Optional
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
from aiohttp.web_exceptions import (
|
from aiohttp.web_exceptions import (
|
||||||
|
@ -22,11 +23,14 @@ from .const import KEY_AUTHENTICATED, KEY_HASS, KEY_REAL_IP
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
|
|
||||||
class HomeAssistantView:
|
class HomeAssistantView:
|
||||||
"""Base view for all views."""
|
"""Base view for all views."""
|
||||||
|
|
||||||
url = None
|
url: Optional[str] = None
|
||||||
extra_urls = []
|
extra_urls: List[str] = []
|
||||||
# Views inheriting from this class can override this
|
# Views inheriting from this class can override this
|
||||||
requires_auth = True
|
requires_auth = True
|
||||||
cors_allowed = False
|
cors_allowed = False
|
||||||
|
|
|
@ -14,6 +14,9 @@ from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.util.async_ import run_callback_threadsafe
|
from homeassistant.util.async_ import run_callback_threadsafe
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DOMAIN = "image_processing"
|
DOMAIN = "image_processing"
|
||||||
|
|
|
@ -16,6 +16,9 @@ from homeassistant.core import callback
|
||||||
from homeassistant.helpers.event import async_track_state_change
|
from homeassistant.helpers.event import async_track_state_change
|
||||||
from homeassistant.helpers.restore_state import RestoreEntity
|
from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ATTR_SOURCE_ID = "source"
|
ATTR_SOURCE_ID = "source"
|
||||||
|
|
|
@ -4,6 +4,7 @@ import csv
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
from typing import Dict, Optional, Tuple
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
@ -29,6 +30,9 @@ from homeassistant.helpers import intent
|
||||||
from homeassistant.loader import bind_hass
|
from homeassistant.loader import bind_hass
|
||||||
import homeassistant.util.color as color_util
|
import homeassistant.util.color as color_util
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
DOMAIN = "light"
|
DOMAIN = "light"
|
||||||
SCAN_INTERVAL = timedelta(seconds=30)
|
SCAN_INTERVAL = timedelta(seconds=30)
|
||||||
|
|
||||||
|
@ -344,7 +348,7 @@ async def async_unload_entry(hass, entry):
|
||||||
class Profiles:
|
class Profiles:
|
||||||
"""Representation of available color profiles."""
|
"""Representation of available color profiles."""
|
||||||
|
|
||||||
_all = None
|
_all: Optional[Dict[str, Tuple[float, float, int]]] = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def load_profiles(cls, hass):
|
async def load_profiles(cls, hass):
|
||||||
|
|
|
@ -14,6 +14,9 @@ import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity_registry import async_entries_for_device
|
from homeassistant.helpers.entity_registry import async_entries_for_device
|
||||||
from . import DOMAIN
|
from . import DOMAIN
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
CONF_TURN_OFF = "turn_off"
|
CONF_TURN_OFF = "turn_off"
|
||||||
CONF_TURN_ON = "turn_on"
|
CONF_TURN_ON = "turn_on"
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,9 @@ from homeassistant.const import (
|
||||||
)
|
)
|
||||||
from homeassistant.components import group
|
from homeassistant.components import group
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
ATTR_CHANGED_BY = "changed_by"
|
ATTR_CHANGED_BY = "changed_by"
|
||||||
|
|
||||||
DOMAIN = "lock"
|
DOMAIN = "lock"
|
||||||
|
|
|
@ -16,6 +16,9 @@ from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.setup import async_prepare_setup_platform
|
from homeassistant.setup import async_prepare_setup_platform
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DOMAIN = "mailbox"
|
DOMAIN = "mailbox"
|
||||||
|
|
|
@ -97,6 +97,9 @@ from .const import (
|
||||||
SUPPORT_VOLUME_STEP,
|
SUPPORT_VOLUME_STEP,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
_RND = SystemRandom()
|
_RND = SystemRandom()
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,9 @@ from .const import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-incomplete-defs, allow-untyped-defs
|
||||||
|
|
||||||
|
|
||||||
async def _async_reproduce_states(
|
async def _async_reproduce_states(
|
||||||
hass: HomeAssistantType, state: State, context: Optional[Context] = None
|
hass: HomeAssistantType, state: State, context: Optional[Context] = None
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
|
@ -416,7 +416,7 @@ async def async_subscribe(
|
||||||
topic: str,
|
topic: str,
|
||||||
msg_callback: MessageCallbackType,
|
msg_callback: MessageCallbackType,
|
||||||
qos: int = DEFAULT_QOS,
|
qos: int = DEFAULT_QOS,
|
||||||
encoding: str = "utf-8",
|
encoding: Optional[str] = "utf-8",
|
||||||
):
|
):
|
||||||
"""Subscribe to an MQTT topic.
|
"""Subscribe to an MQTT topic.
|
||||||
|
|
||||||
|
@ -829,7 +829,11 @@ class MQTT:
|
||||||
return self.hass.async_add_job(stop)
|
return self.hass.async_add_job(stop)
|
||||||
|
|
||||||
async def async_subscribe(
|
async def async_subscribe(
|
||||||
self, topic: str, msg_callback: MessageCallbackType, qos: int, encoding: str
|
self,
|
||||||
|
topic: str,
|
||||||
|
msg_callback: MessageCallbackType,
|
||||||
|
qos: int,
|
||||||
|
encoding: Optional[str] = None,
|
||||||
) -> Callable[[], None]:
|
) -> Callable[[], None]:
|
||||||
"""Set up a subscription to a topic with the provided qos.
|
"""Set up a subscription to a topic with the provided qos.
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
@ -10,8 +11,12 @@ from homeassistant.exceptions import HomeAssistantError
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.const import CONF_NAME, CONF_PLATFORM
|
from homeassistant.const import CONF_NAME, CONF_PLATFORM
|
||||||
from homeassistant.helpers import config_per_platform, discovery
|
from homeassistant.helpers import config_per_platform, discovery
|
||||||
|
from homeassistant.helpers.typing import HomeAssistantType
|
||||||
from homeassistant.util import slugify
|
from homeassistant.util import slugify
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Platform specific data
|
# Platform specific data
|
||||||
|
@ -164,7 +169,7 @@ async def async_setup(hass, config):
|
||||||
class BaseNotificationService:
|
class BaseNotificationService:
|
||||||
"""An abstract class for notification services."""
|
"""An abstract class for notification services."""
|
||||||
|
|
||||||
hass = None
|
hass: Optional[HomeAssistantType] = None
|
||||||
|
|
||||||
def send_message(self, message, **kwargs):
|
def send_message(self, message, **kwargs):
|
||||||
"""Send a message.
|
"""Send a message.
|
||||||
|
|
|
@ -10,6 +10,9 @@ from homeassistant.helpers.event import track_state_change
|
||||||
from homeassistant.util.distance import convert
|
from homeassistant.util.distance import convert
|
||||||
from homeassistant.util.location import distance
|
from homeassistant.util.location import distance
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ATTR_DIR_OF_TRAVEL = "dir_of_travel"
|
ATTR_DIR_OF_TRAVEL = "dir_of_travel"
|
||||||
|
|
|
@ -22,6 +22,9 @@ from homeassistant.helpers.config_validation import ( # noqa
|
||||||
PLATFORM_SCHEMA_BASE,
|
PLATFORM_SCHEMA_BASE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ATTR_ACTIVITY = "activity"
|
ATTR_ACTIVITY = "activity"
|
||||||
|
|
|
@ -12,6 +12,9 @@ from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.state import HASS_DOMAIN
|
from homeassistant.helpers.state import HASS_DOMAIN
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
DOMAIN = "scene"
|
DOMAIN = "scene"
|
||||||
STATE = "scening"
|
STATE = "scening"
|
||||||
STATES = "states"
|
STATES = "states"
|
||||||
|
|
|
@ -21,6 +21,9 @@ from homeassistant.helpers.config_validation import ( # noqa
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DOMAIN = "sensor"
|
DOMAIN = "sensor"
|
||||||
|
|
|
@ -20,6 +20,9 @@ from homeassistant.const import (
|
||||||
)
|
)
|
||||||
from homeassistant.components import group
|
from homeassistant.components import group
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
DOMAIN = "switch"
|
DOMAIN = "switch"
|
||||||
SCAN_INTERVAL = timedelta(seconds=30)
|
SCAN_INTERVAL = timedelta(seconds=30)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""Light support for switch entities."""
|
"""Light support for switch entities."""
|
||||||
import logging
|
import logging
|
||||||
|
from typing import cast
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
@ -18,6 +19,9 @@ from homeassistant.helpers.typing import ConfigType, HomeAssistantType
|
||||||
|
|
||||||
from homeassistant.components.light import PLATFORM_SCHEMA, Light
|
from homeassistant.components.light import PLATFORM_SCHEMA, Light
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-incomplete-defs, allow-untyped-calls, allow-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_NAME = "Light Switch"
|
DEFAULT_NAME = "Light Switch"
|
||||||
|
@ -35,7 +39,7 @@ async def async_setup_platform(
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize Light Switch platform."""
|
"""Initialize Light Switch platform."""
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
[LightSwitch(config.get(CONF_NAME), config[CONF_ENTITY_ID])], True
|
[LightSwitch(cast(str, config.get(CONF_NAME)), config[CONF_ENTITY_ID])], True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,9 @@ from homeassistant.helpers.entity import Entity
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
CONF_ARG = "arg"
|
CONF_ARG = "arg"
|
||||||
|
|
|
@ -8,6 +8,7 @@ import logging
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -25,8 +26,12 @@ from homeassistant.core import callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import config_per_platform
|
from homeassistant.helpers import config_per_platform
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.typing import HomeAssistantType
|
||||||
from homeassistant.setup import async_prepare_setup_platform
|
from homeassistant.setup import async_prepare_setup_platform
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ATTR_CACHE = "cache"
|
ATTR_CACHE = "cache"
|
||||||
|
@ -461,8 +466,8 @@ class SpeechManager:
|
||||||
class Provider:
|
class Provider:
|
||||||
"""Represent a single TTS provider."""
|
"""Represent a single TTS provider."""
|
||||||
|
|
||||||
hass = None
|
hass: Optional[HomeAssistantType] = None
|
||||||
name = None
|
name: Optional[str] = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def default_language(self):
|
def default_language(self):
|
||||||
|
|
|
@ -27,6 +27,9 @@ from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.entity import ToggleEntity, Entity
|
from homeassistant.helpers.entity import ToggleEntity, Entity
|
||||||
from homeassistant.helpers.icon import icon_for_battery_level
|
from homeassistant.helpers.icon import icon_for_battery_level
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DOMAIN = "vacuum"
|
DOMAIN = "vacuum"
|
||||||
|
|
|
@ -27,6 +27,9 @@ from homeassistant.const import (
|
||||||
TEMP_FAHRENHEIT,
|
TEMP_FAHRENHEIT,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
DEFAULT_MIN_TEMP = 110
|
DEFAULT_MIN_TEMP = 110
|
||||||
DEFAULT_MAX_TEMP = 140
|
DEFAULT_MAX_TEMP = 140
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,9 @@ from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.temperature import display_temp as show_temp
|
from homeassistant.helpers.temperature import display_temp as show_temp
|
||||||
|
|
||||||
|
|
||||||
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ATTR_CONDITION_CLASS = "condition_class"
|
ATTR_CONDITION_CLASS = "condition_class"
|
||||||
|
|
|
@ -175,11 +175,11 @@ class FlowHandler:
|
||||||
"""Handle the configuration flow of a component."""
|
"""Handle the configuration flow of a component."""
|
||||||
|
|
||||||
# Set by flow manager
|
# Set by flow manager
|
||||||
flow_id = None
|
flow_id: Optional[str] = None
|
||||||
hass = None
|
hass: Optional[HomeAssistant] = None
|
||||||
handler = None
|
handler = None
|
||||||
cur_step = None
|
cur_step: Optional[Dict[str, str]] = None
|
||||||
context = None # type: Optional[Dict]
|
context: Optional[Dict] = None
|
||||||
|
|
||||||
# Set by _async_create_flow callback
|
# Set by _async_create_flow callback
|
||||||
init_step = "init"
|
init_step = "init"
|
||||||
|
|
|
@ -28,7 +28,7 @@ MOCKS = {
|
||||||
} # type: Dict[str, Tuple[str, Callable]]
|
} # type: Dict[str, Tuple[str, Callable]]
|
||||||
SILENCE = ("homeassistant.scripts.check_config.yaml_loader.clear_secret_cache",)
|
SILENCE = ("homeassistant.scripts.check_config.yaml_loader.clear_secret_cache",)
|
||||||
|
|
||||||
PATCHES = {}
|
PATCHES: Dict[str, Any] = {}
|
||||||
|
|
||||||
C_HEAD = "bold"
|
C_HEAD = "bold"
|
||||||
ERROR_STR = "General Errors"
|
ERROR_STR = "General Errors"
|
||||||
|
|
27
mypyrc
27
mypyrc
|
@ -1,5 +1,32 @@
|
||||||
homeassistant/*.py
|
homeassistant/*.py
|
||||||
homeassistant/auth/
|
homeassistant/auth/
|
||||||
|
homeassistant/components/*.py
|
||||||
|
homeassistant/components/automation/
|
||||||
|
homeassistant/components/binary_sensor/
|
||||||
|
homeassistant/components/calendar/
|
||||||
|
homeassistant/components/camera/
|
||||||
|
homeassistant/components/cover/
|
||||||
|
homeassistant/components/frontend/
|
||||||
|
homeassistant/components/geo_location/
|
||||||
|
homeassistant/components/history/
|
||||||
|
homeassistant/components/http/
|
||||||
|
homeassistant/components/image_processing/
|
||||||
|
homeassistant/components/integration/
|
||||||
|
homeassistant/components/light/
|
||||||
|
homeassistant/components/lock/
|
||||||
|
homeassistant/components/mailbox/
|
||||||
|
homeassistant/components/media_player/
|
||||||
|
homeassistant/components/notify/
|
||||||
|
homeassistant/components/proximity/
|
||||||
|
homeassistant/components/remote/
|
||||||
|
homeassistant/components/scene/
|
||||||
|
homeassistant/components/sensor/
|
||||||
|
homeassistant/components/switch/
|
||||||
|
homeassistant/components/systemmonitor/
|
||||||
|
homeassistant/components/tts/
|
||||||
|
homeassistant/components/vacuum/
|
||||||
|
homeassistant/components/water_heater/
|
||||||
|
homeassistant/components/weather/
|
||||||
homeassistant/helpers/
|
homeassistant/helpers/
|
||||||
homeassistant/scripts/
|
homeassistant/scripts/
|
||||||
homeassistant/util/
|
homeassistant/util/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue