chore(cli): add ruff rules D1 (#32350)

Co-authored-by: Mason Daugherty <mason@langchain.dev>
This commit is contained in:
Christophe Bornet
2025-08-12 00:25:30 +02:00
committed by GitHub
parent 8b663ed6c6
commit 46bbd52e81
20 changed files with 67 additions and 13 deletions

View File

@@ -1,7 +1,10 @@
"""Find and replace text in files."""
from pathlib import Path
def find_and_replace(source: str, replacements: dict[str, str]) -> str:
"""Find and replace text in a string."""
rtn = source
# replace keys in deterministic alphabetical order
@@ -13,6 +16,7 @@ def find_and_replace(source: str, replacements: dict[str, str]) -> str:
def replace_file(source: Path, replacements: dict[str, str]) -> None:
"""Replace text in a file."""
try:
content = source.read_text()
except UnicodeDecodeError:
@@ -24,6 +28,7 @@ def replace_file(source: Path, replacements: dict[str, str]) -> None:
def replace_glob(parent: Path, glob: str, replacements: dict[str, str]) -> None:
"""Replace text in files matching a glob pattern."""
for file in parent.glob(glob):
if not file.is_file():
continue