mirror of
https://github.com/hwchase17/langchain.git
synced 2025-10-09 16:08:24 +00:00
chore(cli): add ruff rules D1 (#32350)
Co-authored-by: Mason Daugherty <mason@langchain.dev>
This commit is contained in:
committed by
GitHub
parent
8b663ed6c6
commit
46bbd52e81
@@ -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
|
||||
|
Reference in New Issue
Block a user