Enable Ruff FLY002 rule (#115112)

Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
This commit is contained in:
Sid 2024-04-12 09:04:16 +02:00 committed by GitHub
parent 35d3f2b29b
commit 9bf87329da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 474 additions and 659 deletions

View file

@ -219,8 +219,10 @@ async def test_if_state(
"action": {
"service": "test.automation",
"data_template": {
"some": "is_on {{ trigger.%s }}"
% "}} - {{ trigger.".join(("platform", "event.event_type"))
"some": (
"is_on {{ trigger.platform }}"
" - {{ trigger.event.event_type }}"
)
},
},
},
@ -238,8 +240,10 @@ async def test_if_state(
"action": {
"service": "test.automation",
"data_template": {
"some": "is_off {{ trigger.%s }}"
% "}} - {{ trigger.".join(("platform", "event.event_type"))
"some": (
"is_off {{ trigger.platform }}"
" - {{ trigger.event.event_type }}"
)
},
},
},
@ -302,8 +306,10 @@ async def test_if_state_legacy(
"action": {
"service": "test.automation",
"data_template": {
"some": "is_on {{ trigger.%s }}"
% "}} - {{ trigger.".join(("platform", "event.event_type"))
"some": (
"is_on {{ trigger.platform }}"
" - {{ trigger.event.event_type }}"
)
},
},
},
@ -367,9 +373,9 @@ async def test_if_fires_on_for_condition(
"action": {
"service": "test.automation",
"data_template": {
"some": "is_off {{ trigger.%s }}"
% "}} - {{ trigger.".join(
("platform", "event.event_type")
"some": (
"is_off {{ trigger.platform }}"
" - {{ trigger.event.event_type }}"
)
},
},

View file

@ -23,6 +23,14 @@ from tests.common import (
async_mock_service,
)
DATA_TEMPLATE_ATTRIBUTES = (
"{{ trigger.platform }}"
" - {{ trigger.entity_id }}"
" - {{ trigger.from_state.state }}"
" - {{ trigger.to_state.state }}"
" - {{ trigger.for }}"
)
@pytest.fixture(autouse=True, name="stub_blueprint_populate")
def stub_blueprint_populate_autouse(stub_blueprint_populate: None) -> None:
@ -212,16 +220,7 @@ async def test_if_fires_on_state_change(
"action": {
"service": "test.automation",
"data_template": {
"some": "turn_on {{ trigger.%s }}"
% "}} - {{ trigger.".join(
(
"platform",
"entity_id",
"from_state.state",
"to_state.state",
"for",
)
)
"some": "turn_on " + DATA_TEMPLATE_ATTRIBUTES
},
},
},
@ -236,16 +235,7 @@ async def test_if_fires_on_state_change(
"action": {
"service": "test.automation",
"data_template": {
"some": "turn_off {{ trigger.%s }}"
% "}} - {{ trigger.".join(
(
"platform",
"entity_id",
"from_state.state",
"to_state.state",
"for",
)
)
"some": "turn_off " + DATA_TEMPLATE_ATTRIBUTES
},
},
},
@ -260,16 +250,7 @@ async def test_if_fires_on_state_change(
"action": {
"service": "test.automation",
"data_template": {
"some": "turn_on_or_off {{ trigger.%s }}"
% "}} - {{ trigger.".join(
(
"platform",
"entity_id",
"from_state.state",
"to_state.state",
"for",
)
)
"some": "turn_on_or_off " + DATA_TEMPLATE_ATTRIBUTES
},
},
},
@ -332,16 +313,7 @@ async def test_if_fires_on_state_change_legacy(
"action": {
"service": "test.automation",
"data_template": {
"some": "turn_on {{ trigger.%s }}"
% "}} - {{ trigger.".join(
(
"platform",
"entity_id",
"from_state.state",
"to_state.state",
"for",
)
)
"some": "turn_on " + DATA_TEMPLATE_ATTRIBUTES
},
},
},
@ -396,16 +368,7 @@ async def test_if_fires_on_state_change_with_for(
"action": {
"service": "test.automation",
"data_template": {
"some": "turn_off {{ trigger.%s }}"
% "}} - {{ trigger.".join(
(
"platform",
"entity_id",
"from_state.state",
"to_state.state",
"for",
)
)
"some": "turn_off " + DATA_TEMPLATE_ATTRIBUTES
},
},
}