From 6061e8f2def138861d7631a83b0a215b276763a3 Mon Sep 17 00:00:00 2001 From: Andy Lee Date: Wed, 6 Aug 2025 22:53:40 -0700 Subject: [PATCH] fix: format test files with latest ruff version for CI compatibility --- tests/test_diskann_partition.py | 48 ++++++++++++++++----------------- tests/test_readme_examples.py | 6 ++--- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/tests/test_diskann_partition.py b/tests/test_diskann_partition.py index 8cbff25..5b3d5f0 100644 --- a/tests/test_diskann_partition.py +++ b/tests/test_diskann_partition.py @@ -71,9 +71,9 @@ def test_diskann_without_partition(): for partition_file in partition_files: file_path = index_dir / partition_file - assert ( - not file_path.exists() - ), f"Partition file {partition_file} should not exist in non-partition mode" + assert not file_path.exists(), ( + f"Partition file {partition_file} should not exist in non-partition mode" + ) # Test search functionality searcher = LeannSearcher(index_path) @@ -137,9 +137,9 @@ def test_diskann_with_partition(): for large_file in large_files: file_path = index_dir / large_file - assert ( - not file_path.exists() - ), f"Large file {large_file} should have been deleted for storage saving" + assert not file_path.exists(), ( + f"Large file {large_file} should have been deleted for storage saving" + ) # Verify required auxiliary files for partition mode exist required_files = [ @@ -149,9 +149,9 @@ def test_diskann_with_partition(): for req_file in required_files: file_path = index_dir / req_file - assert ( - file_path.exists() - ), f"Required auxiliary file {req_file} missing for partition mode" + assert file_path.exists(), ( + f"Required auxiliary file {req_file} missing for partition mode" + ) @pytest.mark.skipif( @@ -203,21 +203,21 @@ def test_diskann_partition_search_functionality(): # Verify search results assert len(results) == top_k, f"Expected {top_k} results for query '{query}'" - assert all( - result.score is not None for result in results - ), "All results should have scores" - assert all( - result.score != float("-inf") for result in results - ), "No result should have -inf score" - assert all( - result.text is not None for result in results - ), "All results should have text" + assert all(result.score is not None for result in results), ( + "All results should have scores" + ) + assert all(result.score != float("-inf") for result in results), ( + "No result should have -inf score" + ) + assert all(result.text is not None for result in results), ( + "All results should have text" + ) # Scores should be in descending order (higher similarity first) scores = [result.score for result in results] - assert scores == sorted( - scores, reverse=True - ), "Results should be sorted by score descending" + assert scores == sorted(scores, reverse=True), ( + "Results should be sorted by score descending" + ) @pytest.mark.skipif( @@ -286,9 +286,9 @@ def test_diskann_medoid_and_norm_files(): # Verify that scores are not -inf (which indicates norm file was loaded correctly) assert len(results) > 0 - assert all( - result.score != float("-inf") for result in results - ), "Scores should not be -inf when norm file is correct" + assert all(result.score != float("-inf") for result in results), ( + "Scores should not be -inf when norm file is correct" + ) @pytest.mark.skipif( diff --git a/tests/test_readme_examples.py b/tests/test_readme_examples.py index 5770f81..fe69e4a 100644 --- a/tests/test_readme_examples.py +++ b/tests/test_readme_examples.py @@ -53,9 +53,9 @@ def test_readme_basic_example(backend_name): # Verify search results assert len(results) > 0 assert isinstance(results[0], SearchResult) - assert results[0].score != float( - "-inf" - ), f"should return valid scores, got {results[0].score}" + assert results[0].score != float("-inf"), ( + f"should return valid scores, got {results[0].score}" + ) # The second text about banana-crocodile should be more relevant assert "banana" in results[0].text or "crocodile" in results[0].text