From 5c42ebd99f6d391f6239b0e3ae44e84c0c0f0a53 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon, 1 Jan 2024 17:31:51 +0100 Subject: [PATCH] Enable strict typing for airthings_ble --- .strict-typing | 1 + homeassistant/components/airthings_ble/__init__.py | 6 +++--- mypy.ini | 10 ++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.strict-typing b/.strict-typing index 076b093adbbbb..9eb9d31845783 100644 --- a/.strict-typing +++ b/.strict-typing @@ -49,6 +49,7 @@ homeassistant.components.aftership.* homeassistant.components.air_quality.* homeassistant.components.airly.* homeassistant.components.airnow.* +homeassistant.components.airthings_ble.* homeassistant.components.airvisual.* homeassistant.components.airvisual_pro.* homeassistant.components.airzone.* diff --git a/homeassistant/components/airthings_ble/__init__.py b/homeassistant/components/airthings_ble/__init__.py index d7e6bddbcd4e1..c642ebf95635c 100644 --- a/homeassistant/components/airthings_ble/__init__.py +++ b/homeassistant/components/airthings_ble/__init__.py @@ -4,7 +4,7 @@ from datetime import timedelta import logging -from airthings_ble import AirthingsBluetoothDeviceData +from airthings_ble import AirthingsBluetoothDeviceData, AirthingsDevice from homeassistant.components import bluetooth 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}" ) - async def _async_update_method(): + async def _async_update_method() -> AirthingsDevice: """Get data from Airthings BLE.""" ble_device = bluetooth.async_ble_device_from_address(hass, address) airthings = AirthingsBluetoothDeviceData(_LOGGER, elevation, is_metric) try: - data = await airthings.update_device(ble_device) + data = await airthings.update_device(ble_device) # type: ignore[arg-type] except Exception as err: raise UpdateFailed(f"Unable to fetch data: {err}") from err diff --git a/mypy.ini b/mypy.ini index c6a880bc6d789..06d9f21df423d 100644 --- a/mypy.ini +++ b/mypy.ini @@ -250,6 +250,16 @@ disallow_untyped_defs = true warn_return_any = 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.*] check_untyped_defs = true disallow_incomplete_defs = true