Drop unnecessary lambdas in the entity filter (#122941)

pull/115645/head
J. Nick Koston 2024-07-31 13:44:47 -05:00 committed by GitHub
parent 79a741486c
commit 2f3f124aa1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 3 deletions

View File

@ -4,7 +4,8 @@ from __future__ import annotations
from collections.abc import Callable
import fnmatch
from functools import lru_cache
from functools import lru_cache, partial
import operator
import re
import voluptuous as vol
@ -195,7 +196,7 @@ def _generate_filter_from_sets_and_pattern_lists(
# Case 1 - No filter
# - All entities included
if not have_include and not have_exclude:
return lambda entity_id: True
return bool
# Case 2 - Only includes
# - Entity listed in entities include: include
@ -280,4 +281,4 @@ def _generate_filter_from_sets_and_pattern_lists(
# Case 6 - No Domain and/or glob includes or excludes
# - Entity listed in entities include: include
# - Otherwise: exclude
return lambda entity_id: entity_id in include_e
return partial(operator.contains, include_e)