Skip to content

Commit 103fd6a

Browse files
docs: add Google-style docstrings to tools and llms modules (zapier, … (#31957)
**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_
1 parent 612ccf8 commit 103fd6a

File tree

4 files changed

+79
-8
lines changed

4 files changed

+79
-8
lines changed

libs/langchain/langchain/llms/base.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
# Backwards compatibility.
1+
"""
2+
This module provides backward-compatible exports of core language model classes.
3+
4+
These classes are re-exported for compatibility with older versions of LangChain
5+
and allow users to import language model interfaces from a stable path.
6+
7+
Exports:
8+
- LLM: Abstract base class for all LLMs
9+
- BaseLLM: Deprecated or foundational class for legacy LLMs
10+
- BaseLanguageModel: Base class for core language model implementations
11+
"""
12+
213
from langchain_core.language_models import BaseLanguageModel
3-
from langchain_core.language_models.llms import (
4-
LLM,
5-
BaseLLM,
6-
)
14+
from langchain_core.language_models.llms import LLM, BaseLLM
715

816
__all__ = [
917
"LLM",

libs/langchain/langchain/tools/jira/tool.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
"""
2+
This module provides dynamic access to deprecated Jira tools.
3+
4+
When attributes like `JiraAction` are accessed, they are redirected to their new
5+
locations in `langchain_community.tools`. This ensures backward compatibility
6+
while warning developers about deprecation.
7+
8+
Attributes:
9+
JiraAction (deprecated): Dynamically loaded from langchain_community.tools.
10+
"""
11+
112
from typing import TYPE_CHECKING, Any
213

314
from langchain._api import create_importer
@@ -14,7 +25,15 @@
1425

1526

1627
def __getattr__(name: str) -> Any:
17-
"""Look up attributes dynamically."""
28+
"""
29+
Dynamically retrieve attributes from the updated module path.
30+
31+
Args:
32+
name (str): The name of the attribute to import.
33+
34+
Returns:
35+
Any: The resolved attribute from the updated path.
36+
"""
1837
return _import_attribute(name)
1938

2039

libs/langchain/langchain/tools/json/tool.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
"""
2+
This module provides dynamic access to deprecated JSON tools in LangChain.
3+
4+
It ensures backward compatibility by forwarding references such as
5+
`JsonGetValueTool`, `JsonListKeysTool`, and `JsonSpec` to their updated
6+
locations within the `langchain_community.tools` namespace.
7+
8+
This setup allows legacy code to continue working while guiding developers
9+
toward using the updated module paths.
10+
"""
11+
112
from typing import TYPE_CHECKING, Any
213

314
from langchain._api import create_importer
@@ -19,7 +30,18 @@
1930

2031

2132
def __getattr__(name: str) -> Any:
22-
"""Look up attributes dynamically."""
33+
"""
34+
Dynamically retrieve attributes from the updated module path.
35+
36+
This method is used to resolve deprecated attribute imports
37+
at runtime and forward them to their new locations.
38+
39+
Args:
40+
name (str): The name of the attribute to import.
41+
42+
Returns:
43+
Any: The resolved attribute from the appropriate updated module.
44+
"""
2345
return _import_attribute(name)
2446

2547

libs/langchain/langchain/tools/zapier/tool.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
"""
2+
This module provides dynamic access to deprecated Zapier tools in LangChain.
3+
4+
It supports backward compatibility by forwarding references such as
5+
`ZapierNLAListActions` and `ZapierNLARunAction` to their updated locations
6+
in the `langchain_community.tools` package.
7+
8+
Developers using older import paths will continue to function, while LangChain
9+
internally redirects access to the newer, supported module structure.
10+
"""
11+
112
from typing import TYPE_CHECKING, Any
213

314
from langchain._api import create_importer
@@ -17,7 +28,18 @@
1728

1829

1930
def __getattr__(name: str) -> Any:
20-
"""Look up attributes dynamically."""
31+
"""
32+
Dynamically retrieve attributes from the updated module path.
33+
34+
This method is used to resolve deprecated attribute imports
35+
at runtime and forward them to their new locations.
36+
37+
Args:
38+
name (str): The name of the attribute to import.
39+
40+
Returns:
41+
Any: The resolved attribute from the appropriate updated module.
42+
"""
2143
return _import_attribute(name)
2244

2345

0 commit comments

Comments
 (0)