ruff: more rules across the board & fixes (#31898)

* standardizes ruff dep version across all `pyproject.toml` files
* cli: ruff rules and corrections
* langchain: rules and corrections
This commit is contained in:
Mason Daugherty
2025-07-07 17:48:01 -04:00
committed by GitHub
parent 706a66eccd
commit e7eac27241
408 changed files with 2783 additions and 1671 deletions

View File

@@ -20,7 +20,7 @@ def create_events(events: list[EventDict]) -> Optional[Any]:
"properties": event.get("properties"),
}
for event in events
]
],
}
conn = http.client.HTTPSConnection("app.firstpartyhq.com")

View File

@@ -122,7 +122,9 @@ def parse_dependencies(
api_path: list[str],
) -> list[DependencySource]:
num_deps = max(
len(dependencies) if dependencies is not None else 0, len(repo), len(branch)
len(dependencies) if dependencies is not None else 0,
len(repo),
len(branch),
)
if (
(dependencies and len(dependencies) != num_deps)
@@ -143,7 +145,10 @@ def parse_dependencies(
return [
parse_dependency_string(iter_dep, iter_repo, iter_branch, iter_api_path)
for iter_dep, iter_repo, iter_branch, iter_api_path in zip(
inner_deps, inner_repos, inner_branches, inner_api_paths
inner_deps,
inner_repos,
inner_branches,
inner_api_paths,
)
]
@@ -186,7 +191,7 @@ def copy_repo(
source: Path,
destination: Path,
) -> None:
"""Copies a repo, ignoring git folders.
"""Copiy a repo, ignoring git folders.
Raises FileNotFound error if it can't find source
"""

View File

@@ -13,7 +13,9 @@ def list_packages(*, contains: Optional[str] = None):
}
conn.request(
"GET", "/repos/langchain-ai/langchain/contents/templates", headers=headers
"GET",
"/repos/langchain-ai/langchain/contents/templates",
headers=headers,
)
res = conn.getresponse()

View File

@@ -26,6 +26,7 @@ class LangServeExport(TypedDict):
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

View File

@@ -14,7 +14,8 @@ def _get_dep_inline_table(path: Path) -> InlineTable:
def add_dependencies_to_pyproject_toml(
pyproject_toml: Path, local_editable_dependencies: Iterable[tuple[str, Path]]
pyproject_toml: Path,
local_editable_dependencies: Iterable[tuple[str, Path]],
) -> None:
"""Add dependencies to pyproject.toml."""
with open(pyproject_toml, encoding="utf-8") as f:
@@ -24,14 +25,15 @@ def add_dependencies_to_pyproject_toml(
{
name: _get_dep_inline_table(loc.relative_to(pyproject_toml.parent))
for name, loc in local_editable_dependencies
}
},
)
with open(pyproject_toml, "w", encoding="utf-8") as f:
dump(pyproject, f)
def remove_dependencies_from_pyproject_toml(
pyproject_toml: Path, local_editable_dependencies: Iterable[str]
pyproject_toml: Path,
local_editable_dependencies: Iterable[str],
) -> None:
"""Remove dependencies from pyproject.toml."""
with open(pyproject_toml, encoding="utf-8") as f: