Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Ruff

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install ruff
run: |
python -m pip install --upgrade pip
pip install ruff
- name: Run ruff check
run: ruff check .
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.0
hooks:
- id: ruff-check
- id: ruff-format
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

.PHONY: lint format test add-dev

# write help
help:
@echo "Available commands:"
@echo " lint - Run linters"
@echo " format - Format code"
@echo " test - Run tests"
@echo " add-dev - Add development dependencies"

# Use uv to run tools in the project's environment. Example:
# uv add --dev ruff

lint:
uv ruff check .

format:
uv ruff format .

add-dev:
# Add ruff to the project's dev tools using uv
uv add --dev ruff

test:
python -m pytest -q
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,37 @@ except ollama.ResponseError as e:
if e.status_code == 404:
ollama.pull(model)
```

## Contributing / Linting


We use Ruff for linting and formatting. This project uses uv for managing dev tools. Recommended commands:

```sh
# add ruff to the project dev tools (adds to uv config)
uv add --dev ruff

# lint
uv ruff check .

# format in-place
uv ruff format .
```

Alternatives: install Ruff globally with `pipx`, `pip`, or Homebrew if you prefer.

Pre-commit hooks are provided. To enable them locally:

```sh
pip install --upgrade pre-commit
pre-commit install
pre-commit run --all-files
```

There's also a Makefile with convenient targets:

```sh
make lint
make format
```

5 changes: 5 additions & 0 deletions ollama/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""Ollama Python client package.

Convenience exports for the top-level API.
"""

from ollama._client import AsyncClient, Client
from ollama._types import (
ChatResponse,
Expand Down
Loading