From f0abfea55d7b58ed21432eec5d62676aa29c43ea Mon Sep 17 00:00:00 2001 From: cachho Date: Thu, 10 Aug 2023 22:23:42 +0200 Subject: [PATCH] chore: linting (#414) --- embedchain/config/apps/CustomAppConfig.py | 3 +-- embedchain/data_formatter/data_formatter.py | 3 ++- embedchain/utils.py | 6 +++--- tests/vectordb/test_chroma_db.py | 9 +++++---- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/embedchain/config/apps/CustomAppConfig.py b/embedchain/config/apps/CustomAppConfig.py index edacf4b5..cc42f85a 100644 --- a/embedchain/config/apps/CustomAppConfig.py +++ b/embedchain/config/apps/CustomAppConfig.py @@ -52,8 +52,7 @@ class CustomAppConfig(BaseAppConfig): super().__init__( log_level=log_level, embedding_fn=CustomAppConfig.embedding_function( - embedding_function=embedding_fn, model=embedding_fn_model, - deployment_name=deployment_name + embedding_function=embedding_fn, model=embedding_fn_model, deployment_name=deployment_name ), db=db, host=host, diff --git a/embedchain/data_formatter/data_formatter.py b/embedchain/data_formatter/data_formatter.py index f8834828..4edb0f69 100644 --- a/embedchain/data_formatter/data_formatter.py +++ b/embedchain/data_formatter/data_formatter.py @@ -46,12 +46,13 @@ class DataFormatter: "sitemap": SitemapLoader(), "docs_site": DocsSiteLoader(), } - lazy_loaders = ("notion", ) + lazy_loaders = ("notion",) if data_type in loaders: return loaders[data_type] elif data_type in lazy_loaders: if data_type == "notion": from embedchain.loaders.notion import NotionLoader + return NotionLoader() else: raise ValueError(f"Unsupported data type: {data_type}") diff --git a/embedchain/utils.py b/embedchain/utils.py index 5b7cfa60..2afae191 100644 --- a/embedchain/utils.py +++ b/embedchain/utils.py @@ -65,7 +65,7 @@ def use_pysqlite3(): import datetime import subprocess import sys - + subprocess.check_call( [sys.executable, "-m", "pip", "install", "pysqlite3-binary", "--quiet", "--disable-pip-version-check"] ) @@ -86,6 +86,6 @@ def use_pysqlite3(): print( f"{current_time} [embedchain] [ERROR]", "Failed to swap std-lib sqlite3 with pysqlite3 for ChromaDb compatibility.", - f"Error:", - e + "Error:", + e, ) diff --git a/tests/vectordb/test_chroma_db.py b/tests/vectordb/test_chroma_db.py index 9ddff085..37a62d57 100644 --- a/tests/vectordb/test_chroma_db.py +++ b/tests/vectordb/test_chroma_db.py @@ -73,6 +73,7 @@ class TestChromaDbHostsLoglevel(unittest.TestCase): self.assertEqual(mock_client.call_args[0][0].chroma_server_host, None) self.assertEqual(mock_client.call_args[0][0].chroma_server_http_port, None) + class TestChromaDbDuplicateHandling: def test_duplicates_throw_warning(self, caplog): """ @@ -101,8 +102,8 @@ class TestChromaDbDuplicateHandling: app.collection.add(embeddings=[[0, 0, 0]], ids=["0"]) app.set_collection("test_collection_2") app.collection.add(embeddings=[[0, 0, 0]], ids=["0"]) - assert "Insert of existing embedding ID: 0" not in caplog.text # not - assert "Add of existing embedding ID: 0" not in caplog.text # not + assert "Insert of existing embedding ID: 0" not in caplog.text # not + assert "Add of existing embedding ID: 0" not in caplog.text # not class TestChromaDbCollection(unittest.TestCase): @@ -197,9 +198,9 @@ class TestChromaDbCollection(unittest.TestCase): app2.collection.add(embeddings=[0, 0, 0], ids=["0"]) # Swap names and test - app1.set_collection('test_collection_2') + app1.set_collection("test_collection_2") self.assertEqual(app1.count(), 1) - app2.set_collection('test_collection_1') + app2.set_collection("test_collection_1") self.assertEqual(app2.count(), 3) def test_ids_share_collections(self):