Skip to content

Commit 42185eb

Browse files
[FIX] Pre-commit fixes (#65)
Precommit fixes Signed-off-by: Deepak <[email protected]>
1 parent 5ca4c82 commit 42185eb

File tree

8 files changed

+16
-34
lines changed

8 files changed

+16
-34
lines changed

src/unstract/adapters/adapterkit.py

+6-12
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,14 @@ def adapters(self) -> AdapterDict:
3434

3535
def get_adapter_class_by_adapter_id(self, adapter_id: str) -> Adapter:
3636
if adapter_id in self._adapters:
37-
adapter_class: Adapter = self._adapters[adapter_id][
38-
Common.METADATA
39-
][Common.ADAPTER]
37+
adapter_class: Adapter = self._adapters[adapter_id][Common.METADATA][
38+
Common.ADAPTER
39+
]
4040
return adapter_class
4141
else:
4242
raise RuntimeError(f"Couldn't obtain adapter for {adapter_id}")
4343

44-
def get_adapter_by_id(
45-
self, adapter_id: str, *args: Any, **kwargs: Any
46-
) -> Adapter:
44+
def get_adapter_by_id(self, adapter_id: str, *args: Any, **kwargs: Any) -> Adapter:
4745
"""Instantiates and returns a adapter.
4846
4947
Args:
@@ -55,17 +53,13 @@ def get_adapter_by_id(
5553
Returns:
5654
Adapter: Concrete impl of the `Adapter` base
5755
"""
58-
adapter_class: Adapter = self.get_adapter_class_by_adapter_id(
59-
adapter_id
60-
)
56+
adapter_class: Adapter = self.get_adapter_class_by_adapter_id(adapter_id)
6157
return adapter_class(*args, **kwargs)
6258

6359
def get_adapters_list(self) -> list[dict[str, Any]]:
6460
adapters = []
6561
for adapter_id, adapter_registry_metadata in self._adapters.items():
66-
m: Adapter = adapter_registry_metadata[Common.METADATA][
67-
Common.ADAPTER
68-
]
62+
m: Adapter = adapter_registry_metadata[Common.METADATA][Common.ADAPTER]
6963
_id = m.get_id()
7064
name = m.get_name()
7165
adapter_type = m.get_adapter_type().name

src/unstract/adapters/registry.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import logging
2-
from typing import Any
31
from abc import ABC, abstractmethod
2+
from typing import Any
3+
44

55
class AdapterRegistry(ABC):
66

Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from unstract.adapters import AdapterDict
22
from unstract.adapters.vectordb.register import VectorDBRegistry
33

4-
54
adapters: AdapterDict = {}
65
VectorDBRegistry.register_adapters(adapters)

src/unstract/adapters/vectordb/postgres/src/postgres.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
2-
from urllib.parse import quote_plus
32
from typing import Any, Optional
3+
from urllib.parse import quote_plus
44

55
import psycopg2
66
from llama_index.core.vector_stores.types import BasePydanticVectorStore
@@ -59,9 +59,7 @@ def get_vector_db_instance(self) -> BasePydanticVectorStore:
5959

6060
def _get_vector_db_instance(self) -> BasePydanticVectorStore:
6161
try:
62-
encoded_password = quote_plus(
63-
str(self._config.get(Constants.PASSWORD))
64-
)
62+
encoded_password = quote_plus(str(self._config.get(Constants.PASSWORD)))
6563
dimension = self._config.get(
6664
VectorDbConstants.EMBEDDING_DIMENSION,
6765
VectorDbConstants.DEFAULT_EMBEDDING_SIZE,

src/unstract/adapters/vectordb/supabase/src/supabase.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
from typing import Any, Optional
33
from urllib.parse import quote_plus
4+
45
from llama_index.core.vector_stores.types import VectorStore
56
from llama_index.vector_stores.supabase import SupabaseVectorStore
67
from vecs import Client
@@ -70,9 +71,7 @@ def _get_vector_db_instance(self) -> VectorStore:
7071
)
7172
user = str(self._config.get(Constants.USER))
7273
password = str(self._config.get(Constants.PASSWORD))
73-
encoded_password = quote_plus(
74-
str(password)
75-
)
74+
encoded_password = quote_plus(str(password))
7675
host = str(self._config.get(Constants.HOST))
7776
port = str(self._config.get(Constants.PORT))
7877
db_name = str(self._config.get(Constants.DATABASE))

src/unstract/adapters/x2text/helper.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ class UnstructuredHelper:
4949
PROCESS = "process"
5050

5151
@staticmethod
52-
def test_server_connection(
53-
unstructured_adapter_config: dict[str, Any]
54-
) -> bool:
52+
def test_server_connection(unstructured_adapter_config: dict[str, Any]) -> bool:
5553
UnstructuredHelper.make_request(
5654
unstructured_adapter_config, UnstructuredHelper.TEST_CONNECTION
5755
)
@@ -66,9 +64,7 @@ def process_document(
6664
try:
6765
response: Response
6866
with open(input_file_path, "rb") as input_f:
69-
mime_type = AdapterUtils.get_file_mime_type(
70-
input_file=input_file_path
71-
)
67+
mime_type = AdapterUtils.get_file_mime_type(input_file=input_file_path)
7268
files = {"file": (input_file_path, input_f, mime_type)}
7369
response = UnstructuredHelper.make_request(
7470
unstructured_adapter_config=unstructured_adapter_config,
@@ -95,9 +91,7 @@ def make_request(
9591
request_type: str,
9692
**kwargs: dict[Any, Any],
9793
) -> Response:
98-
unstructured_url = unstructured_adapter_config.get(
99-
UnstructuredHelper.URL
100-
)
94+
unstructured_url = unstructured_adapter_config.get(UnstructuredHelper.URL)
10195

10296
x2text_service_url = unstructured_adapter_config.get(
10397
X2TextConstants.X2TEXT_HOST
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
from .llama_parse import LlamaParseAdapter
22

3-
43
metadata = {
54
"name": LlamaParseAdapter.__name__,
65
"version": "1.0.0",
76
"adapter": LlamaParseAdapter,
87
"description": "LlamaParse X2Text adapter",
98
"is_active": True,
10-
}
9+
}

src/unstract/adapters/x2text/llama_parse/src/constants.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ class LlamaParseConfig:
77
NUM_WORKERS = "num_workers"
88
VERBOSE = "verbose"
99
LANGUAGE = "language"
10-

0 commit comments

Comments
 (0)