Update ruff to v0.0.262 (#91767)

This commit is contained in:
Franck Nijhof 2023-04-21 08:15:41 +02:00 committed by GitHub
parent 7a20335943
commit 65d7e48815
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 18 deletions

View file

@ -1,6 +1,6 @@
repos: repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit - repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.260 rev: v0.0.262
hooks: hooks:
- id: ruff - id: ruff
args: args:

View file

@ -4,5 +4,5 @@ bandit==1.7.4
black==23.3.0 black==23.3.0
codespell==2.2.2 codespell==2.2.2
isort==5.12.0 isort==5.12.0
ruff==0.0.260 ruff==0.0.262
yamllint==1.28.0 yamllint==1.28.0

View file

@ -100,14 +100,14 @@ def assert_result_info(
assert info.filter("invalid_entity_name.somewhere") == all_states assert info.filter("invalid_entity_name.somewhere") == all_states
if entities is not None: if entities is not None:
assert info.entities == frozenset(entities) 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: if not all_states:
assert not info.filter("invalid_entity_name.somewhere") assert not info.filter("invalid_entity_name.somewhere")
else: else:
assert not info.entities assert not info.entities
if domains is not None: if domains is not None:
assert info.domains == frozenset(domains) 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: else:
assert not hasattr(info, "_domains") assert not hasattr(info, "_domains")
@ -1202,32 +1202,28 @@ def test_min_max_attribute(hass: HomeAssistant, attribute) -> None:
) )
assert ( assert (
template.Template( template.Template(
"{{ (state_attr('test.object', 'objects') | min(attribute='%s'))['%s']}}" f"{{{{ (state_attr('test.object', 'objects') | min(attribute='{attribute}'))['{attribute}']}}}}",
% (attribute, attribute),
hass, hass,
).async_render() ).async_render()
== 1 == 1
) )
assert ( assert (
template.Template( template.Template(
"{{ (min(state_attr('test.object', 'objects'), attribute='%s'))['%s']}}" f"{{{{ (min(state_attr('test.object', 'objects'), attribute='{attribute}'))['{attribute}']}}}}",
% (attribute, attribute),
hass, hass,
).async_render() ).async_render()
== 1 == 1
) )
assert ( assert (
template.Template( template.Template(
"{{ (state_attr('test.object', 'objects') | max(attribute='%s'))['%s']}}" f"{{{{ (state_attr('test.object', 'objects') | max(attribute='{attribute}'))['{attribute}']}}}}",
% (attribute, attribute),
hass, hass,
).async_render() ).async_render()
== 3 == 3
) )
assert ( assert (
template.Template( template.Template(
"{{ (max(state_attr('test.object', 'objects'), attribute='%s'))['%s']}}" f"{{{{ (max(state_attr('test.object', 'objects'), attribute='{attribute}'))['{attribute}']}}}}",
% (attribute, attribute),
hass, hass,
).async_render() ).async_render()
== 3 == 3
@ -2323,8 +2319,7 @@ def test_distance_function_with_2_coords(hass: HomeAssistant) -> None:
_set_up_units(hass) _set_up_units(hass)
assert ( assert (
template.Template( template.Template(
'{{ distance("32.87336", "-117.22943", %s, %s) | round }}' f'{{{{ distance("32.87336", "-117.22943", {hass.config.latitude}, {hass.config.longitude}) | round }}}}',
% (hass.config.latitude, hass.config.longitude),
hass, hass,
).async_render() ).async_render()
== 187 == 187
@ -3352,16 +3347,14 @@ def test_closest_function_to_coord(hass: HomeAssistant) -> None:
) )
tpl = template.Template( tpl = template.Template(
'{{ closest("%s", %s, states.test_domain).entity_id }}' f'{{{{ closest("{hass.config.latitude + 0.3}", {hass.config.longitude + 0.3}, states.test_domain).entity_id }}}}',
% (hass.config.latitude + 0.3, hass.config.longitude + 0.3),
hass, hass,
) )
assert tpl.async_render() == "test_domain.closest_zone" assert tpl.async_render() == "test_domain.closest_zone"
tpl = template.Template( tpl = template.Template(
'{{ (states.test_domain | closest("%s", %s)).entity_id }}' f'{{{{ (states.test_domain | closest("{hass.config.latitude + 0.3}", {hass.config.longitude + 0.3})).entity_id }}}}',
% (hass.config.latitude + 0.3, hass.config.longitude + 0.3),
hass, hass,
) )