mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-07 05:52:15 +00:00
chore(cli): add ruff rules ANN401 and D1 (#32576)
This commit is contained in:
committed by
GitHub
parent
840e4c8e9f
commit
8a1419dad1
@@ -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)
|
||||
|
@@ -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 = {
|
||||
|
@@ -63,9 +63,7 @@ ignore = [
|
||||
"TD003", # Missing issue link in TODO
|
||||
|
||||
# TODO rules
|
||||
"ANN401",
|
||||
"BLE",
|
||||
"D1",
|
||||
]
|
||||
unfixable = [
|
||||
"B028", # People should intentionally tune the stacklevel
|
||||
|
Reference in New Issue
Block a user