mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-25 11:10:43 +08:00
fix: resolve ruff violations in gp scripts and i18n util
- FBT001: make dry_run keyword-only in bake_note_keys._bake_file - S112: add S112 to noqa comments in extract_backend_strings.py - PLW2901: rename shadowed loop variable in i18n.translate_note_nodes
This commit is contained in:
@ -44,7 +44,7 @@ def _note_hash(description: str) -> str:
|
||||
return hashlib.sha256(description.encode()).hexdigest()[:8]
|
||||
|
||||
|
||||
def _bake_file(path: Path, dry_run: bool) -> int:
|
||||
def _bake_file(path: Path, *, dry_run: bool) -> int:
|
||||
"""Bake i18n_keys into a single template JSON file. Returns number of keys added/updated."""
|
||||
with path.open(encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
|
||||
@ -135,7 +135,7 @@ def collect_strings() -> dict[str, str]:
|
||||
try:
|
||||
with project_file.open(encoding="utf-8") as f:
|
||||
project = json.load(f)
|
||||
except Exception: # noqa: BLE001
|
||||
except Exception: # noqa: BLE001, S112
|
||||
continue
|
||||
name = project.get("name")
|
||||
description = project.get("description", "")
|
||||
@ -155,7 +155,7 @@ def collect_strings() -> dict[str, str]:
|
||||
try:
|
||||
with project_file.open(encoding="utf-8") as f:
|
||||
project = json.load(f)
|
||||
except Exception: # noqa: BLE001
|
||||
except Exception: # noqa: BLE001, S112
|
||||
continue
|
||||
nodes = project.get("data", {}).get("nodes", [])
|
||||
for node in nodes:
|
||||
|
||||
@ -131,9 +131,11 @@ def translate_flow_notes(nodes: list[dict], locale: str) -> list[dict]:
|
||||
if node.get("type") == "noteNode":
|
||||
i18n_key = node.get("data", {}).get("node", {}).get("i18n_key")
|
||||
if i18n_key:
|
||||
node = copy.deepcopy(node)
|
||||
description = node["data"]["node"].get("description", "")
|
||||
node["data"]["node"]["description"] = translate(i18n_key, locale, description)
|
||||
translated_node = copy.deepcopy(node)
|
||||
description = translated_node["data"]["node"].get("description", "")
|
||||
translated_node["data"]["node"]["description"] = translate(i18n_key, locale, description)
|
||||
result.append(translated_node)
|
||||
continue
|
||||
result.append(node)
|
||||
return result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user