From 3eeef266268a815c803fdaa7665ef2bb4b89e6d4 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 19 Aug 2026 09:02:46 +0000 Subject: [PATCH] Make the context argument of async_create_group explicit The other keyword-only arguments have no default and every call site passes them explicitly, including the ones that are None. Drop the default so a new caller has to decide what to attribute the group to. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01DQdoLT4SC1w5LUgDQA3vEq --- homeassistant/components/group/entity.py | 2 +- .../device_sun_light_trigger/test_init.py | 1 + tests/components/group/test_init.py | 28 +++++++++++++++++++ tests/components/zwave_js/test_services.py | 6 ++++ .../helpers/template/extensions/test_state.py | 4 +++ tests/helpers/test_service.py | 1 + tests/helpers/test_target.py | 1 + 7 files changed, 42 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/group/entity.py b/homeassistant/components/group/entity.py index 651da4bbcb8c..8c1302e51806 100644 --- a/homeassistant/components/group/entity.py +++ b/homeassistant/components/group/entity.py @@ -232,7 +232,7 @@ class Group(Entity): mode: bool | None, object_id: str | None, order: int | None, - context: Context | None = None, + context: Context | None, ) -> Group: """Initialize a group. diff --git a/tests/components/device_sun_light_trigger/test_init.py b/tests/components/device_sun_light_trigger/test_init.py index 249964829160..62492a1b19e0 100644 --- a/tests/components/device_sun_light_trigger/test_init.py +++ b/tests/components/device_sun_light_trigger/test_init.py @@ -216,6 +216,7 @@ async def test_lights_turn_on_when_coming_home_after_sun_set_person( mode=None, object_id=None, order=None, + context=None, ) assert await async_setup_component( diff --git a/tests/components/group/test_init.py b/tests/components/group/test_init.py index fd8edf0d7195..22b590e9477f 100644 --- a/tests/components/group/test_init.py +++ b/tests/components/group/test_init.py @@ -161,6 +161,7 @@ async def test_setup_group_with_mixed_groupable_states(hass: HomeAssistant) -> N mode=None, object_id=None, order=None, + context=None, ) await hass.async_block_till_done() @@ -183,6 +184,7 @@ async def test_setup_group_with_a_non_existing_state(hass: HomeAssistant) -> Non mode=None, object_id=None, order=None, + context=None, ) assert grp.state == STATE_ON @@ -204,6 +206,7 @@ async def test_setup_group_with_non_groupable_states(hass: HomeAssistant) -> Non mode=None, object_id=None, order=None, + context=None, ) assert grp.state is None @@ -220,6 +223,7 @@ async def test_setup_empty_group(hass: HomeAssistant) -> None: mode=None, object_id=None, order=None, + context=None, ) assert grp.state is None @@ -241,6 +245,7 @@ async def test_monitor_group(hass: HomeAssistant) -> None: mode=None, object_id=None, order=None, + context=None, ) # Test if group setup in our init mode is ok @@ -267,6 +272,7 @@ async def test_group_turns_off_if_all_off(hass: HomeAssistant) -> None: mode=None, object_id=None, order=None, + context=None, ) await hass.async_block_till_done() @@ -293,6 +299,7 @@ async def test_group_turns_on_if_all_are_off_and_one_turns_on( mode=None, object_id=None, order=None, + context=None, ) # Turn one on @@ -321,6 +328,7 @@ async def test_allgroup_stays_off_if_all_are_off_and_one_turns_on( mode=True, object_id=None, order=None, + context=None, ) # Turn one on @@ -347,6 +355,7 @@ async def test_allgroup_turn_on_if_last_turns_on(hass: HomeAssistant) -> None: mode=True, object_id=None, order=None, + context=None, ) # Turn one on @@ -373,6 +382,7 @@ async def test_expand_entity_ids(hass: HomeAssistant) -> None: mode=None, object_id=None, order=None, + context=None, ) assert sorted(["light.ceiling", "light.bowl"]) == sorted( @@ -398,6 +408,7 @@ async def test_expand_entity_ids_does_not_return_duplicates( mode=None, object_id=None, order=None, + context=None, ) assert sorted( @@ -425,6 +436,7 @@ async def test_expand_entity_ids_recursive(hass: HomeAssistant) -> None: mode=None, object_id=None, order=None, + context=None, ) assert sorted(["light.ceiling", "light.bowl"]) == sorted( @@ -453,6 +465,7 @@ async def test_get_entity_ids(hass: HomeAssistant) -> None: mode=None, object_id=None, order=None, + context=None, ) assert sorted(group.get_entity_ids(hass, test_group.entity_id)) == [ @@ -476,6 +489,7 @@ async def test_get_entity_ids_with_domain_filter(hass: HomeAssistant) -> None: mode=None, object_id=None, order=None, + context=None, ) assert group.get_entity_ids( @@ -513,6 +527,7 @@ async def test_group_being_init_before_first_tracked_state_is_set_to_on( mode=None, object_id=None, order=None, + context=None, ) hass.states.async_set("light.not_there_1", STATE_ON) @@ -541,6 +556,7 @@ async def test_group_being_init_before_first_tracked_state_is_set_to_off( mode=None, object_id=None, order=None, + context=None, ) hass.states.async_set("light.not_there_1", STATE_OFF) @@ -565,6 +581,7 @@ async def test_groups_get_unique_names(hass: HomeAssistant) -> None: mode=None, object_id=None, order=None, + context=None, ) grp2 = await group.Group.async_create_group( hass, @@ -575,6 +592,7 @@ async def test_groups_get_unique_names(hass: HomeAssistant) -> None: mode=None, object_id=None, order=None, + context=None, ) assert grp1.entity_id != grp2.entity_id @@ -594,6 +612,7 @@ async def test_expand_entity_ids_expands_nested_groups(hass: HomeAssistant) -> N mode=None, object_id=None, order=None, + context=None, ) await group.Group.async_create_group( hass, @@ -604,6 +623,7 @@ async def test_expand_entity_ids_expands_nested_groups(hass: HomeAssistant) -> N mode=None, object_id=None, order=None, + context=None, ) await group.Group.async_create_group( hass, @@ -614,6 +634,7 @@ async def test_expand_entity_ids_expands_nested_groups(hass: HomeAssistant) -> N mode=None, object_id=None, order=None, + context=None, ) assert sorted(group.expand_entity_ids(hass, ["group.group_of_groups"])) == [ @@ -640,6 +661,7 @@ async def test_set_assumed_state_based_on_tracked(hass: HomeAssistant) -> None: mode=None, object_id=None, order=None, + context=None, ) state = hass.states.get(test_group.entity_id) @@ -679,6 +701,7 @@ async def test_group_updated_after_device_tracker_zone_change( mode=None, object_id=None, order=None, + context=None, ) hass.states.async_set("device_tracker.Adam", "cool_state_not_home") @@ -705,6 +728,7 @@ async def test_is_on(hass: HomeAssistant) -> None: mode=None, object_id=None, order=None, + context=None, ) await hass.async_block_till_done() @@ -842,6 +866,7 @@ async def test_is_on_and_state_mixed_domains( mode=None, object_id=None, order=None, + context=None, ) await hass.async_block_till_done() @@ -885,6 +910,7 @@ async def test_reloading_groups(hass: HomeAssistant) -> None: mode=None, object_id=None, order=None, + context=None, ) await hass.async_block_till_done() @@ -962,6 +988,7 @@ async def test_setup(hass: HomeAssistant) -> None: mode=None, object_id=None, order=None, + context=None, ) await group.Group.async_create_group( hass, @@ -972,6 +999,7 @@ async def test_setup(hass: HomeAssistant) -> None: mode=None, object_id=None, order=None, + context=None, ) await hass.async_block_till_done() diff --git a/tests/components/zwave_js/test_services.py b/tests/components/zwave_js/test_services.py index bfb7dd8bf5b4..f0ffd0bcaa00 100644 --- a/tests/components/zwave_js/test_services.py +++ b/tests/components/zwave_js/test_services.py @@ -302,6 +302,7 @@ async def test_set_config_parameter( mode=None, object_id=None, order=None, + context=None, ) await hass.services.async_call( DOMAIN, @@ -800,6 +801,7 @@ async def test_bulk_set_config_parameters( mode=None, object_id=None, order=None, + context=None, ) await hass.services.async_call( DOMAIN, @@ -943,6 +945,7 @@ async def test_refresh_value( mode=None, object_id=None, order=None, + context=None, ) client.async_send_command.return_value = {"result": 2} await hass.services.async_call( @@ -1075,6 +1078,7 @@ async def test_set_value( mode=None, object_id=None, order=None, + context=None, ) await hass.services.async_call( DOMAIN, @@ -1385,6 +1389,7 @@ async def test_multicast_set_value( mode=None, object_id=None, order=None, + context=None, ) await hass.services.async_call( DOMAIN, @@ -1760,6 +1765,7 @@ async def test_ping( mode=None, object_id=None, order=None, + context=None, ) await hass.services.async_call( DOMAIN, diff --git a/tests/helpers/template/extensions/test_state.py b/tests/helpers/template/extensions/test_state.py index 7ca099dff527..1cf6afb684de 100644 --- a/tests/helpers/template/extensions/test_state.py +++ b/tests/helpers/template/extensions/test_state.py @@ -740,6 +740,7 @@ async def test_expand(hass: HomeAssistant) -> None: mode=None, object_id=None, order=None, + context=None, ) info = render_to_info( @@ -800,6 +801,7 @@ async def test_expand(hass: HomeAssistant) -> None: mode=None, object_id=None, order=None, + context=None, ) info = render_to_info( @@ -1301,6 +1303,7 @@ async def test_closest_function_home_vs_group_entity_id(hass: HomeAssistant) -> mode=None, object_id=None, order=None, + context=None, ) info = render_to_info(hass, '{{ closest("group.location_group").entity_id }}') @@ -1338,6 +1341,7 @@ async def test_closest_function_home_vs_group_state(hass: HomeAssistant) -> None mode=None, object_id=None, order=None, + context=None, ) info = render_to_info(hass, '{{ closest("group.location_group").entity_id }}') diff --git a/tests/helpers/test_service.py b/tests/helpers/test_service.py index 7505798e9dc1..cca0ed954190 100644 --- a/tests/helpers/test_service.py +++ b/tests/helpers/test_service.py @@ -719,6 +719,7 @@ async def test_extract_entity_ids(hass: HomeAssistant) -> None: mode=None, object_id=None, order=None, + context=None, ) call = ServiceCall(hass, "light", "turn_on", {ATTR_ENTITY_ID: "light.Bowl"}) diff --git a/tests/helpers/test_target.py b/tests/helpers/test_target.py index e42cbc4eb389..27f57ae1d5f2 100644 --- a/tests/helpers/test_target.py +++ b/tests/helpers/test_target.py @@ -513,6 +513,7 @@ async def test_extract_referenced_entity_ids( mode=None, object_id=None, order=None, + context=None, ) target_selection = selection_class(selector_config)