From dcaa4ac949da4f42a9d2a64d733d641b9734ca74 Mon Sep 17 00:00:00 2001 From: agessaman Date: Sun, 14 Jun 2026 15:50:03 -0700 Subject: [PATCH] Refactor contact trimming logic for improved readability by consolidating function calls into single lines. Update related test cases for consistency. --- repeater/web/companion_endpoints.py | 4 +--- tests/test_companion_settings.py | 8 ++------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/repeater/web/companion_endpoints.py b/repeater/web/companion_endpoints.py index 6a07c68..c99f52a 100644 --- a/repeater/web/companion_endpoints.py +++ b/repeater/web/companion_endpoints.py @@ -418,9 +418,7 @@ class CompanionAPIEndpoints: # that every other path honors. Trim favourite-aware (oldest non-favourites # first) so persisted contacts never exceed max_contacts. try: - removed = trim_companion_contacts_to_fit( - sqlite_handler, companion_hash, max_contacts - ) + removed = trim_companion_contacts_to_fit(sqlite_handler, companion_hash, max_contacts) except ValueError as exc: raise cherrypy.HTTPError( 409, diff --git a/tests/test_companion_settings.py b/tests/test_companion_settings.py index bd965dc..ebca62e 100644 --- a/tests/test_companion_settings.py +++ b/tests/test_companion_settings.py @@ -341,9 +341,7 @@ class TestImportRepeaterContactsCap: @classmethod def _bridge(cls, max_contacts): contacts = SimpleNamespace(max_contacts=max_contacts, loaded=None) - contacts.load_from_dicts = lambda records: setattr( - contacts, "loaded", list(records) - ) + contacts.load_from_dicts = lambda records: setattr(contacts, "loaded", list(records)) return SimpleNamespace(_companion_hash=cls._HASH, contacts=contacts) def test_import_over_cap_trims_to_fit(self, tmp_path): @@ -396,9 +394,7 @@ class TestImportRepeaterContactsCap: import cherrypy h = self._handler(tmp_path) - self._save_contacts( - h, [self._contact(i, flags=1, lastmod=i) for i in range(51)] - ) + self._save_contacts(h, [self._contact(i, flags=1, lastmod=i) for i in range(51)]) self._seed_adverts(h, 1) bridge = self._bridge(max_contacts=50) ep = self._endpoint(h, bridge, {"companion_name": "c"})