Avoid dict comp in statistic_during_period if there is no conversion (#93699)

This commit is contained in:
J. Nick Koston 2023-05-29 19:59:15 -05:00 committed by GitHub
parent 53fe74e055
commit 493d78f070
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1478,7 +1478,9 @@ def statistic_during_period(
state_unit = state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
convert = _get_statistic_to_display_unit_converter(unit, state_unit, units)
return {key: convert(value) if convert else value for key, value in result.items()}
if not convert:
return result
return {key: convert(value) for key, value in result.items()}
_type_column_mapping = {