Enable strict typing for airthings_ble (#106815)
This commit is contained in:
parent
a64f912733
commit
3433e1d349
3 changed files with 14 additions and 3 deletions
|
@ -49,6 +49,7 @@ homeassistant.components.aftership.*
|
||||||
homeassistant.components.air_quality.*
|
homeassistant.components.air_quality.*
|
||||||
homeassistant.components.airly.*
|
homeassistant.components.airly.*
|
||||||
homeassistant.components.airnow.*
|
homeassistant.components.airnow.*
|
||||||
|
homeassistant.components.airthings_ble.*
|
||||||
homeassistant.components.airvisual.*
|
homeassistant.components.airvisual.*
|
||||||
homeassistant.components.airvisual_pro.*
|
homeassistant.components.airvisual_pro.*
|
||||||
homeassistant.components.airzone.*
|
homeassistant.components.airzone.*
|
||||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from airthings_ble import AirthingsBluetoothDeviceData
|
from airthings_ble import AirthingsBluetoothDeviceData, AirthingsDevice
|
||||||
|
|
||||||
from homeassistant.components import bluetooth
|
from homeassistant.components import bluetooth
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
@ -37,13 +37,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
f"Could not find Airthings device with address {address}"
|
f"Could not find Airthings device with address {address}"
|
||||||
)
|
)
|
||||||
|
|
||||||
async def _async_update_method():
|
async def _async_update_method() -> AirthingsDevice:
|
||||||
"""Get data from Airthings BLE."""
|
"""Get data from Airthings BLE."""
|
||||||
ble_device = bluetooth.async_ble_device_from_address(hass, address)
|
ble_device = bluetooth.async_ble_device_from_address(hass, address)
|
||||||
airthings = AirthingsBluetoothDeviceData(_LOGGER, elevation, is_metric)
|
airthings = AirthingsBluetoothDeviceData(_LOGGER, elevation, is_metric)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = await airthings.update_device(ble_device)
|
data = await airthings.update_device(ble_device) # type: ignore[arg-type]
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
raise UpdateFailed(f"Unable to fetch data: {err}") from err
|
raise UpdateFailed(f"Unable to fetch data: {err}") from err
|
||||||
|
|
||||||
|
|
10
mypy.ini
10
mypy.ini
|
@ -250,6 +250,16 @@ disallow_untyped_defs = true
|
||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unreachable = true
|
warn_unreachable = true
|
||||||
|
|
||||||
|
[mypy-homeassistant.components.airthings_ble.*]
|
||||||
|
check_untyped_defs = true
|
||||||
|
disallow_incomplete_defs = true
|
||||||
|
disallow_subclassing_any = true
|
||||||
|
disallow_untyped_calls = true
|
||||||
|
disallow_untyped_decorators = true
|
||||||
|
disallow_untyped_defs = true
|
||||||
|
warn_return_any = true
|
||||||
|
warn_unreachable = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.airvisual.*]
|
[mypy-homeassistant.components.airvisual.*]
|
||||||
check_untyped_defs = true
|
check_untyped_defs = true
|
||||||
disallow_incomplete_defs = true
|
disallow_incomplete_defs = true
|
||||||
|
|
Loading…
Add table
Reference in a new issue