From 103fd6ac0ce01cb155aa4e2b3ca18bfdced031f6 Mon Sep 17 00:00:00 2001 From: Akshara <117743533+Akshara-P-Vijayan@users.noreply.github.com> Date: Fri, 11 Jul 2025 19:16:21 +0530 Subject: [PATCH] =?UTF-8?q?docs:=20add=20Google-style=20docstrings=20to=20?= =?UTF-8?q?tools=20and=20llms=20modules=20(zapier,=20=E2=80=A6=20(#31957)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description:** Added standardized Google-style docstrings to improve documentation consistency across key modules. Updated files: - `tools/zapier/tool.py` - `tools/jira/tool.py` - `tools/json/tool.py` - `llms/base.py` These changes enhance readability and maintain consistency with LangChain’s documentation style guide. **Issue:** Fixes #21983 **Dependencies:** None **Twitter handle :** @Akshara_p_ --- libs/langchain/langchain/llms/base.py | 18 ++++++++++---- libs/langchain/langchain/tools/jira/tool.py | 21 +++++++++++++++- libs/langchain/langchain/tools/json/tool.py | 24 ++++++++++++++++++- libs/langchain/langchain/tools/zapier/tool.py | 24 ++++++++++++++++++- 4 files changed, 79 insertions(+), 8 deletions(-) diff --git a/libs/langchain/langchain/llms/base.py b/libs/langchain/langchain/llms/base.py index 335fbadbcfc..1b34e359f53 100644 --- a/libs/langchain/langchain/llms/base.py +++ b/libs/langchain/langchain/llms/base.py @@ -1,9 +1,17 @@ -# Backwards compatibility. +""" +This module provides backward-compatible exports of core language model classes. + +These classes are re-exported for compatibility with older versions of LangChain +and allow users to import language model interfaces from a stable path. + +Exports: + - LLM: Abstract base class for all LLMs + - BaseLLM: Deprecated or foundational class for legacy LLMs + - BaseLanguageModel: Base class for core language model implementations +""" + from langchain_core.language_models import BaseLanguageModel -from langchain_core.language_models.llms import ( - LLM, - BaseLLM, -) +from langchain_core.language_models.llms import LLM, BaseLLM __all__ = [ "LLM", diff --git a/libs/langchain/langchain/tools/jira/tool.py b/libs/langchain/langchain/tools/jira/tool.py index 9f8b313dc01..b9f2db6c11a 100644 --- a/libs/langchain/langchain/tools/jira/tool.py +++ b/libs/langchain/langchain/tools/jira/tool.py @@ -1,3 +1,14 @@ +""" +This module provides dynamic access to deprecated Jira tools. + +When attributes like `JiraAction` are accessed, they are redirected to their new +locations in `langchain_community.tools`. This ensures backward compatibility +while warning developers about deprecation. + +Attributes: + JiraAction (deprecated): Dynamically loaded from langchain_community.tools. +""" + from typing import TYPE_CHECKING, Any from langchain._api import create_importer @@ -14,7 +25,15 @@ _import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_L def __getattr__(name: str) -> Any: - """Look up attributes dynamically.""" + """ + Dynamically retrieve attributes from the updated module path. + + Args: + name (str): The name of the attribute to import. + + Returns: + Any: The resolved attribute from the updated path. + """ return _import_attribute(name) diff --git a/libs/langchain/langchain/tools/json/tool.py b/libs/langchain/langchain/tools/json/tool.py index 5edf1c798d2..d6b2a6a4299 100644 --- a/libs/langchain/langchain/tools/json/tool.py +++ b/libs/langchain/langchain/tools/json/tool.py @@ -1,3 +1,14 @@ +""" +This module provides dynamic access to deprecated JSON tools in LangChain. + +It ensures backward compatibility by forwarding references such as +`JsonGetValueTool`, `JsonListKeysTool`, and `JsonSpec` to their updated +locations within the `langchain_community.tools` namespace. + +This setup allows legacy code to continue working while guiding developers +toward using the updated module paths. +""" + from typing import TYPE_CHECKING, Any from langchain._api import create_importer @@ -19,7 +30,18 @@ _import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_L def __getattr__(name: str) -> Any: - """Look up attributes dynamically.""" + """ + Dynamically retrieve attributes from the updated module path. + + This method is used to resolve deprecated attribute imports + at runtime and forward them to their new locations. + + Args: + name (str): The name of the attribute to import. + + Returns: + Any: The resolved attribute from the appropriate updated module. + """ return _import_attribute(name) diff --git a/libs/langchain/langchain/tools/zapier/tool.py b/libs/langchain/langchain/tools/zapier/tool.py index 3211624589c..c0100e3d0cb 100644 --- a/libs/langchain/langchain/tools/zapier/tool.py +++ b/libs/langchain/langchain/tools/zapier/tool.py @@ -1,3 +1,14 @@ +""" +This module provides dynamic access to deprecated Zapier tools in LangChain. + +It supports backward compatibility by forwarding references such as +`ZapierNLAListActions` and `ZapierNLARunAction` to their updated locations +in the `langchain_community.tools` package. + +Developers using older import paths will continue to function, while LangChain +internally redirects access to the newer, supported module structure. +""" + from typing import TYPE_CHECKING, Any from langchain._api import create_importer @@ -17,7 +28,18 @@ _import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_L def __getattr__(name: str) -> Any: - """Look up attributes dynamically.""" + """ + Dynamically retrieve attributes from the updated module path. + + This method is used to resolve deprecated attribute imports + at runtime and forward them to their new locations. + + Args: + name (str): The name of the attribute to import. + + Returns: + Any: The resolved attribute from the appropriate updated module. + """ return _import_attribute(name)