From 970b9d79c5aee07e03011a6c9c44adecab95de56 Mon Sep 17 00:00:00 2001 From: Tom Parker-Shemilt Date: Mon, 1 Apr 2024 22:57:44 +0100 Subject: [PATCH] Allow other config --- custom_components/ban_whitelist/__init__.py | 3 ++- stubs/voluptuous.pyi | 4 +++- tests/ban_whitelist/test_setup.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/custom_components/ban_whitelist/__init__.py b/custom_components/ban_whitelist/__init__.py index 07a5eba..9f7d032 100644 --- a/custom_components/ban_whitelist/__init__.py +++ b/custom_components/ban_whitelist/__init__.py @@ -23,7 +23,8 @@ vol.Required("ip_addresses"): vol.All(cv.ensure_list, [cv.string]), } ) - } + }, + extra=vol.ALLOW_EXTRA, ) diff --git a/stubs/voluptuous.pyi b/stubs/voluptuous.pyi index 5603247..a67a9e9 100644 --- a/stubs/voluptuous.pyi +++ b/stubs/voluptuous.pyi @@ -3,7 +3,7 @@ from typing import Any, Callable, List class Schema: - def __init__(self, config: dict) -> None: ... + def __init__(self, config: dict, extra: int | None = None) -> None: ... class Required: def __init__(self, name: str) -> None: ... @@ -12,3 +12,5 @@ class All: def __init__( self, *args: List[Callable[[Any], Any]] | Callable[[Any], Any] ) -> None: ... + +ALLOW_EXTRA: int = ... diff --git a/tests/ban_whitelist/test_setup.py b/tests/ban_whitelist/test_setup.py index 315fb52..468ec22 100644 --- a/tests/ban_whitelist/test_setup.py +++ b/tests/ban_whitelist/test_setup.py @@ -17,7 +17,7 @@ async def test_setup(hass: HomeAssistant, caplog: pytest.LogCaptureFixture) -> N assert list((await async_get_custom_components(hass)).keys()) == ["ban_whitelist"] await async_setup_component(hass, "http", {}) await async_setup_component( - hass, DOMAIN, {DOMAIN: {"ip_addresses": ["192.168.1.1"]}} + hass, DOMAIN, {DOMAIN: {"ip_addresses": ["192.168.1.1"]}, "foo": "bar"} ) for record in caplog.records: