Skip to content

The agent engineering platform.

chore(cli): add ruff rules ANN401 and D1 (#32576)

Christophe Bornet8a1419dad150
diff --git a/libs/cli/langchain_cli/namespaces/migrate/generate/utils.py b/libs/cli/langchain_cli/namespaces/migrate/generate/utils.py
index 4870763a70..f7628b2f05 100644
--- a/libs/cli/langchain_cli/namespaces/migrate/generate/utils.py
+++ b/libs/cli/langchain_cli/namespaces/migrate/generate/utils.py
@@ -6,7 +6,9 @@ import os
import pathlib
from pathlib import Path
from types import ModuleType
-from typing import Any, Optional
+from typing import Optional
+
+from typing_extensions import override
HERE = Path(__file__).parent
# Should bring us to [root]/src
@@ -25,7 +27,8 @@ class ImportExtractor(ast.NodeVisitor):
self.imports: list = []
self.package = from_package
- def visit_ImportFrom(self, node: ast.ImportFrom) -> None: # noqa: N802
+ @override
+ def visit_ImportFrom(self, node: ast.ImportFrom) -> None:
if node.module and (
self.package is None or str(node.module).startswith(self.package)
):
@@ -44,7 +47,8 @@ def _get_class_names(code: str) -> list[str]:
# Define a node visitor class to collect class names
class ClassVisitor(ast.NodeVisitor):
- def visit_ClassDef(self, node: ast.ClassDef) -> None: # noqa: N802
+ @override
+ def visit_ClassDef(self, node: ast.ClassDef) -> None:
class_names.append(node.name)
self.generic_visit(node)
@@ -54,7 +58,7 @@ def _get_class_names(code: str) -> list[str]:
return class_names
-def is_subclass(class_obj: Any, classes_: list[type]) -> bool:
+def is_subclass(class_obj: type, classes_: list[type]) -> bool:
"""Check if the given class object is a subclass of any class in list classes."""
return any(
issubclass(class_obj, kls)
diff --git a/libs/cli/langchain_cli/utils/events.py b/libs/cli/langchain_cli/utils/events.py
index 860c5aaedd..38bacf8c63 100644
--- a/libs/cli/langchain_cli/utils/events.py
+++ b/libs/cli/langchain_cli/utils/events.py
@@ -21,7 +21,7 @@ class EventDict(TypedDict):
properties: Optional[dict[str, Any]]
-def create_events(events: list[EventDict]) -> Optional[Any]:
+def create_events(events: list[EventDict]) -> Optional[dict[str, Any]]:
"""Create events."""
try:
data = {
diff --git a/libs/cli/pyproject.toml b/libs/cli/pyproject.toml
index 222a947e8f..6d8d3075bd 100644
--- a/libs/cli/pyproject.toml
+++ b/libs/cli/pyproject.toml
@@ -63,9 +63,7 @@ ignore = [
"TD003", # Missing issue link in TODO
# TODO rules
- "ANN401",
"BLE",
- "D1",
]
unfixable = [
"B028", # People should intentionally tune the stacklevel