From e651a06e3ad632d707f7576bee33b3254f5c9ad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Sun, 14 Nov 2021 23:42:26 +0100 Subject: [PATCH] Return instead of raise ValueError (#2290) --- custom_components/hacs/hacsbase/hacs.py | 2 +- tests/hacsbase/test_hacs.py | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/custom_components/hacs/hacsbase/hacs.py b/custom_components/hacs/hacsbase/hacs.py index 2b5b84d9535..89dc3bfa5b7 100644 --- a/custom_components/hacs/hacsbase/hacs.py +++ b/custom_components/hacs/hacsbase/hacs.py @@ -63,7 +63,7 @@ def async_set_repository_id(self, repository, repo_id): def async_add_repository(self, repository): """Add a repository to the list.""" if repository.data.full_name_lower in self._repositories_by_full_name: - raise ValueError(f"The repo {repository.data.full_name_lower} is already added") + return self._repositories.append(repository) repo_id = str(repository.data.id) if repo_id != "0": diff --git a/tests/hacsbase/test_hacs.py b/tests/hacsbase/test_hacs.py index ceb5d7d064c..7cdaa7b5b85 100644 --- a/tests/hacsbase/test_hacs.py +++ b/tests/hacsbase/test_hacs.py @@ -35,9 +35,6 @@ async def test_add_remove_repository(hacs, repository, tmpdir): repository.data.id = "0" hacs.async_add_repository(repository) - with pytest.raises(ValueError): - hacs.async_add_repository(repository) - hacs.async_set_repository_id(repository, "42") # Once its set, it should never change