Small speed up to validating entity ids (#92970)

This commit is contained in:
J. Nick Koston 2023-05-12 22:04:09 +09:00 committed by GitHub
parent 02b5d643e7
commit 93bfd7d8d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -567,6 +567,10 @@ def string(value: Any) -> str:
if value is None:
raise vol.Invalid("string value is None")
# This is expected to be the most common case, so check it first.
if type(value) is str: # pylint: disable=unidiomatic-typecheck
return value
if isinstance(value, template_helper.ResultWrapper):
value = value.render_result