From b7da7089e473c18126abe6f30fcbc02a339a892c Mon Sep 17 00:00:00 2001 From: Samiul Sk Date: Sat, 11 Oct 2025 13:49:31 +0530 Subject: [PATCH 1/2] Ensure Python 3.8+ compatibility by fixing type annotations and adding CI testing matrix - Change dict to Dict for Python 3.8 support - Add Python version matrix (3.8-3.13) to github action test workflow --- .github/workflows/test.yaml | 4 ++++ ollama/_utils.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f60c4cae..290dccf6 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,11 +9,15 @@ on: jobs: test: runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] steps: - uses: actions/checkout@v5 - uses: astral-sh/setup-uv@v5 with: enable-cache: true + python-version: ${{ matrix.python-version }} - run: uvx hatch test -acp if: ${{ always() }} lint: diff --git a/ollama/_utils.py b/ollama/_utils.py index 15f1cc0c..b32525bd 100644 --- a/ollama/_utils.py +++ b/ollama/_utils.py @@ -3,14 +3,14 @@ import inspect import re from collections import defaultdict -from typing import Callable, Union +from typing import Callable, Dict, Union import pydantic from ollama._types import Tool -def _parse_docstring(doc_string: Union[str, None]) -> dict[str, str]: +def _parse_docstring(doc_string: Union[str, None]) -> Dict[str, str]: parsed_docstring = defaultdict(str) if not doc_string: return parsed_docstring From cc0f3dfa4ccc856f5334cff398569ff575f4986f Mon Sep 17 00:00:00 2001 From: Samiul Sk Date: Sat, 11 Oct 2025 14:07:57 +0530 Subject: [PATCH 2/2] Add tox to test environment dependencies - Include tox in [tool.hatch.envs.hatch-test].extra-dependencies - Makes it easy for developers to run multi-version tests locally - No impact on end users or package size --- pyproject.toml | 1 + tox.ini | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 tox.ini diff --git a/pyproject.toml b/pyproject.toml index 05eafdc5..dfd69048 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,6 +30,7 @@ default-args = ['ollama', 'tests'] extra-dependencies = [ 'pytest-anyio', 'pytest-httpserver', + 'tox', ] [tool.hatch.envs.hatch-static-analysis] diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..bda8f8b4 --- /dev/null +++ b/tox.ini @@ -0,0 +1,16 @@ +# Tox configuration for local multi-version testing +# Run `tox` to test the package on all supported Python versions +# Requires Python interpreters to be installed (e.g., via pyenv) + +[tox] +envlist = py38, py39, py310, py311, py312, py313 +skip_missing_interpreters = true + +[testenv] +allowlist_externals = uv +deps = + pytest + pytest-anyio + pytest-httpserver +install_command = uv pip install {opts} {packages} +commands = uv run pytest {posargs:tests/} \ No newline at end of file