From 19900b004b0651ff62a94f78a0c5f977162dd95f Mon Sep 17 00:00:00 2001 From: Quentin Smith Date: Tue, 11 Oct 2022 22:15:03 -0400 Subject: [PATCH] Fix type annotation on `extract_registry_entry_config` (#3623) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- esphome/cpp_helpers.py | 7 ++++--- esphome/util.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/esphome/cpp_helpers.py b/esphome/cpp_helpers.py index 822197341e..0ab4b75a16 100644 --- a/esphome/cpp_helpers.py +++ b/esphome/cpp_helpers.py @@ -13,7 +13,7 @@ from esphome.const import ( # pylint: disable=unused-import from esphome.core import coroutine, ID, CORE -from esphome.types import ConfigType +from esphome.types import ConfigType, ConfigFragmentType from esphome.cpp_generator import add, get_variable from esphome.cpp_types import App from esphome.util import Registry, RegistryEntry @@ -108,8 +108,9 @@ async def setup_entity(var, config): def extract_registry_entry_config( - registry: Registry, full_config: ConfigType -) -> RegistryEntry: + registry: Registry, + full_config: ConfigType, +) -> tuple[RegistryEntry, ConfigFragmentType]: key, config = next((k, v) for k, v in full_config.items() if k in registry) return registry[key], config diff --git a/esphome/util.py b/esphome/util.py index 1779e8ccfb..0d60212f50 100644 --- a/esphome/util.py +++ b/esphome/util.py @@ -34,7 +34,7 @@ class RegistryEntry: return Schema(self.raw_schema) -class Registry(dict): +class Registry(dict[str, RegistryEntry]): def __init__(self, base_schema=None, type_id_key=None): super().__init__() self.base_schema = base_schema or {}