Drop unnecessary lambdas in the entity filter (#122941)
parent
79a741486c
commit
2f3f124aa1
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue