From ebb450c94698e2240b2fa49ce44655d247b32f99 Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Tue, 21 Feb 2023 08:48:44 +0100 Subject: [PATCH] Default `hass_config` to contain an empty config (#88515) * Default hass_config to {} * Correct type hint --- pylint/plugins/hass_enforce_type_hints.py | 2 +- .../components/homeassistant/triggers/test_homeassistant.py | 2 +- tests/conftest.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py index 5ee0489e8c4..41c718704b5 100644 --- a/pylint/plugins/hass_enforce_type_hints.py +++ b/pylint/plugins/hass_enforce_type_hints.py @@ -109,7 +109,7 @@ _TEST_FIXTURES: dict[str, list[str] | str] = { "hass_admin_user": "MockUser", "hass_client": "ClientSessionGenerator", "hass_client_no_auth": "ClientSessionGenerator", - "hass_config": "ConfigType | None", + "hass_config": "ConfigType", "hass_config_yaml": "str | None", "hass_config_yaml_files": "dict[str, str] | None", "hass_owner_user": "MockUser", diff --git a/tests/components/homeassistant/triggers/test_homeassistant.py b/tests/components/homeassistant/triggers/test_homeassistant.py index 1bc28a92ba4..ef57e1628d8 100644 --- a/tests/components/homeassistant/triggers/test_homeassistant.py +++ b/tests/components/homeassistant/triggers/test_homeassistant.py @@ -27,7 +27,7 @@ from tests.common import async_mock_service ], ) async def test_if_fires_on_hass_start( - hass: HomeAssistant, mock_hass_config: None, hass_config: ConfigType | None + hass: HomeAssistant, mock_hass_config: None, hass_config: ConfigType ) -> None: """Test the firing when Home Assistant starts.""" calls = async_mock_service(hass, "test", "automation") diff --git a/tests/conftest.py b/tests/conftest.py index 2717edf7021..356e2ba0d83 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -920,19 +920,19 @@ async def _mqtt_mock_entry( @pytest.fixture -def hass_config() -> ConfigType | None: +def hass_config() -> ConfigType: """Fixture to parametrize the content of main configuration using mock_hass_config. To set a configuration, tests can be marked with: @pytest.mark.parametrize("hass_config", [{integration: {...}}]) Add the `mock_hass_config: None` fixture to the test. """ - return None + return {} @pytest.fixture def mock_hass_config( - hass: HomeAssistant, hass_config: ConfigType | None + hass: HomeAssistant, hass_config: ConfigType ) -> Generator[None, None, None]: """Fixture to mock the content of main configuration.