Remove integrations from mypy ignored modules (part 4) (#64435)

Co-authored-by: epenet <epenet@users.noreply.github.com>
pull/64448/head
epenet 2022-01-19 13:29:24 +01:00 committed by GitHub
parent 7520a3fd01
commit edaf75321e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 22 additions and 33 deletions

View File

@ -33,7 +33,6 @@ CONF_ZONE_NAME = "name"
CONF_ZONE_TYPE = "type" CONF_ZONE_TYPE = "type"
CONF_ZONE_ID = "id" CONF_ZONE_ID = "id"
ATTR_OUTPUT_ID = "output_id" ATTR_OUTPUT_ID = "output_id"
DEFAULT_ZONES = []
DEFAULT_SCAN_INTERVAL = datetime.timedelta(minutes=1) DEFAULT_SCAN_INTERVAL = datetime.timedelta(minutes=1)
DEFAULT_INFER_ARMING_STATE = False DEFAULT_INFER_ARMING_STATE = False
@ -62,7 +61,7 @@ CONFIG_SCHEMA = vol.Schema(
vol.Optional( vol.Optional(
CONF_SCAN_INTERVAL, default=DEFAULT_SCAN_INTERVAL CONF_SCAN_INTERVAL, default=DEFAULT_SCAN_INTERVAL
): cv.positive_time_period, ): cv.positive_time_period,
vol.Optional(CONF_ZONES, default=DEFAULT_ZONES): vol.All( vol.Optional(CONF_ZONES, default=[]): vol.All(
cv.ensure_list, [ZONE_SCHEMA] cv.ensure_list, [ZONE_SCHEMA]
), ),
vol.Optional( vol.Optional(

View File

@ -4,6 +4,7 @@ from __future__ import annotations
from asyncio import TimeoutError as AsyncIOTimeoutError from asyncio import TimeoutError as AsyncIOTimeoutError
from datetime import timedelta from datetime import timedelta
import logging import logging
from typing import Any
from aiohttp import ClientError from aiohttp import ClientError
from py_nightscout import Api as NightscoutAPI from py_nightscout import Api as NightscoutAPI
@ -42,7 +43,7 @@ class NightscoutSensor(SensorEntity):
self._unique_id = unique_id self._unique_id = unique_id
self._name = name self._name = name
self._state = None self._state = None
self._attributes = None self._attributes: dict[str, Any] = {}
self._unit_of_measurement = "mg/dL" self._unit_of_measurement = "mg/dL"
self._icon = "mdi:cloud-question" self._icon = "mdi:cloud-question"
self._available = False self._available = False

View File

@ -31,7 +31,9 @@ async def async_setup_entry(
data = hass.data[NUKI_DOMAIN][entry.entry_id] data = hass.data[NUKI_DOMAIN][entry.entry_id]
coordinator = data[DATA_COORDINATOR] coordinator = data[DATA_COORDINATOR]
entities = [NukiLockEntity(coordinator, lock) for lock in data[DATA_LOCKS]] entities: list[NukiDeviceEntity] = [
NukiLockEntity(coordinator, lock) for lock in data[DATA_LOCKS]
]
entities.extend( entities.extend(
[NukiOpenerEntity(coordinator, opener) for opener in data[DATA_OPENERS]] [NukiOpenerEntity(coordinator, opener) for opener in data[DATA_OPENERS]]
) )

View File

@ -4,6 +4,7 @@ from __future__ import annotations
from collections.abc import Awaitable, Callable from collections.abc import Awaitable, Callable
import datetime import datetime
import logging import logging
from typing import TYPE_CHECKING
from pynws import SimpleNWS from pynws import SimpleNWS
@ -69,7 +70,7 @@ class NwsDataUpdateCoordinator(DataUpdateCoordinator):
request_refresh_debouncer=request_refresh_debouncer, request_refresh_debouncer=request_refresh_debouncer,
) )
self.failed_update_interval = failed_update_interval self.failed_update_interval = failed_update_interval
self.last_update_success_time = None self.last_update_success_time: datetime.datetime | None = None
@callback @callback
def _schedule_refresh(self) -> None: def _schedule_refresh(self) -> None:
@ -83,6 +84,9 @@ class NwsDataUpdateCoordinator(DataUpdateCoordinator):
# That way we obtain a constant update frequency, # That way we obtain a constant update frequency,
# as long as the update process takes less than a second # as long as the update process takes less than a second
if self.last_update_success: if self.last_update_success:
if TYPE_CHECKING:
# the base class allows None, but this one doesn't
assert self.update_interval is not None
update_interval = self.update_interval update_interval = self.update_interval
self.last_update_success_time = utcnow() self.last_update_success_time = utcnow()
else: else:

View File

@ -1,4 +1,6 @@
"""Support to help onboard new users.""" """Support to help onboard new users."""
from typing import TYPE_CHECKING
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.storage import Store from homeassistant.helpers.storage import Store
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -54,6 +56,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
if (data := await store.async_load()) is None: if (data := await store.async_load()) is None:
data = {"done": []} data = {"done": []}
if TYPE_CHECKING:
assert isinstance(data, dict)
if STEP_USER not in data["done"]: if STEP_USER not in data["done"]:
# Users can already have created an owner account via the command line # Users can already have created an owner account via the command line
# If so, mark the user step as done. # If so, mark the user step as done.

View File

@ -1,4 +1,6 @@
"""Onboarding views.""" """Onboarding views."""
from __future__ import annotations
import asyncio import asyncio
from http import HTTPStatus from http import HTTPStatus
@ -77,7 +79,7 @@ class InstallationTypeOnboardingView(HomeAssistantView):
class _BaseOnboardingView(HomeAssistantView): class _BaseOnboardingView(HomeAssistantView):
"""Base class for onboarding.""" """Base class for onboarding."""
step = None step: str | None = None
def __init__(self, data, store): def __init__(self, data, store):
"""Initialize the onboarding view.""" """Initialize the onboarding view."""

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from collections.abc import Callable from collections.abc import Callable
from dataclasses import dataclass from dataclasses import dataclass
from datetime import timedelta from datetime import datetime, timedelta
from typing import Final from typing import Final
from ovoenergy import OVODailyUsage from ovoenergy import OVODailyUsage
@ -37,7 +37,7 @@ KEY_LAST_GAS_COST: Final = "last_gas_cost"
class OVOEnergySensorEntityDescription(SensorEntityDescription): class OVOEnergySensorEntityDescription(SensorEntityDescription):
"""Class describing System Bridge sensor entities.""" """Class describing System Bridge sensor entities."""
value: Callable[[OVODailyUsage], StateType] = round value: Callable[[OVODailyUsage], StateType | datetime] = round
SENSOR_TYPES_ELECTRICITY: tuple[OVOEnergySensorEntityDescription, ...] = ( SENSOR_TYPES_ELECTRICITY: tuple[OVOEnergySensorEntityDescription, ...] = (
@ -158,7 +158,7 @@ class OVOEnergySensor(OVOEnergyDeviceEntity, SensorEntity):
self.entity_description = description self.entity_description = description
@property @property
def native_value(self) -> StateType: def native_value(self) -> StateType | datetime:
"""Return the state.""" """Return the state."""
usage: OVODailyUsage = self.coordinator.data usage: OVODailyUsage = self.coordinator.data
return self.entity_description.value(usage) return self.entity_description.value(usage)

View File

@ -2120,42 +2120,24 @@ ignore_errors = true
[mypy-homeassistant.components.mobile_app.*] [mypy-homeassistant.components.mobile_app.*]
ignore_errors = true ignore_errors = true
[mypy-homeassistant.components.ness_alarm.*]
ignore_errors = true
[mypy-homeassistant.components.nest.legacy.*] [mypy-homeassistant.components.nest.legacy.*]
ignore_errors = true ignore_errors = true
[mypy-homeassistant.components.netgear.*] [mypy-homeassistant.components.netgear.*]
ignore_errors = true ignore_errors = true
[mypy-homeassistant.components.nightscout.*]
ignore_errors = true
[mypy-homeassistant.components.nilu.*] [mypy-homeassistant.components.nilu.*]
ignore_errors = true ignore_errors = true
[mypy-homeassistant.components.nuki.*]
ignore_errors = true
[mypy-homeassistant.components.nws.*]
ignore_errors = true
[mypy-homeassistant.components.nzbget.*] [mypy-homeassistant.components.nzbget.*]
ignore_errors = true ignore_errors = true
[mypy-homeassistant.components.omnilogic.*] [mypy-homeassistant.components.omnilogic.*]
ignore_errors = true ignore_errors = true
[mypy-homeassistant.components.onboarding.*]
ignore_errors = true
[mypy-homeassistant.components.onvif.*] [mypy-homeassistant.components.onvif.*]
ignore_errors = true ignore_errors = true
[mypy-homeassistant.components.ovo_energy.*]
ignore_errors = true
[mypy-homeassistant.components.ozw.*] [mypy-homeassistant.components.ozw.*]
ignore_errors = true ignore_errors = true

View File

@ -52,18 +52,12 @@ IGNORED_MODULES: Final[list[str]] = [
"homeassistant.components.meteo_france.*", "homeassistant.components.meteo_france.*",
"homeassistant.components.minecraft_server.*", "homeassistant.components.minecraft_server.*",
"homeassistant.components.mobile_app.*", "homeassistant.components.mobile_app.*",
"homeassistant.components.ness_alarm.*",
"homeassistant.components.nest.legacy.*", "homeassistant.components.nest.legacy.*",
"homeassistant.components.netgear.*", "homeassistant.components.netgear.*",
"homeassistant.components.nightscout.*",
"homeassistant.components.nilu.*", "homeassistant.components.nilu.*",
"homeassistant.components.nuki.*",
"homeassistant.components.nws.*",
"homeassistant.components.nzbget.*", "homeassistant.components.nzbget.*",
"homeassistant.components.omnilogic.*", "homeassistant.components.omnilogic.*",
"homeassistant.components.onboarding.*",
"homeassistant.components.onvif.*", "homeassistant.components.onvif.*",
"homeassistant.components.ovo_energy.*",
"homeassistant.components.ozw.*", "homeassistant.components.ozw.*",
"homeassistant.components.philips_js.*", "homeassistant.components.philips_js.*",
"homeassistant.components.ping.*", "homeassistant.components.ping.*",