Skip to content

Commit 03d14a9

Browse files
committed
Add lint/format checks using ruff
1 parent 5dc7d55 commit 03d14a9

File tree

5 files changed

+67
-107
lines changed

5 files changed

+67
-107
lines changed

.github/workflows/test.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,29 @@ permissions:
66
contents: read
77

88
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up Python
14+
uses: actions/setup-python@v5
15+
with:
16+
python-version: "3.12"
17+
cache: pip
18+
cache-dependency-path: pyproject.toml
19+
- name: Install dependencies
20+
run: |
21+
pip install -e '.[dev]'
22+
- name: Run ruff linter
23+
run: |
24+
ruff check .
25+
- name: Run ruff formatter
26+
run: |
27+
ruff format --check .
28+
929
test:
1030
runs-on: ubuntu-latest
31+
needs: lint
1132
strategy:
1233
matrix:
1334
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

llm_tools_searxng.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ def search(
5959
# TODO: Set user agent?
6060
headers = None
6161

62-
with httpx.Client(
63-
follow_redirects=True, timeout=30.0, headers=headers
64-
) as client:
62+
with httpx.Client(follow_redirects=True, timeout=30.0, headers=headers) as client:
6563
if self.method == "POST":
6664
response = client.post(search_url, data=params)
6765
else:

pyproject.toml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ build-backend = "setuptools.build_meta"
1818

1919
[dependency-groups]
2020
dev = [
21-
"black>=25.1.0",
22-
"isort>=6.0.1",
21+
"ruff>=0.11.12",
2322
]
2423

2524
[project.urls]
@@ -33,3 +32,16 @@ llm_tools_searxng = "llm_tools_searxng"
3332

3433
[project.optional-dependencies]
3534
test = ["pytest", "llm-echo>=0.3a1", "pytest-httpx"]
35+
36+
[tool.ruff]
37+
line-length = 120
38+
target-version = "py39"
39+
40+
[tool.ruff.lint]
41+
ignore = []
42+
43+
[tool.ruff.format]
44+
quote-style = "double"
45+
indent-style = "space"
46+
skip-magic-trailing-comma = false
47+
line-ending = "auto"

tests/test_llm_tools_searxng.py

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import json
2-
import os
32

43
import llm
5-
import pytest
64

75
from llm_tools_searxng import SearXNG, searxng_search
86

@@ -33,13 +31,7 @@ def test_searxng_search_function_get(httpx_mock, monkeypatch):
3331

3432
model = llm.get_model("echo")
3533
chain_response = model.chain(
36-
json.dumps(
37-
{
38-
"tool_calls": [
39-
{"name": "searxng_search", "arguments": {"query": "test query"}}
40-
]
41-
}
42-
),
34+
json.dumps({"tool_calls": [{"name": "searxng_search", "arguments": {"query": "test query"}}]}),
4335
tools=[searxng_search],
4436
)
4537
responses = list(chain_response.responses())
@@ -69,19 +61,11 @@ def test_searxng_search_function_post(httpx_mock, monkeypatch):
6961
}
7062
],
7163
}
72-
httpx_mock.add_response(
73-
url="https://searx.be/search", json=mock_response, method="POST"
74-
)
64+
httpx_mock.add_response(url="https://searx.be/search", json=mock_response, method="POST")
7565

7666
model = llm.get_model("echo")
7767
chain_response = model.chain(
78-
json.dumps(
79-
{
80-
"tool_calls": [
81-
{"name": "searxng_search", "arguments": {"query": "test query"}}
82-
]
83-
}
84-
),
68+
json.dumps({"tool_calls": [{"name": "searxng_search", "arguments": {"query": "test query"}}]}),
8569
tools=[searxng_search],
8670
)
8771
responses = list(chain_response.responses())
@@ -139,9 +123,7 @@ def test_searxng_class_direct_post_default(httpx_mock):
139123
}
140124
],
141125
}
142-
httpx_mock.add_response(
143-
url="https://custom.searxng.com/search", json=mock_response, method="POST"
144-
)
126+
httpx_mock.add_response(url="https://custom.searxng.com/search", json=mock_response, method="POST")
145127

146128
# Test the SearXNG class directly without setting method (should default to POST)
147129
searxng = SearXNG("https://custom.searxng.com")

uv.lock

Lines changed: 27 additions & 80 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)