From d5bcf02a810cf5bb7a2e6edccb1484580aff9ca9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Mar 2026 12:52:31 +0000 Subject: [PATCH 1/7] Initial plan From 3721ef40e671ffc815874ffcdd8f5f3621be0e93 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Mar 2026 12:57:40 +0000 Subject: [PATCH 2/7] chore: migrate project config from Hatch envs to UV Co-authored-by: masci <7241+masci@users.noreply.github.com> --- AGENTS.md | 47 +++++++++++++++++++++++++---------------------- CONTRIBUTING.md | 37 ++++++++++++++++++++----------------- README.md | 1 - pyproject.toml | 44 +++++++++++--------------------------------- 4 files changed, 56 insertions(+), 73 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index dd94b8d..2108278 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -10,36 +10,39 @@ Banks is a Python prompt programming language and templating system for LLM appl ```bash # Most common commands -hatch run test # Run unit tests -hatch run lint:all # Run all linting checks -hatch run lint:fmt # Auto-format code -hatch run test tests/test_foo.py # Run specific test file +uv run pytest tests # Run unit tests +uv run ruff format --check && uv run ruff check . && uv run mypy --install-types --non-interactive src/banks && uv run pylint src/banks # Run all linting checks +uv run ruff format # Auto-format code +uv run pytest tests/test_foo.py # Run specific test file ``` ## Development Commands +### Setup +- Install dev dependencies: `uv sync --extra dev` + ### Testing -- Run tests: `hatch run test` -- Run tests with coverage: `hatch run test-cov` -- Generate coverage report: `hatch run cov` -- Run specific test file: `hatch run test tests/test_foo.py` -- Run e2e tests: `hatch run test tests/e2e/` (requires API keys) +- Run tests: `uv run pytest tests` +- Run tests with coverage: `uv run pytest --cov --cov-report=xml tests` +- Generate coverage report: `uv run pytest --cov --cov-report=xml tests && coverage combine && coverage report -m` +- Run specific test file: `uv run pytest tests/test_foo.py` +- Run e2e tests: `uv run pytest tests/e2e/` (requires API keys) ### Linting and Type Checking -- Format code: `hatch run lint:fmt` -- Auto-fix lint issues: `hatch run lint:fix` -- Check formatting: `hatch run lint:check` -- Run type checking: `hatch run lint:typing` -- Run pylint: `hatch run lint:lint` -- Run all lint checks: `hatch run lint:all` +- Format code: `uv run ruff format` +- Auto-fix lint issues: `uv run ruff check --fix` +- Check formatting: `uv run ruff format --check && uv run ruff check .` +- Run type checking: `uv run mypy --install-types --non-interactive src/banks` +- Run pylint: `uv run pylint src/banks` +- Run all lint checks: `uv run ruff format --check && uv run ruff check . && uv run mypy --install-types --non-interactive src/banks && uv run pylint src/banks` ### Documentation -- Build docs: `hatch run docs build` -- Serve docs locally: `hatch run docs serve` (available at http://127.0.0.1:8000/) +- Build docs: `uv run mkdocs build` +- Serve docs locally: `uv run mkdocs serve` (available at http://127.0.0.1:8000/) ### Environment Management -- All commands use Hatch environments with automatic dependency management -- Uses `uv` as the installer for faster dependency resolution +- Uses `uv` for dependency management and running tools +- Install all dev dependencies: `uv sync --extra dev` - Python 3.9+ supported (tested on 3.10-3.14) ## Architecture Overview @@ -157,9 +160,9 @@ hatch run test tests/test_foo.py # Run specific test file ### Running Specific Tests ```bash -hatch run test tests/test_image.py # Single file -hatch run test tests/test_image.py::test_name # Single test -hatch run test -k "image" # Tests matching pattern +uv run pytest tests/test_image.py # Single file +uv run pytest tests/test_image.py::test_name # Single test +uv run pytest -k "image" # Tests matching pattern ``` ## Code Style diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f0ce80a..111a643 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,35 +11,32 @@ be very happy about: - Refer this project in your project's readme - Mention the project at local meetups and tell your friends/colleagues -## Install Hatch +## Setup -Assuming you already have Python installed and it's at least on version 3.10, the first step is to install -[Hatch](https://hatch.pypa.io/1.9/). We'll use Hatch to manage the virtual environments that are needed to build the -project, the documentation and to run the tests. Depending on your operating system, there are different ways to -install Hatch: +Assuming you already have Python installed (version 3.10 or later), the recommended way to work on this project is +with [uv](https://docs.astral.sh/uv/). Install `uv` following the +[official instructions](https://docs.astral.sh/uv/getting-started/installation/), then install all development +dependencies with: -- `brew install hatch` on Mac -- The [GUI installer](https://hatch.pypa.io/1.9/install/#gui-installer_1) on Windows -- Or just `pip install hatch` - -The [official documentation for Hatch](https://hatch.pypa.io/1.9/install/) contains a thorough description of all the -available installation methods. +```sh +$ uv sync --extra dev +``` ## Run the tests -With Hatch installed, from the root of the repository running the tests is as simple as: +With `uv` installed, from the root of the repository running the tests is as simple as: ```sh -$ hatch run test +$ uv run pytest tests ``` -This command will activate the proper virtual environment, sync the required dependencies and invoke +This command will use the virtual environment managed by `uv`, sync the required dependencies and invoke [pytest](https://docs.pytest.org/en/stable/index.html). To see a recap of the test coverage and specifically which are the lines that are currently not tested, you can run: ```sh -$ hatch run cov +$ uv run pytest --cov --cov-report=xml tests && coverage combine && coverage report -m ``` ## Lint the code @@ -51,7 +48,13 @@ and used consistently across the codebase. To perform a comprehensive lint check just run: ```sh -$ hatch run lint:all +$ uv run ruff format --check && uv run ruff check . && uv run mypy --install-types --non-interactive src/banks && uv run pylint src/banks +``` + +To auto-format the code: + +```sh +$ uv run ruff format ``` > [!IMPORTANT] @@ -64,7 +67,7 @@ Any contribution to the documentation is very welcome, whether it's a fix for a new recipe in the cookbook. To preview the documentation locally, you can run: ```sh -$ hatch run docs serve +$ uv run mkdocs serve ``` and open the browser at the URL `http://127.0.0.1:8000/`. The documentation is built with diff --git a/README.md b/README.md index 5219a8a..f215c04 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ [![test](https://github.com/masci/banks/actions/workflows/test.yml/badge.svg)](https://github.com/masci/banks/actions/workflows/test.yml) [![docs](https://github.com/masci/banks/actions/workflows/docs.yml/badge.svg)](https://github.com/masci/banks/actions/workflows/docs.yml) -[![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/) [![License - MIT](https://img.shields.io/badge/license-MIT-9400d3.svg)](https://spdx.org/licenses/) diff --git a/pyproject.toml b/pyproject.toml index a6739c3..478dd8d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,18 +35,7 @@ dependencies = [ [project.optional-dependencies] all = ["litellm", "redis"] - -[project.urls] -Documentation = "https://github.com/masci/banks#readme" -Issues = "https://github.com/masci/banks/issues" -Source = "https://github.com/masci/banks" - -[tool.hatch.version] -path = "src/banks/__about__.py" - -[tool.hatch.envs.default] -installer = "uv" -dependencies = [ +dev = [ "coverage[toml]>=6.5", "pytest", "pytest-cov", @@ -57,29 +46,18 @@ dependencies = [ "eval-type-backport;python_version<'3.10'", "redis", "litellm", + "mypy>=1.0.0", + "ruff>=0.0.243", + "pylint", ] -[tool.hatch.envs.default.scripts] -test = "pytest {args:tests}" -test-cov = "pytest --cov --cov-report=xml {args:tests}" -cov-report = ["- coverage combine", "coverage report -m"] -cov = ["test-cov", "cov-report"] -docs = "mkdocs {args:build}" - -[[tool.hatch.envs.all.matrix]] -python = ["3.10", "3.11", "3.12", "3.13", "3.14"] - -[tool.hatch.envs.lint] -detached = false # Normally the linting env can be detached, but mypy doesn't install all the stubs we need -dependencies = ["mypy>=1.0.0", "ruff>=0.0.243", "pylint", "redis", "litellm"] - -[tool.hatch.envs.lint.scripts] -check = ["ruff format --check {args}", "ruff check {args:.}"] -lint = "pylint {args:src/banks}" -typing = "mypy --install-types --non-interactive {args:src/banks}" -all = ["check", "typing", "lint"] -fmt = "ruff format {args}" -fix = "ruff check --fix {args}" +[project.urls] +Documentation = "https://github.com/masci/banks#readme" +Issues = "https://github.com/masci/banks/issues" +Source = "https://github.com/masci/banks" + +[tool.hatch.version] +path = "src/banks/__about__.py" [tool.hatch.build.targets.wheel] only-include = ["src/banks", "src/templates"] From 59090f7df92a9acc4f11ad7f1883f828c083c88e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Mar 2026 13:06:31 +0000 Subject: [PATCH 3/7] chore: update CI workflows to use uv instead of hatch Co-authored-by: masci <7241+masci@users.noreply.github.com> --- .github/workflows/docs.yml | 9 ++++++--- .github/workflows/release.yml | 11 +++++------ .github/workflows/test.yml | 31 ++++++++++++++++++++----------- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 08567f6..ff9c81d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -18,7 +18,10 @@ jobs: with: python-version: '3.12' - - name: Install Hatch - run: pip install --upgrade hatch + - name: Install uv + uses: astral-sh/setup-uv@v5 - - run: hatch run mkdocs gh-deploy --force + - name: Sync dependencies + run: uv sync --extra dev + + - run: uv run mkdocs gh-deploy --force diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 37cc1ef..a86f8f3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,16 +60,15 @@ jobs: git tag "v${VERSION}" git push origin "v${VERSION}" - - name: Install Hatch - run: pip install hatch + - name: Install uv + uses: astral-sh/setup-uv@v5 - name: Publish on PyPi env: - HATCH_INDEX_USER: __token__ - HATCH_INDEX_AUTH: ${{ secrets.PYPI_API_TOKEN }} + UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }} run: | - hatch build - hatch publish -y + uv build + uv publish - name: Create GitHub Release uses: ncipollo/release-action@v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 02b7b21..e1674e4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,22 +44,25 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Install Hatch - run: pip install --upgrade hatch + - name: Install uv + uses: astral-sh/setup-uv@v5 + + - name: Sync dependencies + run: uv sync --extra dev - if: matrix.python-version == '3.13' name: Lint - run: hatch run lint:all + run: uv run ruff format --check && uv run ruff check . && uv run mypy --install-types --non-interactive src/banks && uv run pylint src/banks - name: Run tests - run: hatch run cov -m"not e2e" + run: uv run pytest --cov --cov-report=xml -m"not e2e" tests - if: matrix.python-version == '3.13' name: End-to-end env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} - run: hatch run test -m"e2e" + run: uv run pytest -m"e2e" tests - if: matrix.python-version == '3.13' name: Report Coveralls @@ -82,11 +85,14 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Install Hatch - run: pip install --upgrade hatch + - name: Install uv + uses: astral-sh/setup-uv@v5 + + - name: Sync dependencies + run: uv sync --extra dev - name: Run tests - run: hatch run test -m"not e2e" + run: uv run pytest -m"not e2e" tests windows: name: Python ${{ matrix.python-version }} on Windows @@ -105,8 +111,11 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Install Hatch - run: pip install --upgrade hatch + - name: Install uv + uses: astral-sh/setup-uv@v5 + + - name: Sync dependencies + run: uv sync --extra dev - name: Run tests - run: hatch run test -m"not e2e" + run: uv run pytest -m"not e2e" tests From c0b731d65fd2a66f08a748d78f3bf548e78cba2a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Mar 2026 14:00:39 +0000 Subject: [PATCH 4/7] chore: remove e2e tests step from CI workflow Co-authored-by: masci <7241+masci@users.noreply.github.com> --- .github/workflows/test.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e1674e4..49b402e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -57,13 +57,6 @@ jobs: - name: Run tests run: uv run pytest --cov --cov-report=xml -m"not e2e" tests - - if: matrix.python-version == '3.13' - name: End-to-end - env: - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} - run: uv run pytest -m"e2e" tests - - if: matrix.python-version == '3.13' name: Report Coveralls uses: coverallsapp/github-action@v2 From 835f63cc4354c5a542bd0816194a39a50c0e9660 Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Mon, 9 Mar 2026 16:36:54 +0100 Subject: [PATCH 5/7] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- AGENTS.md | 2 +- CONTRIBUTING.md | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 2108278..65a6b8a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -24,7 +24,7 @@ uv run pytest tests/test_foo.py # Run specific test file ### Testing - Run tests: `uv run pytest tests` - Run tests with coverage: `uv run pytest --cov --cov-report=xml tests` -- Generate coverage report: `uv run pytest --cov --cov-report=xml tests && coverage combine && coverage report -m` +- Generate coverage report: `uv run pytest --cov --cov-report=xml tests && uv run coverage combine && uv run coverage report -m` - Run specific test file: `uv run pytest tests/test_foo.py` - Run e2e tests: `uv run pytest tests/e2e/` (requires API keys) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 111a643..263a427 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,7 +36,7 @@ This command will use the virtual environment managed by `uv`, sync the required To see a recap of the test coverage and specifically which are the lines that are currently not tested, you can run: ```sh -$ uv run pytest --cov --cov-report=xml tests && coverage combine && coverage report -m +$ uv run pytest --cov --cov-report=xml tests && uv run coverage combine && uv run coverage report -m ``` ## Lint the code diff --git a/pyproject.toml b/pyproject.toml index 478dd8d..d8e04f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,7 @@ dev = [ "mkdocs-material", "mkdocstrings[python]", "simplemma", - "eval-type-backport;python_version<'3.10'", + "redis", "litellm", "mypy>=1.0.0", From 5d395f6c16bab9034ea7a5bbca1fde6f96e66cf5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Mar 2026 15:38:10 +0000 Subject: [PATCH 6/7] docs: wrap lint and format into single command in CONTRIBUTING.md Co-authored-by: masci <7241+masci@users.noreply.github.com> --- CONTRIBUTING.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 263a427..ecef9a5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,16 +45,10 @@ Banks tries to keep a high standard of coding conventions and uses [ruff](https: and format consistent. [Mypy](https://mypy-lang.org/) is used to static check that types are properly declared and used consistently across the codebase. -To perform a comprehensive lint check just run: +To auto-format and perform a comprehensive lint check just run: ```sh -$ uv run ruff format --check && uv run ruff check . && uv run mypy --install-types --non-interactive src/banks && uv run pylint src/banks -``` - -To auto-format the code: - -```sh -$ uv run ruff format +$ uv run ruff format && uv run ruff check . && uv run mypy --install-types --non-interactive src/banks && uv run pylint src/banks ``` > [!IMPORTANT] From 451926d846fcfc7c6d90db9b9a7c22ce408f5b47 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Mar 2026 15:42:12 +0000 Subject: [PATCH 7/7] revert: undo merging lint and format into single command in CONTRIBUTING.md Co-authored-by: masci <7241+masci@users.noreply.github.com> --- CONTRIBUTING.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ecef9a5..263a427 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,10 +45,16 @@ Banks tries to keep a high standard of coding conventions and uses [ruff](https: and format consistent. [Mypy](https://mypy-lang.org/) is used to static check that types are properly declared and used consistently across the codebase. -To auto-format and perform a comprehensive lint check just run: +To perform a comprehensive lint check just run: ```sh -$ uv run ruff format && uv run ruff check . && uv run mypy --install-types --non-interactive src/banks && uv run pylint src/banks +$ uv run ruff format --check && uv run ruff check . && uv run mypy --install-types --non-interactive src/banks && uv run pylint src/banks +``` + +To auto-format the code: + +```sh +$ uv run ruff format ``` > [!IMPORTANT]