From e30c283fd8b2ea95a71279309620811ce6cc6b79 Mon Sep 17 00:00:00 2001 From: MSL Date: Fri, 10 Apr 2026 08:49:35 -0700 Subject: [PATCH] style: ruff format Co-Authored-By: Claude Opus 4.6 (1M context) --- mempalace/dedup.py | 8 +++----- mempalace/repair.py | 9 +++------ tests/test_dedup.py | 10 ++++++++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/mempalace/dedup.py b/mempalace/dedup.py index cf0dfaf..c2f9f6b 100644 --- a/mempalace/dedup.py +++ b/mempalace/dedup.py @@ -42,6 +42,7 @@ def _get_palace_path(): """Resolve palace path from config.""" try: from .config import MempalaceConfig + return MempalaceConfig().palace_path except Exception: return os.path.join(os.path.expanduser("~"), ".mempalace", "palace") @@ -143,9 +144,7 @@ def show_stats(palace_path=None): for src, ids in sorted_groups[:15]: print(f" {len(ids):4d} {src[:65]}") - estimated_dups = sum( - int(len(ids) * 0.4) for ids in groups.values() if len(ids) > 20 - ) + estimated_dups = sum(int(len(ids) * 0.4) for ids in groups.values() if len(ids) > 20) print(f"\n Estimated duplicates (groups > 20): ~{estimated_dups:,}") @@ -201,8 +200,7 @@ def dedup_palace( print(f"\n{'─' * 55}") print(f" Done in {elapsed:.1f}s") print( - f" Drawers: {total_kept + total_deleted:,} → {total_kept:,} " - f"(-{total_deleted:,} removed)" + f" Drawers: {total_kept + total_deleted:,} → {total_kept:,} (-{total_deleted:,} removed)" ) print(f" Palace after: {col.count():,} drawers") diff --git a/mempalace/repair.py b/mempalace/repair.py index 150c4ec..d51be60 100644 --- a/mempalace/repair.py +++ b/mempalace/repair.py @@ -42,6 +42,7 @@ def _get_palace_path(): """Resolve palace path from config.""" try: from .config import MempalaceConfig + return MempalaceConfig().palace_path except Exception: default = os.path.join(os.path.expanduser("~"), ".mempalace", "palace") @@ -244,9 +245,7 @@ def rebuild_index(palace_path=None): all_metas = [] offset = 0 while offset < total: - batch = col.get( - limit=batch_size, offset=offset, include=["documents", "metadatas"] - ) + batch = col.get(limit=batch_size, offset=offset, include=["documents", "metadatas"]) if not batch["ids"]: break all_ids.extend(batch["ids"]) @@ -266,9 +265,7 @@ def rebuild_index(palace_path=None): # Rebuild with correct HNSW settings print(" Rebuilding collection with hnsw:space=cosine...") client.delete_collection(COLLECTION_NAME) - new_col = client.create_collection( - COLLECTION_NAME, metadata={"hnsw:space": "cosine"} - ) + new_col = client.create_collection(COLLECTION_NAME, metadata={"hnsw:space": "cosine"}) filed = 0 for i in range(0, len(all_ids), batch_size): diff --git a/tests/test_dedup.py b/tests/test_dedup.py index 1e0ab99..2ddffb3 100644 --- a/tests/test_dedup.py +++ b/tests/test_dedup.py @@ -128,7 +128,10 @@ def test_dedup_source_group_with_duplicate(): col = MagicMock() col.get.return_value = { "ids": ["d1", "d2"], - "documents": ["long document content that is fairly long", "long document content that is fairly long"], + "documents": [ + "long document content that is fairly long", + "long document content that is fairly long", + ], "metadatas": [{"wing": "a"}, {"wing": "a"}], } col.query.return_value = { @@ -181,7 +184,10 @@ def test_dedup_source_group_query_failure_keeps(): col = MagicMock() col.get.return_value = { "ids": ["d1", "d2"], - "documents": ["long document one content here enough", "long document two content here enough"], + "documents": [ + "long document one content here enough", + "long document two content here enough", + ], "metadatas": [{"wing": "a"}, {"wing": "a"}], } col.query.side_effect = Exception("query failed")