Skip to content

The agent engineering platform.

style(cli): linting pass (#33078)

Mason Daugherty05ba9412309f
diff --git a/libs/cli/CONTRIBUTING.md b/libs/cli/CONTRIBUTING.md
deleted file mode 100644
index dcbd2c06b2..0000000000
--- a/libs/cli/CONTRIBUTING.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Contributing to langchain-cli
-
-Update CLI versions with `poe bump` to ensure that version commands display correctly.
diff --git a/libs/cli/langchain_cli/dev_scripts.py b/libs/cli/langchain_cli/dev_scripts.py
index 98ae985f05..9542e0d702 100644
--- a/libs/cli/langchain_cli/dev_scripts.py
+++ b/libs/cli/langchain_cli/dev_scripts.py
@@ -18,7 +18,7 @@ def create_demo_server(
Args:
config_keys: Optional sequence of config keys to expose in the playground.
- playground_type: The type of playground to use. Can be `'default'` or `'chat'`.
+ playground_type: The type of playground to use.
Returns:
The demo server.
diff --git a/libs/cli/langchain_cli/integration_template/tests/integration_tests/test_retrievers.py b/libs/cli/langchain_cli/integration_template/tests/integration_tests/test_retrievers.py
index f4164ebd1b..fdcdc98757 100644
--- a/libs/cli/langchain_cli/integration_template/tests/integration_tests/test_retrievers.py
+++ b/libs/cli/langchain_cli/integration_template/tests/integration_tests/test_retrievers.py
@@ -18,7 +18,5 @@ class Test__ModuleName__Retriever(RetrieversIntegrationTests):
@property
def retriever_query_example(self) -> str:
- """
- Returns a str representing the "query" of an example retriever call.
- """
+ """Returns a str representing the "query" of an example retriever call."""
return "example query"
diff --git a/libs/cli/langchain_cli/integration_template/tests/integration_tests/test_tools.py b/libs/cli/langchain_cli/integration_template/tests/integration_tests/test_tools.py
index 529bd7fe7e..7861b52ae0 100644
--- a/libs/cli/langchain_cli/integration_template/tests/integration_tests/test_tools.py
+++ b/libs/cli/langchain_cli/integration_template/tests/integration_tests/test_tools.py
@@ -21,7 +21,7 @@ class TestParrotMultiplyToolIntegration(ToolsIntegrationTests):
"""
Returns a dictionary representing the "args" of an example tool call.
- This should NOT be a ToolCall dict - i.e. it should not
- have {"name", "id", "args"} keys.
+ This should NOT be a ToolCall dict - i.e. it should not have
+ `{"name", "id", "args"}` keys.
"""
return {"a": 2, "b": 3}
diff --git a/libs/cli/langchain_cli/integration_template/tests/unit_tests/test_tools.py b/libs/cli/langchain_cli/integration_template/tests/unit_tests/test_tools.py
index 23231276d4..4512eaba2e 100644
--- a/libs/cli/langchain_cli/integration_template/tests/unit_tests/test_tools.py
+++ b/libs/cli/langchain_cli/integration_template/tests/unit_tests/test_tools.py
@@ -11,7 +11,7 @@ class TestParrotMultiplyToolUnit(ToolsUnitTests):
@property
def tool_constructor_params(self) -> dict:
- # if your tool constructor instead required initialization arguments like
+ # If your tool constructor instead required initialization arguments like
# `def __init__(self, some_arg: int):`, you would return those here
# as a dictionary, e.g.: `return {'some_arg': 42}`
return {}
@@ -21,7 +21,7 @@ class TestParrotMultiplyToolUnit(ToolsUnitTests):
"""
Returns a dictionary representing the "args" of an example tool call.
- This should NOT be a ToolCall dict - i.e. it should not
- have {"name", "id", "args"} keys.
+ This should NOT be a ToolCall dict - i.e. it should not have
+ `{"name", "id", "args"}` keys.
"""
return {"a": 2, "b": 3}
diff --git a/libs/cli/langchain_cli/namespaces/app.py b/libs/cli/langchain_cli/namespaces/app.py
index b83cf9fbaf..54170bed14 100644
--- a/libs/cli/langchain_cli/namespaces/app.py
+++ b/libs/cli/langchain_cli/namespaces/app.py
@@ -159,8 +159,8 @@ def add(
"""Add the specified template to the current LangServe app.
e.g.:
- langchain app add extraction-openai-functions
- langchain app add git+ssh://[email protected]/efriis/simple-pirate.git
+ `langchain app add extraction-openai-functions`
+ `langchain app add git+ssh://[email protected]/efriis/simple-pirate.git`
"""
if branch is None:
branch = []
diff --git a/libs/cli/langchain_cli/namespaces/integration.py b/libs/cli/langchain_cli/namespaces/integration.py
index ca7b1c6764..89804be170 100644
--- a/libs/cli/langchain_cli/namespaces/integration.py
+++ b/libs/cli/langchain_cli/namespaces/integration.py
@@ -116,17 +116,17 @@ def new(
typer.echo(f"Folder {destination_dir} exists.")
raise typer.Exit(code=1)
- # copy over template from ../integration_template
+ # Copy over template from ../integration_template
shutil.copytree(project_template_dir, destination_dir, dirs_exist_ok=False)
- # folder movement
+ # Folder movement
package_dir = destination_dir / replacements["__module_name__"]
shutil.move(destination_dir / "integration_template", package_dir)
- # replacements in files
+ # Replacements in files
replace_glob(destination_dir, "**/*", cast("dict[str, str]", replacements))
- # dependency install
+ # Dependency install
try:
# Use --no-progress to avoid tty issues in CI/test environments
env = os.environ.copy()
@@ -149,7 +149,7 @@ def new(
"`uv sync --dev` manually in the package directory.",
)
else:
- # confirm src and dst are the same length
+ # Confirm src and dst are the same length
if not src:
typer.echo("Cannot provide --dst without --src.")
raise typer.Exit(code=1)
@@ -158,7 +158,7 @@ def new(
typer.echo("Number of --src and --dst arguments must match.")
raise typer.Exit(code=1)
if not dst:
- # assume we're in a package dir, copy to equivalent path
+ # Assume we're in a package dir, copy to equivalent path
dst_paths = [destination_dir / p for p in src]
else:
dst_paths = [Path.cwd() / p for p in dst]
@@ -169,7 +169,7 @@ def new(
for p in dst_paths
]
- # confirm no duplicate dst_paths
+ # Confirm no duplicate dst_paths
if len(dst_paths) != len(set(dst_paths)):
typer.echo(
"Duplicate destination paths provided or computed - please "
@@ -177,7 +177,7 @@ def new(
)
raise typer.Exit(code=1)
- # confirm no files exist at dst_paths
+ # Confirm no files exist at dst_paths
for dst_path in dst_paths:
if dst_path.exists():
typer.echo(f"File {dst_path} exists.")
diff --git a/libs/cli/langchain_cli/namespaces/migrate/generate/generic.py b/libs/cli/langchain_cli/namespaces/migrate/generate/generic.py
index ac8c059e46..2fac5bafb3 100644
--- a/libs/cli/langchain_cli/namespaces/migrate/generate/generic.py
+++ b/libs/cli/langchain_cli/namespaces/migrate/generate/generic.py
@@ -75,7 +75,7 @@ def generate_raw_migrations(
def generate_top_level_imports(pkg: str) -> list[tuple[str, str]]:
"""Look at all the top level modules in langchain_community.
- Attempt to import everything from each ``__init__`` file. For example,
+ Attempt to import everything from each `__init__` file. For example,
langchain_community/
chat_models/
@@ -83,16 +83,15 @@ def generate_top_level_imports(pkg: str) -> list[tuple[str, str]]:
llm/
__init__.py # <-- import everything from here
-
It'll collect all the imports, import the classes / functions it can find
there. It'll return a list of 2-tuples
Each tuple will contain the fully qualified path of the class / function to where
- its logic is defined
- (e.g., ``langchain_community.chat_models.xyz_implementation.ver2.XYZ``)
+ its logic is defined.
+ (e.g., `langchain_community.chat_models.xyz_implementation.ver2.XYZ`)
and the second tuple will contain the path
to importing it from the top level namespaces
- (e.g., ``langchain_community.chat_models.XYZ``)
+ (e.g., `langchain_community.chat_models.XYZ`)
Args:
pkg: The package to scan.
diff --git a/libs/cli/langchain_cli/namespaces/migrate/generate/partner.py b/libs/cli/langchain_cli/namespaces/migrate/generate/partner.py
index 912548ddde..ef8a34409d 100644
--- a/libs/cli/langchain_cli/namespaces/migrate/generate/partner.py
+++ b/libs/cli/langchain_cli/namespaces/migrate/generate/partner.py
@@ -28,7 +28,6 @@ def get_migrations_for_partner_package(pkg_name: str) -> list[tuple[str, str]]:
Returns:
List of 2-tuples containing old and new import paths.
-
"""
package = importlib.import_module(pkg_name)
classes_ = find_subclasses_in_module(
diff --git a/libs/cli/langchain_cli/utils/git.py b/libs/cli/langchain_cli/utils/git.py
index ce7af5705a..36d99f5535 100644
--- a/libs/cli/langchain_cli/utils/git.py
+++ b/libs/cli/langchain_cli/utils/git.py
@@ -38,19 +38,19 @@ def parse_dependency_string(
branch: str | None,
api_path: str | None,
) -> DependencySource:
- """Parse a dependency string into a DependencySource.
+ """Parse a dependency string into a `DependencySource`.
Args:
- dep: the dependency string.
- repo: optional repository.
- branch: optional branch.
- api_path: optional API path.
+ dep: The dependency string
+ repo: Optional repository
+ branch: Optional branch
+ api_path: Optional API path
Returns:
- The parsed dependency source information.
+ The parsed dependency source information
Raises:
- ValueError: if the dependency string is invalid.
+ ValueError: If the dependency string is invalid
"""
if dep is not None and dep.startswith("git+"):
if repo is not None or branch is not None:
@@ -147,8 +147,8 @@ def parse_dependencies(
"""Parse dependencies.
Args:
- dependencies: the dependencies to parse
- repo: the repositories to use
+ dependencies: The dependencies to parse
+ repo: The repositories to use
branch: the branches to use
api_path: the api paths to use
@@ -244,7 +244,7 @@ def copy_repo(
) -> None:
"""Copiy a repo, ignoring git folders.
- Raises FileNotFound error if it can't find source
+ Raises `FileNotFound` if it can't find source
"""
def ignore_func(_: str, files: list[str]) -> list[str]:
diff --git a/libs/cli/langchain_cli/utils/packages.py b/libs/cli/langchain_cli/utils/packages.py
index 63ac1a0530..4c61ed0f0f 100644
--- a/libs/cli/langchain_cli/utils/packages.py
+++ b/libs/cli/langchain_cli/utils/packages.py
@@ -37,13 +37,12 @@ def get_package_root(cwd: Path | None = None) -> Path:
class LangServeExport(TypedDict):
- """Fields from pyproject.toml that are relevant to LangServe.
+ """Fields from `pyproject.toml` that are relevant to LangServe.
Attributes:
- module: The module to import from, tool.langserve.export_module
- attr: The attribute to import from the module, tool.langserve.export_attr
- package_name: The name of the package, tool.poetry.name
-
+ module: The module to import from, `tool.langserve.export_module`
+ attr: The attribute to import from the module, `tool.langserve.export_attr`
+ package_name: The name of the package, `tool.poetry.name`
"""
module: str
diff --git a/libs/cli/langchain_cli/utils/pyproject.py b/libs/cli/langchain_cli/utils/pyproject.py
index 3a90243f88..1014f83612 100644
--- a/libs/cli/langchain_cli/utils/pyproject.py
+++ b/libs/cli/langchain_cli/utils/pyproject.py
@@ -19,7 +19,7 @@ def add_dependencies_to_pyproject_toml(
pyproject_toml: Path,
local_editable_dependencies: Iterable[tuple[str, Path]],
) -> None:
- """Add dependencies to pyproject.toml."""
+ """Add dependencies to `pyproject.toml`."""
with pyproject_toml.open(encoding="utf-8") as f:
# tomlkit types aren't amazing - treat as Dict instead
pyproject: dict[str, Any] = load(f)
@@ -37,7 +37,7 @@ def remove_dependencies_from_pyproject_toml(
pyproject_toml: Path,
local_editable_dependencies: Iterable[str],
) -> None:
- """Remove dependencies from pyproject.toml."""
+ """Remove dependencies from `pyproject.toml`."""
with pyproject_toml.open(encoding="utf-8") as f:
pyproject: dict[str, Any] = load(f)
# tomlkit types aren't amazing - treat as Dict instead
diff --git a/libs/cli/tests/unit_tests/migrate/generate/test_langchain_migration.py b/libs/cli/tests/unit_tests/migrate/generate/test_langchain_migration.py
index c566df2179..290a095609 100644
--- a/libs/cli/tests/unit_tests/migrate/generate/test_langchain_migration.py
+++ b/libs/cli/tests/unit_tests/migrate/generate/test_langchain_migration.py
@@ -9,7 +9,7 @@ from langchain_cli.namespaces.migrate.generate.generic import (
@pytest.mark.xfail(reason="Unknown reason")
def test_create_json_agent_migration() -> None:
- """Test the migration of create_json_agent from langchain to langchain_community."""
+ """Test migration of `create_json_agent` from langchain to `langchain_community`."""
with sup1(), sup2():
raw_migrations = generate_simplified_migrations(
from_package="langchain",
@@ -40,7 +40,7 @@ def test_create_json_agent_migration() -> None:
@pytest.mark.xfail(reason="Unknown reason")
def test_create_single_store_retriever_db() -> None:
- """Test migration from langchain to langchain_core."""
+ """Test migration from `langchain` to `langchain_core`."""
with sup1(), sup2():
raw_migrations = generate_simplified_migrations(
from_package="langchain",