From f3a690f3f13a1381c79a787d5f2fa3b6f682a082 Mon Sep 17 00:00:00 2001 From: daiyu Date: Tue, 20 Oct 2026 00:05:42 +0800 Subject: [PATCH] ci(lint): add a lint job and fix the two open ruff findings on main Closes #103 - llmsql/_cli/llmsql_cli.py: sort the two llmsql._cli imports (I001) and separate the class from them with two blank lines - llmsql/inference/inference_api.py: zip(questions, prompts) silently dropped the tail whenever the two lists had different lengths; pass strict=True (B905) - llmsql/_cli/inference.py: ruff format (the only change is wrapping one parser.add_argument call) - .github/workflows/tests.yml: new lint job running ruff check and ruff format --check on 3.10-3.13, pinned to ruff 0.8.4, the revision in .pre-commit-config.yaml. The matrix matters because the lint rules include UP (pyupgrade), whose findings depend on the target Python version. - .github/workflows/docs.yml: actions/setup-python v4 -> v5 --- .github/workflows/docs.yml | 2 +- .github/workflows/tests.yml | 29 +++++++++++++++++++++++++++++ llmsql/_cli/inference.py | 4 +++- llmsql/_cli/llmsql_cli.py | 3 ++- llmsql/inference/inference_api.py | 5 +++-- 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index e2d3d9c..3f4756a 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.11" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c48216c..d3721e1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,6 +6,35 @@ on: pull_request: jobs: + lint: + # `pre-commit run --all-files` is not enforced anywhere, so `ruff check llmsql` + # has been failing on main. Run the same ruff version as .pre-commit-config.yaml + # (v0.8.4) on every supported interpreter: the lint rules include `UP` + # (pyupgrade), whose findings depend on the target Python version. + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.10", "3.11", "3.12", "3.13"] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install ruff + run: pip install "ruff==0.8.4" + + - name: Lint + run: ruff check llmsql + + - name: Check formatting + run: ruff format --check llmsql + test: runs-on: ubuntu-latest diff --git a/llmsql/_cli/inference.py b/llmsql/_cli/inference.py index 919ced4..46a40aa 100644 --- a/llmsql/_cli/inference.py +++ b/llmsql/_cli/inference.py @@ -176,7 +176,9 @@ def _add_args(self) -> None: # COMMON BENCHMARK ARGS # ========================= def add_common_benchmark_args(parser: argparse.ArgumentParser) -> None: - parser.add_argument("--version", default="2.0", choices=get_available_versions()) + parser.add_argument( + "--version", default="2.0", choices=get_available_versions() + ) parser.add_argument("--output-file", default="llm_sql_predictions.jsonl") parser.add_argument( "--workdir-path", diff --git a/llmsql/_cli/llmsql_cli.py b/llmsql/_cli/llmsql_cli.py index c08e148..5fb54b0 100644 --- a/llmsql/_cli/llmsql_cli.py +++ b/llmsql/_cli/llmsql_cli.py @@ -1,8 +1,9 @@ import argparse import textwrap -from llmsql._cli.inference import Inference from llmsql._cli.evaluate import Evaluate +from llmsql._cli.inference import Inference + class ParserCLI: """Main CLI parser that manages all subcommands.""" diff --git a/llmsql/inference/inference_api.py b/llmsql/inference/inference_api.py index 7746cb7..29d10ba 100644 --- a/llmsql/inference/inference_api.py +++ b/llmsql/inference/inference_api.py @@ -116,7 +116,6 @@ async def _inference_api_async( write_lock = asyncio.Lock() async with aiohttp.ClientSession(headers=headers) as session: - # Pre-build all prompts using the shared function prompts = build_all_requests(questions, tables, prompt_builder) @@ -152,7 +151,9 @@ async def process_question(q: dict[str, Any], prompt: str) -> dict[str, str]: return result - tasks = [process_question(q, p) for q, p in zip(questions, prompts)] + tasks = [ + process_question(q, p) for q, p in zip(questions, prompts, strict=True) + ] for coro in tqdm( asyncio.as_completed(tasks), total=len(tasks),