From 42008c50f35fea3b8fdac2648c0155778bcd51f4 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 7 Feb 2023 11:16:22 +0100 Subject: [PATCH] Enable error-code `truthy-iterable` [mypy 1.0] (#87596) --- homeassistant/helpers/entity_platform.py | 2 +- mypy.ini | 2 +- script/hassfest/mypy_config.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/helpers/entity_platform.py b/homeassistant/helpers/entity_platform.py index f003d755033..c002915a4df 100644 --- a/homeassistant/helpers/entity_platform.py +++ b/homeassistant/helpers/entity_platform.py @@ -418,7 +418,7 @@ class EntityPlatform: This method must be run in the event loop. """ # handle empty list from component/platform - if not new_entities: + if not new_entities: # type: ignore[truthy-iterable] return hass = self.hass diff --git a/mypy.ini b/mypy.ini index 08dce1ad594..fdbacd0c817 100644 --- a/mypy.ini +++ b/mypy.ini @@ -14,7 +14,7 @@ warn_incomplete_stub = true warn_redundant_casts = true warn_unused_configs = true warn_unused_ignores = true -enable_error_code = ignore-without-code +enable_error_code = ignore-without-code, truthy-iterable disable_error_code = annotation-unchecked strict_concatenate = false check_untyped_defs = true diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index 36aa6083326..fa69a56f601 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -48,7 +48,7 @@ GENERAL_SETTINGS: Final[dict[str, str]] = { "warn_redundant_casts": "true", "warn_unused_configs": "true", "warn_unused_ignores": "true", - "enable_error_code": ", ".join(["ignore-without-code"]), + "enable_error_code": ", ".join(["ignore-without-code", "truthy-iterable"]), "disable_error_code": ", ".join(["annotation-unchecked"]), # Strict_concatenate breaks passthrough ParamSpec typing "strict_concatenate": "false",