From 3952ee31b8fc95b1ed74b83429002a7b5da630a3 Mon Sep 17 00:00:00 2001
From: JiaranI <121741034+JiaranI@users.noreply.github.com>
Date: Thu, 31 Oct 2024 11:06:55 +0800
Subject: [PATCH] ollama: add pydocstyle linting for ollama (#27686)
Description: add lint docstrings for ollama module
Issue: the issue https://github.com/langchain-ai/langchain/issues/23188
@baskaryan
test: ruff check passed.
Co-authored-by: Erick Friis
---
libs/partners/ollama/langchain_ollama/__init__.py | 6 ++++++
.../ollama/langchain_ollama/chat_models.py | 2 +-
.../ollama/langchain_ollama/embeddings.py | 1 +
libs/partners/ollama/pyproject.toml | 15 ++++++++++++++-
libs/partners/ollama/scripts/check_imports.py | 1 +
5 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/libs/partners/ollama/langchain_ollama/__init__.py b/libs/partners/ollama/langchain_ollama/__init__.py
index 4921503fa6ea0..add2685a5b1f2 100644
--- a/libs/partners/ollama/langchain_ollama/__init__.py
+++ b/libs/partners/ollama/langchain_ollama/__init__.py
@@ -1,3 +1,9 @@
+"""This is the langchain_ollama package.
+
+It provides infrastructure for interacting with the Ollama service.
+"""
+
+
from importlib import metadata
from langchain_ollama.chat_models import ChatOllama
diff --git a/libs/partners/ollama/langchain_ollama/chat_models.py b/libs/partners/ollama/langchain_ollama/chat_models.py
index f0db82b835ff1..7f887280b000d 100644
--- a/libs/partners/ollama/langchain_ollama/chat_models.py
+++ b/libs/partners/ollama/langchain_ollama/chat_models.py
@@ -90,7 +90,7 @@ def _lc_tool_call_to_openai_tool_call(tool_call: ToolCall) -> dict:
class ChatOllama(BaseChatModel):
- """Ollama chat model integration.
+ r"""Ollama chat model integration.
.. dropdown:: Setup
:open:
diff --git a/libs/partners/ollama/langchain_ollama/embeddings.py b/libs/partners/ollama/langchain_ollama/embeddings.py
index 6c5b812dc99cb..81dfd75b02f68 100644
--- a/libs/partners/ollama/langchain_ollama/embeddings.py
+++ b/libs/partners/ollama/langchain_ollama/embeddings.py
@@ -1,3 +1,4 @@
+"""Ollama embeddings models."""
from typing import (
List,
Optional,
diff --git a/libs/partners/ollama/pyproject.toml b/libs/partners/ollama/pyproject.toml
index 2bb8d9f71886b..6f66fbce29f98 100644
--- a/libs/partners/ollama/pyproject.toml
+++ b/libs/partners/ollama/pyproject.toml
@@ -24,7 +24,20 @@ ollama = ">=0.3.0,<1"
langchain-core = "^0.3.0"
[tool.ruff.lint]
-select = ["E", "F", "I", "T201"]
+select = [
+ "E", # pycodestyle
+ "F", # pyflakes
+ "I", # isort
+ "T201", # print
+ "D", # pydocstyle
+
+]
+
+[tool.ruff.lint.pydocstyle]
+convention = "google"
+
+[tool.ruff.lint.per-file-ignores]
+"tests/**" = ["D"] # ignore docstring checks for tests
[tool.coverage.run]
omit = ["tests/*"]
diff --git a/libs/partners/ollama/scripts/check_imports.py b/libs/partners/ollama/scripts/check_imports.py
index 58a460c149353..acf6128ab95ca 100644
--- a/libs/partners/ollama/scripts/check_imports.py
+++ b/libs/partners/ollama/scripts/check_imports.py
@@ -1,3 +1,4 @@
+"""load multiple Python files specified as command line arguments."""
import sys
import traceback
from importlib.machinery import SourceFileLoader