From 7e28c788cbb096fccd64f727e609e7883039753f Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Fri, 12 Jan 2024 12:56:13 +0100 Subject: [PATCH] Enable strict typing for bthome (#107859) --- .strict-typing | 1 + homeassistant/components/bthome/config_flow.py | 6 +++--- homeassistant/components/bthome/device_trigger.py | 2 +- mypy.ini | 10 ++++++++++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.strict-typing b/.strict-typing index f92ede38c19..cd43c375439 100644 --- a/.strict-typing +++ b/.strict-typing @@ -110,6 +110,7 @@ homeassistant.components.bond.* homeassistant.components.braviatv.* homeassistant.components.brother.* homeassistant.components.browser.* +homeassistant.components.bthome.* homeassistant.components.button.* homeassistant.components.calendar.* homeassistant.components.camera.* diff --git a/homeassistant/components/bthome/config_flow.py b/homeassistant/components/bthome/config_flow.py index a728efdf05a..26bf1186a1d 100644 --- a/homeassistant/components/bthome/config_flow.py +++ b/homeassistant/components/bthome/config_flow.py @@ -75,7 +75,7 @@ class BTHomeConfigFlow(ConfigFlow, domain=DOMAIN): errors = {} if user_input is not None: - bindkey = user_input["bindkey"] + bindkey: str = user_input["bindkey"] if len(bindkey) != 32: errors["bindkey"] = "expected_32_characters" @@ -173,8 +173,8 @@ class BTHomeConfigFlow(ConfigFlow, domain=DOMAIN): # Otherwise there wasn't actually encryption so abort return self.async_abort(reason="reauth_successful") - def _async_get_or_create_entry(self, bindkey=None): - data = {} + def _async_get_or_create_entry(self, bindkey: str | None = None) -> FlowResult: + data: dict[str, Any] = {} if bindkey: data["bindkey"] = bindkey diff --git a/homeassistant/components/bthome/device_trigger.py b/homeassistant/components/bthome/device_trigger.py index a81c30eee85..6bcc1635aff 100644 --- a/homeassistant/components/bthome/device_trigger.py +++ b/homeassistant/components/bthome/device_trigger.py @@ -66,7 +66,7 @@ async def async_validate_trigger_config( hass: HomeAssistant, config: ConfigType ) -> ConfigType: """Validate trigger config.""" - return SCHEMA_BY_EVENT_CLASS.get(config[CONF_TYPE], DEVICE_TRIGGER_BASE_SCHEMA)( + return SCHEMA_BY_EVENT_CLASS.get(config[CONF_TYPE], DEVICE_TRIGGER_BASE_SCHEMA)( # type: ignore[no-any-return] config ) diff --git a/mypy.ini b/mypy.ini index bd975096ea4..361bdd63047 100644 --- a/mypy.ini +++ b/mypy.ini @@ -860,6 +860,16 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.bthome.*] +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.button.*] check_untyped_defs = true disallow_incomplete_defs = true