The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
style(cli): linting pass (#33078)
Mason Daugherty05ba9412309f
diff --git a/libs/cli/CONTRIBUTING.md b/libs/cli/CONTRIBUTING.mddeleted file mode 100644index 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.pyindex 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.pyindex 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):@propertydef 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.pyindex 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.pyindex 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):@propertydef 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.pyindex 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.pyindex 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_templateshutil.copytree(project_template_dir, destination_dir, dirs_exist_ok=False)- # folder movement+ # Folder movementpackage_dir = destination_dir / replacements["__module_name__"]shutil.move(destination_dir / "integration_template", package_dir)- # replacements in files+ # Replacements in filesreplace_glob(destination_dir, "**/*", cast("dict[str, str]", replacements))- # dependency install+ # Dependency installtry:# Use --no-progress to avoid tty issues in CI/test environmentsenv = 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 lengthif 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 pathdst_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_pathsif 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_pathsfor 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.pyindex 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 findthere. It'll return a list of 2-tuplesEach 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 pathto 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.pyindex 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.pyindex 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 pathReturns:- The parsed dependency source information.+ The parsed dependency source informationRaises:- 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 usebranch: the branches to useapi_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.pyindex 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: strdiff --git a/libs/cli/langchain_cli/utils/pyproject.py b/libs/cli/langchain_cli/utils/pyproject.pyindex 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 insteadpyproject: 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 insteaddiff --git a/libs/cli/tests/unit_tests/migrate/generate/test_langchain_migration.py b/libs/cli/tests/unit_tests/migrate/generate/test_langchain_migration.pyindex 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",