diff --git a/custom_components/hacs/helpers/functions/misc.py b/custom_components/hacs/helpers/functions/misc.py index 85ff848f001..83bd56cd753 100644 --- a/custom_components/hacs/helpers/functions/misc.py +++ b/custom_components/hacs/helpers/functions/misc.py @@ -1,6 +1,7 @@ """Helper functions: misc""" import re import semantic_version +from functools import lru_cache RE_REPOSITORY = re.compile( r"(?:(?:.*github.com.)|^)([A-Za-z0-9-]+\/[\w.-]+?)(?:(?:\.git)?|(?:[^\w.-].*)?)$" @@ -26,6 +27,7 @@ def get_repository_name(repository) -> str: ) +@lru_cache(maxsize=1024) def version_left_higher_then_right(new: str, old: str) -> bool: """Return a bool if source is newer than target, will also be true if identical.""" if not isinstance(new, str) or not isinstance(old, str): diff --git a/tests/helpers/misc/test_version_is_newer_than_version.py b/tests/helpers/misc/test_version_is_newer_than_version.py index 774fb02ce1b..88190e2c008 100644 --- a/tests/helpers/misc/test_version_is_newer_than_version.py +++ b/tests/helpers/misc/test_version_is_newer_than_version.py @@ -27,4 +27,4 @@ def test_wierd_stuff(): assert version_left_higher_then_right("1.0.0", "1.0.0rc0") assert not version_left_higher_then_right(None, "1.0.0rc0") assert not version_left_higher_then_right(1.0, "1.0.0rc0") - assert not version_left_higher_then_right({}, "1.0.0rc0") + assert not version_left_higher_then_right("0", "1.0.0rc0")