The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
refactor(cli): target ruff 310 (#32985)
Mason Daugherty66041a2778b6
diff --git a/libs/cli/langchain_cli/namespaces/app.py b/libs/cli/langchain_cli/namespaces/app.pyindex e80d8e7f24..b83cf9fbaf 100644--- a/libs/cli/langchain_cli/namespaces/app.py+++ b/libs/cli/langchain_cli/namespaces/app.py@@ -5,7 +5,7 @@ import subprocessimport sysimport warningsfrom pathlib import Path-from typing import Annotated, Optional+from typing import Annotatedimport typerimport uvicorn@@ -35,18 +35,18 @@ app_cli = typer.Typer(no_args_is_help=True, add_completion=False)@app_cli.command()def new(name: Annotated[- Optional[str],+ str | None,typer.Argument(help="The name of the folder to create",),] = None,*,package: Annotated[- Optional[list[str]],+ list[str] | None,typer.Option(help="Packages to seed the project with"),] = None,pip: Annotated[- Optional[bool],+ bool | None,typer.Option("--pip/--no-pip",help="Pip install the template(s) as editable dependencies",@@ -127,24 +127,24 @@ def new(@app_cli.command()def add(dependencies: Annotated[- Optional[list[str]],+ list[str] | None,typer.Argument(help="The dependency to add"),] = None,*,api_path: Annotated[- Optional[list[str]],+ list[str] | None,typer.Option(help="API paths to add"),] = None,project_dir: Annotated[- Optional[Path],+ Path | None,typer.Option(help="The project directory"),] = None,repo: Annotated[- Optional[list[str]],+ list[str] | None,typer.Option(help="Install templates from a specific github repo instead"),] = None,branch: Annotated[- Optional[list[str]],+ list[str] | None,typer.Option(help="Install templates from a specific branch"),] = None,pip: Annotated[@@ -186,7 +186,7 @@ def add()# group by repo/ref- grouped: dict[tuple[str, Optional[str]], list[DependencySource]] = {}+ grouped: dict[tuple[str, str | None], list[DependencySource]] = {}for dep in parsed_deps:key_tup = (dep["git"], dep["ref"])lst = grouped.get(key_tup, [])@@ -305,7 +305,7 @@ def remove(api_paths: Annotated[list[str], typer.Argument(help="The API paths to remove")],*,project_dir: Annotated[- Optional[Path],+ Path | None,typer.Option(help="The project directory"),] = None,) -> None:@@ -344,15 +344,15 @@ def remove(def serve(*,port: Annotated[- Optional[int],+ int | None,typer.Option(help="The port to run the server on"),] = None,host: Annotated[- Optional[str],+ str | None,typer.Option(help="The host to run the server on"),] = None,app: Annotated[- Optional[str],+ str | None,typer.Option(help="The app to run, e.g. `app.server:app`"),] = None,) -> None:diff --git a/libs/cli/langchain_cli/namespaces/integration.py b/libs/cli/langchain_cli/namespaces/integration.pyindex 614e81352c..ca7b1c6764 100644--- a/libs/cli/langchain_cli/namespaces/integration.py+++ b/libs/cli/langchain_cli/namespaces/integration.py@@ -5,7 +5,7 @@ import reimport shutilimport subprocessfrom pathlib import Path-from typing import Annotated, Optional, cast+from typing import Annotated, castimport typerfrom typing_extensions import TypedDict@@ -66,14 +66,14 @@ def new(),],name_class: Annotated[- Optional[str],+ str | None,typer.Option(help="The name of the integration in PascalCase. e.g. `MyIntegration`."" This is used to name classes like `MyIntegrationVectorStore`",),] = None,src: Annotated[- Optional[list[str]],+ list[str] | None,typer.Option(help="The name of the single template file to copy."" e.g. `--src integration_template/chat_models.py "@@ -81,7 +81,7 @@ def new(),] = None,dst: Annotated[- Optional[list[str]],+ list[str] | None,typer.Option(help="The relative path to the integration package to place the new file in"". e.g. `my-integration/my_integration.py`",@@ -220,7 +220,7 @@ def create_doc(),],name_class: Annotated[- Optional[str],+ str | None,typer.Option(help=("The PascalCase name of the integration (e.g. `OpenAI`, "diff --git a/libs/cli/langchain_cli/namespaces/migrate/generate/utils.py b/libs/cli/langchain_cli/namespaces/migrate/generate/utils.pyindex 8c7a01f3b1..e62f4b07db 100644--- a/libs/cli/langchain_cli/namespaces/migrate/generate/utils.py+++ b/libs/cli/langchain_cli/namespaces/migrate/generate/utils.py@@ -6,7 +6,6 @@ import osimport pathlibfrom pathlib import Pathfrom types import ModuleType-from typing import Optionalfrom typing_extensions import override@@ -22,7 +21,7 @@ PARTNER_PKGS = PKGS_ROOT / "partners"class ImportExtractor(ast.NodeVisitor):"""Import extractor."""- def __init__(self, *, from_package: Optional[str] = None) -> None:+ def __init__(self, *, from_package: str | None = None) -> None:"""Extract all imports from the given code, optionally filtering by package."""self.imports: list[tuple[str, str]] = []self.package = from_package@@ -105,7 +104,7 @@ def _get_all_classnames_from_file(file: Path, pkg: str) -> list[tuple[str, str]]def identify_all_imports_in_file(file: str,*,- from_package: Optional[str] = None,+ from_package: str | None = None,) -> list[tuple[str, str]]:"""Identify all the imports in the given file.@@ -191,7 +190,7 @@ def list_init_imports_by_package(pkg_root: str) -> list[tuple[str, str]]:def find_imports_from_package(code: str,*,- from_package: Optional[str] = None,+ from_package: str | None = None,) -> list[tuple[str, str]]:"""Find imports in code.diff --git a/libs/cli/langchain_cli/namespaces/template.py b/libs/cli/langchain_cli/namespaces/template.pyindex 80b09722ce..e41cba5e10 100644--- a/libs/cli/langchain_cli/namespaces/template.py+++ b/libs/cli/langchain_cli/namespaces/template.py@@ -4,7 +4,7 @@ import reimport shutilimport subprocessfrom pathlib import Path-from typing import Annotated, Optional+from typing import Annotatedimport typerimport uvicorn@@ -88,15 +88,15 @@ def new(def serve(*,port: Annotated[- Optional[int],+ int | None,typer.Option(help="The port to run the server on"),] = None,host: Annotated[- Optional[str],+ str | None,typer.Option(help="The host to run the server on"),] = None,configurable: Annotated[- Optional[bool],+ bool | None,typer.Option("--configurable/--no-configurable",help="Whether to include a configurable route",@@ -140,7 +140,7 @@ def serve(@package_cli.command()-def list(contains: Annotated[Optional[str], typer.Argument()] = None) -> None: # noqa: A001+def list(contains: Annotated[str | None, typer.Argument()] = None) -> None: # noqa: A001"""List all or search for available templates."""packages = list_packages(contains=contains)for package in packages:diff --git a/libs/cli/pyproject.toml b/libs/cli/pyproject.tomlindex 7320f395f6..a8d1d60f17 100644--- a/libs/cli/pyproject.toml+++ b/libs/cli/pyproject.toml@@ -39,9 +39,6 @@ test_integration = []langchain-core = { path = "../core", editable = true }langchain = { path = "../langchain", editable = true }-[tool.ruff]-target-version = "py39"-[tool.ruff.format]docstring-code-format = true