Skip to content

Commit 0804246

Browse files
author
Daniele Briggi
committed
feat(dev): pre-commit
1 parent 148b6e8 commit 0804246

File tree

12 files changed

+50
-16
lines changed

12 files changed

+50
-16
lines changed

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use the same version of tools installed in the IDE
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v6.0.0
5+
hooks:
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
- id: detect-private-key
9+
- id: check-merge-conflict
10+
- repo: https://github.com/psf/black
11+
rev: 25.1.0
12+
hooks:
13+
- id: black
14+
- repo: https://github.com/pycqa/isort
15+
rev: 6.0.1
16+
hooks:
17+
- id: isort
18+
args: ["--profile", "black", "--filter-files"]
19+
- repo: https://github.com/pycqa/flake8
20+
rev: 7.3.0
21+
hooks:
22+
- id: flake8
23+
- repo: https://github.com/PyCQA/bandit
24+
rev: 1.8.6
25+
hooks:
26+
- id: bandit
27+
args: ["--configfile", "bandit.yaml"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# sqlite-rag
1+
# sqlite-rag

bandit.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://bndit.readthedocs.io/en/latest/config.html
2+
skips: ['B101']
3+
exclude_dirs: ['tests']

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ dev = [
2121
"pytest-cov",
2222
"black",
2323
"flake8",
24+
"bandit",
25+
"isort",
26+
"pre-commit"
2427
]
2528

2629
[project.scripts]
@@ -41,4 +44,4 @@ testpaths = [
4144
]
4245
pythonpath = [
4346
"src"
44-
]
47+
]

src/sqlite_rag/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
"""
22
SQLite RAG - Hybrid search with SQLite AI and SQLite Vector
33
4-
This package provides both a library interface and CLI for document
4+
This package provides both a library interface and CLI for document
55
indexing and semantic search using SQLite with AI and vector extensions.
66
"""
77

8-
from .sqliterag import SQLiteRag
9-
from .models.document import Document
108
from .models.chunk import Chunk
9+
from .models.document import Document
1110
from .settings import Settings
11+
from .sqliterag import SQLiteRag
1212

1313
__version__ = "0.1.0"
1414
__all__ = [
1515
"SQLiteRag",
16-
"Document",
16+
"Document",
1717
"Chunk",
1818
"Settings",
19-
]
19+
]

src/sqlite_rag/chunker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import math
12
import sqlite3
23
from typing import List
34

45
from .models.chunk import Chunk
56
from .settings import Settings
6-
import math
77

88

99
class Chunker:
@@ -23,7 +23,7 @@ def _get_token_count(self, text: str) -> int:
2323
if text == "":
2424
return 0
2525
cursor = self._conn.execute("SELECT llm_token_count(?) AS count", (text,))
26-
return cursor.fetchone()['count']
26+
return cursor.fetchone()["count"]
2727

2828
def _estimate_tokens_count(self, text: str) -> int:
2929
"""Estimate token count more conservatively."""

src/sqlite_rag/models/chunk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
class Chunk:
66
id: int | None = None
77
document_id: int | None = None
8-
content: str = ''
9-
embedding: str | bytes = b''
8+
content: str = ""
9+
embedding: str | bytes = b""

src/sqlite_rag/models/document.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from datetime import datetime
21
import hashlib
2+
from datetime import datetime
33

44
from attr import dataclass
55

src/sqlite_rag/reader.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ def is_supported(path: Path) -> bool:
4848
def parse_file(path: Path) -> str:
4949
try:
5050
converter = MarkItDown()
51-
return converter.convert(path, stream_info=StreamInfo(charset='utf8')).text_content
51+
return converter.convert(
52+
path, stream_info=StreamInfo(charset="utf8")
53+
).text_content
5254
except Exception as exc:
5355
raise ValueError(f"Failed to parse file {path}") from exc
5456

src/sqlite_rag/settings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ def __init__(self, model_path_or_name: str, db_path: str = "sqliterag.db"):
1212
self.chunk_overlap = 32 # Token overlap between chunks
1313

1414
self.quantize_scan = True # Whether to quantize the vector for faster search
15-

0 commit comments

Comments
 (0)