bail early

This commit is contained in:
J. Nick Koston
2023-04-10 17:13:25 -10:00
parent b780f10de8
commit 30a461c55c

View File

@@ -9,7 +9,6 @@ from operator import itemgetter
from typing import Any, cast from typing import Any, cast
from sqlalchemy import ( from sqlalchemy import (
Column,
CompoundSelect, CompoundSelect,
Integer, Integer,
Select, Select,
@@ -690,10 +689,9 @@ def _sorted_states_to_dict(
# Append all changes to it # Append all changes to it
for metadata_id, group in states_iter: for metadata_id, group in states_iter:
attr_cache: dict[str, dict[str, Any]] = {}
prev_state: Column | str | None = None
if not (entity_id := metadata_id_to_entity_id.get(metadata_id)): if not (entity_id := metadata_id_to_entity_id.get(metadata_id)):
continue continue
attr_cache: dict[str, dict[str, Any]] = {}
ent_results = result[entity_id] ent_results = result[entity_id]
if ( if (
not minimal_response not minimal_response
@@ -712,6 +710,7 @@ def _sorted_states_to_dict(
) )
continue continue
prev_state: str | None = None
# With minimal response we only provide a native # With minimal response we only provide a native
# State for the first and last response. All the states # State for the first and last response. All the states
# in-between only provide the "state" and the # in-between only provide the "state" and the