From 65d7e4881545b49f3656ccb343019cc74f3bf2a6 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Fri, 21 Apr 2023 08:15:41 +0200 Subject: [PATCH] Update ruff to v0.0.262 (#91767) --- .pre-commit-config.yaml | 2 +- requirements_test_pre_commit.txt | 2 +- tests/helpers/test_template.py | 25 +++++++++---------------- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 88bb4a703a9..8e8fef97697 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.260 + rev: v0.0.262 hooks: - id: ruff args: diff --git a/requirements_test_pre_commit.txt b/requirements_test_pre_commit.txt index d76382c5c99..9954e97da97 100644 --- a/requirements_test_pre_commit.txt +++ b/requirements_test_pre_commit.txt @@ -4,5 +4,5 @@ bandit==1.7.4 black==23.3.0 codespell==2.2.2 isort==5.12.0 -ruff==0.0.260 +ruff==0.0.262 yamllint==1.28.0 diff --git a/tests/helpers/test_template.py b/tests/helpers/test_template.py index 0f9be9b2ed8..e18758658d6 100644 --- a/tests/helpers/test_template.py +++ b/tests/helpers/test_template.py @@ -100,14 +100,14 @@ def assert_result_info( assert info.filter("invalid_entity_name.somewhere") == all_states if entities is not None: assert info.entities == frozenset(entities) - assert all([info.filter(entity) for entity in entities]) + assert all(info.filter(entity) for entity in entities) if not all_states: assert not info.filter("invalid_entity_name.somewhere") else: assert not info.entities if domains is not None: assert info.domains == frozenset(domains) - assert all([info.filter(domain + ".entity") for domain in domains]) + assert all(info.filter(domain + ".entity") for domain in domains) else: assert not hasattr(info, "_domains") @@ -1202,32 +1202,28 @@ def test_min_max_attribute(hass: HomeAssistant, attribute) -> None: ) assert ( template.Template( - "{{ (state_attr('test.object', 'objects') | min(attribute='%s'))['%s']}}" - % (attribute, attribute), + f"{{{{ (state_attr('test.object', 'objects') | min(attribute='{attribute}'))['{attribute}']}}}}", hass, ).async_render() == 1 ) assert ( template.Template( - "{{ (min(state_attr('test.object', 'objects'), attribute='%s'))['%s']}}" - % (attribute, attribute), + f"{{{{ (min(state_attr('test.object', 'objects'), attribute='{attribute}'))['{attribute}']}}}}", hass, ).async_render() == 1 ) assert ( template.Template( - "{{ (state_attr('test.object', 'objects') | max(attribute='%s'))['%s']}}" - % (attribute, attribute), + f"{{{{ (state_attr('test.object', 'objects') | max(attribute='{attribute}'))['{attribute}']}}}}", hass, ).async_render() == 3 ) assert ( template.Template( - "{{ (max(state_attr('test.object', 'objects'), attribute='%s'))['%s']}}" - % (attribute, attribute), + f"{{{{ (max(state_attr('test.object', 'objects'), attribute='{attribute}'))['{attribute}']}}}}", hass, ).async_render() == 3 @@ -2323,8 +2319,7 @@ def test_distance_function_with_2_coords(hass: HomeAssistant) -> None: _set_up_units(hass) assert ( template.Template( - '{{ distance("32.87336", "-117.22943", %s, %s) | round }}' - % (hass.config.latitude, hass.config.longitude), + f'{{{{ distance("32.87336", "-117.22943", {hass.config.latitude}, {hass.config.longitude}) | round }}}}', hass, ).async_render() == 187 @@ -3352,16 +3347,14 @@ def test_closest_function_to_coord(hass: HomeAssistant) -> None: ) tpl = template.Template( - '{{ closest("%s", %s, states.test_domain).entity_id }}' - % (hass.config.latitude + 0.3, hass.config.longitude + 0.3), + f'{{{{ closest("{hass.config.latitude + 0.3}", {hass.config.longitude + 0.3}, states.test_domain).entity_id }}}}', hass, ) assert tpl.async_render() == "test_domain.closest_zone" tpl = template.Template( - '{{ (states.test_domain | closest("%s", %s)).entity_id }}' - % (hass.config.latitude + 0.3, hass.config.longitude + 0.3), + f'{{{{ (states.test_domain | closest("{hass.config.latitude + 0.3}", {hass.config.longitude + 0.3})).entity_id }}}}', hass, )