Skip to content

Commit 5cdc469

Browse files
authored
add lint and format check action (#1)
* add lint and format check action * fix imports * add check command to ruff * fix ruff errors
1 parent 8022ec7 commit 5cdc469

File tree

9 files changed

+43
-11
lines changed

9 files changed

+43
-11
lines changed

.github/workflows/lint.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Lint and format checks
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.12"
16+
17+
- name: Install tools
18+
run: |
19+
pip install black isort ruff
20+
21+
- name: Run Black
22+
run: black --check .
23+
24+
- name: Run Isort
25+
run: isort --check-only .
26+
27+
- name: Run Ruff
28+
run: ruff check .

loaders/pdf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
import logging
12
from pathlib import Path
23
from typing import List
34

4-
from config import Config
55
from langchain.text_splitter import RecursiveCharacterTextSplitter
6-
from langchain_core.documents import Document
76
from langchain_community.document_loaders import PyPDFLoader
7+
from langchain_core.documents import Document
88

9-
import logging
9+
from config import Config
1010

1111
logger = logging.getLogger(__name__)
1212

loaders/web.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
import logging
12
from typing import List
23

3-
from pathlib import Path
4-
from langchain_core.documents import Document
54
from langchain.text_splitter import RecursiveCharacterTextSplitter
65
from langchain_community.document_loaders import WebBaseLoader
6+
from langchain_core.documents import Document
77

88
from config import Config
9-
import logging
109

1110
logger = logging.getLogger(__name__)
1211

@@ -55,7 +54,7 @@ def load(self, urls: List[str]) -> List[Document]:
5554
try:
5655
loader = WebBaseLoader(urls)
5756
docs = loader.load()
58-
except Exception as e:
57+
except Exception:
5958
logger.exception("Failed to load URLs via WebBaseLoader")
6059
raise
6160

vector_db/db_provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from abc import ABC, abstractmethod
22
from typing import List
33

4-
from langchain_huggingface import HuggingFaceEmbeddings
54
from langchain_core.documents import Document
65
from langchain_core.embeddings import Embeddings
6+
from langchain_huggingface import HuggingFaceEmbeddings
77

88

99
class DBProvider(ABC):

vector_db/dryrun_provider.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from typing import List
2+
23
from langchain_core.documents import Document
4+
35
from vector_db.db_provider import DBProvider
46

57

vector_db/elastic_provider.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing import List
2+
23
from langchain_core.documents import Document
34
from langchain_elasticsearch.vectorstores import ElasticsearchStore
45

vector_db/pgvector_provider.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from typing import List
2-
from langchain_postgres import PGVector
2+
33
from langchain_core.documents import Document
4+
from langchain_postgres import PGVector
5+
46
from vector_db.db_provider import DBProvider
57

68

vector_db/redis_provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(self, url: str, index: str, schema: str):
4141
try:
4242
self.redis_client = redis.from_url(self.url)
4343
self.redis_client.ping()
44-
except Exception as e:
44+
except Exception:
4545
logger.exception("Failed to connect to Redis at %s", self.url)
4646
raise
4747

vector_db/sqlserver_provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,6 @@ def add_documents(self, docs: List[Document]) -> None:
107107
batch = docs[i : i + batch_size]
108108
try:
109109
self.db.add_documents(batch)
110-
except Exception as e:
110+
except Exception:
111111
logger.exception("Failed to insert batch starting at index %s", i)
112112
raise

0 commit comments

Comments
 (0)