Skip to content

Commit 314c441

Browse files
committed
style: ruff format files changed since v5.9.0 (release gate)
1 parent 8765e5b commit 314c441

17 files changed

Lines changed: 132 additions & 118 deletions

‎.codebuddy/hooks/task_session_start.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,10 @@ def _load_knowledge_overview(repo_path: str) -> str:
287287
return ""
288288
recent = [p.name[:-3] for p in notes[:3]]
289289
lines = [
290-
"【知识库提示】本仓库有 repowiki 知识库"
291-
f"({len(notes)} 条笔记),改文件/做设计前先查:",
290+
f"【知识库提示】本仓库有 repowiki 知识库({len(notes)} 条笔记),改文件/做设计前先查:",
292291
"- 改某文件前:query_wiki(by_file=<路径>) 查该文件的历史决策与教训;",
293292
"- 主题检索:query_wiki(mode='check') 先轻量预检,再全文检索(结果带 est_tokens 成本);",
294-
f"- 最新笔记:{ ';'.join(recent) }",
293+
f"- 最新笔记:{';'.join(recent)}",
295294
]
296295
return "\n".join(lines)
297296
except OSError:

‎.qoder/hooks/task_session_start.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,10 @@ def _load_knowledge_overview(repo_path: str) -> str:
287287
return ""
288288
recent = [p.name[:-3] for p in notes[:3]]
289289
lines = [
290-
"【知识库提示】本仓库有 repowiki 知识库"
291-
f"({len(notes)} 条笔记),改文件/做设计前先查:",
290+
f"【知识库提示】本仓库有 repowiki 知识库({len(notes)} 条笔记),改文件/做设计前先查:",
292291
"- 改某文件前:query_wiki(by_file=<路径>) 查该文件的历史决策与教训;",
293292
"- 主题检索:query_wiki(mode='check') 先轻量预检,再全文检索(结果带 est_tokens 成本);",
294-
f"- 最新笔记:{ ';'.join(recent) }",
293+
f"- 最新笔记:{';'.join(recent)}",
295294
]
296295
return "\n".join(lines)
297296
except OSError:

‎codewiki/hooks/task_session_start.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,10 @@ def _load_knowledge_overview(repo_path: str) -> str:
287287
return ""
288288
recent = [p.name[:-3] for p in notes[:3]]
289289
lines = [
290-
"【知识库提示】本仓库有 repowiki 知识库"
291-
f"({len(notes)} 条笔记),改文件/做设计前先查:",
290+
f"【知识库提示】本仓库有 repowiki 知识库({len(notes)} 条笔记),改文件/做设计前先查:",
292291
"- 改某文件前:query_wiki(by_file=<路径>) 查该文件的历史决策与教训;",
293292
"- 主题检索:query_wiki(mode='check') 先轻量预检,再全文检索(结果带 est_tokens 成本);",
294-
f"- 最新笔记:{ ';'.join(recent) }",
293+
f"- 最新笔记:{';'.join(recent)}",
295294
]
296295
return "\n".join(lines)
297296
except OSError:

‎codewiki/mcp/_ide_hook.py‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,7 @@ def _cleanup_event_file(path: Optional[str]) -> None:
353353

354354
def _event_name(event: Dict[str, Any]) -> str:
355355
"""Lower-cased hook event name (several IDEs spell the key differently)."""
356-
raw = (
357-
event.get("hook_event_name")
358-
or event.get("hookEventName")
359-
or event.get("event")
360-
or ""
361-
)
356+
raw = event.get("hook_event_name") or event.get("hookEventName") or event.get("event") or ""
362357
return str(raw).strip().lower()
363358

364359

‎codewiki/mcp/prompts.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,9 @@ def prompt_catalog() -> list[dict[str, Any]]:
14841484
"resources.catalog.argument",
14851485
name=arg_name,
14861486
scope=_i18n.t(
1487-
"resources.catalog.optional" if not required else "resources.catalog.required"
1487+
"resources.catalog.optional"
1488+
if not required
1489+
else "resources.catalog.required"
14881490
),
14891491
description=_i18n.t("prompts." + meta["name"] + ".args." + arg_name),
14901492
)
@@ -1497,7 +1499,6 @@ def prompt_catalog() -> list[dict[str, Any]]:
14971499

14981500
def register(server):
14991501
"""Register prompt handlers on the given MCP Server instance."""
1500-
from mcp.types import Prompt, PromptArgument
15011502

15021503
@server.list_prompts()
15031504
async def list_prompts() -> list:

‎codewiki/mcp/tools/distill_conversation.py‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,7 @@ def _parse_frontmatter(path: Path) -> Dict[str, str]:
394394
return {}
395395
fm, _ = parse_frontmatter(text)
396396
return {
397-
k: v if isinstance(v, str) else json.dumps(v, ensure_ascii=False)
398-
for k, v in fm.items()
397+
k: v if isinstance(v, str) else json.dumps(v, ensure_ascii=False) for k, v in fm.items()
399398
}
400399

401400

@@ -1854,9 +1853,7 @@ def handle_distill_conversation(
18541853
if not score.get("worth_compiling"):
18551854
continue
18561855
try:
1857-
rel = str(
1858-
Path(nf).resolve().relative_to(Path(output_dir).resolve())
1859-
)
1856+
rel = str(Path(nf).resolve().relative_to(Path(output_dir).resolve()))
18601857
except ValueError:
18611858
rel = f"notes/{Path(nf).name}"
18621859
material_hint = build_skill_hint(

‎codewiki/mcp/tools/note_lifecycle.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ def handle_confirm_note(arguments: Dict[str, Any], store: SessionStore) -> str:
8888
if isinstance(evidence, dict):
8989
_known = ("test_ref", "commit_ref", "reviewed_by")
9090
verification = {
91-
k: str(v)
92-
for k, v in evidence.items()
93-
if k in _known and str(v or "").strip()
91+
k: str(v) for k, v in evidence.items() if k in _known and str(v or "").strip()
9492
}
9593
unknown = set(evidence) - set(_known)
9694
if unknown:

‎codewiki/mcp/tools/outcome_report.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ def handle_report_outcome(arguments: Dict[str, Any], store: SessionStore) -> str
5252
else:
5353
rp = arguments.get("repo_path")
5454
if not rp:
55-
return json.dumps(
56-
{"error": "repo_path is required (or pass an active session)."}
57-
)
55+
return json.dumps({"error": "repo_path is required (or pass an active session)."})
5856
from codewiki.mcp.tools.workspace_layout import default_output_dir
5957

6058
output_dir = default_output_dir(Path(rp).expanduser().resolve())

‎codewiki/mcp/tools/skill_creator.py‎

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,7 @@ def _scan_skills(output_dir: Path) -> List[Dict[str, Any]]:
244244
"status": str(fm.get("status") or "draft"),
245245
"description": str(fm.get("description") or ""),
246246
"summary": str(meta.get("summary") or "")[:_SUMMARY_CHARS],
247-
"source_refs": [
248-
_norm_rel(str(r), output_dir) for r in refs if str(r).strip()
249-
],
247+
"source_refs": [_norm_rel(str(r), output_dir) for r in refs if str(r).strip()],
250248
}
251249
)
252250
return out
@@ -346,9 +344,7 @@ def _candidate_notes(
346344
from codewiki.src.skill_match import score_skill_material
347345

348346
worth = bool(
349-
score_skill_material(body, kind="note", note_type=ntype).get(
350-
"worth_compiling"
351-
)
347+
score_skill_material(body, kind="note", note_type=ntype).get("worth_compiling")
352348
)
353349
except Exception: # advisory only — a scoring failure must not filter
354350
worth = False
@@ -417,9 +413,7 @@ def _skill_capacity(live_count: int) -> Dict[str, Any]:
417413
}
418414

419415

420-
def _conflict_precheck(
421-
topic: Optional[str], skills: List[Dict[str, Any]]
422-
) -> Dict[str, Any]:
416+
def _conflict_precheck(topic: Optional[str], skills: List[Dict[str, Any]]) -> Dict[str, Any]:
423417
"""Jaccard(>0.6) conflict pre-check of *topic* against existing skills."""
424418
if not (topic or "").strip():
425419
return {
@@ -541,14 +535,12 @@ def _err(rule: str, message: str) -> Tuple[Dict[str, Any], Dict[str, Any]]:
541535
if action == "created" and path.is_file():
542536
return _err(
543537
"name_conflict",
544-
f"skills/{name}/SKILL.md already exists; use action='updated' "
545-
"(or retire + re-create).",
538+
f"skills/{name}/SKILL.md already exists; use action='updated' (or retire + re-create).",
546539
)
547540
if action == "updated" and not path.is_file():
548541
return _err(
549542
"not_found",
550-
f"skills/{name}/SKILL.md not found; action='updated' requires an "
551-
"existing draft.",
543+
f"skills/{name}/SKILL.md not found; action='updated' requires an existing draft.",
552544
)
553545

554546
return (
@@ -566,9 +558,7 @@ def _err(rule: str, message: str) -> Tuple[Dict[str, Any], Dict[str, Any]]:
566558
)
567559

568560

569-
def _render_skill_doc(
570-
fm: Dict[str, Any], body: str
571-
) -> str:
561+
def _render_skill_doc(fm: Dict[str, Any], body: str) -> str:
572562
from codewiki.src.frontmatter import render_frontmatter
573563

574564
return render_frontmatter(fm) + "\n" + body + "\n"
@@ -791,9 +781,7 @@ def _mode_retire(arguments: Dict[str, Any], output_dir: Path) -> str:
791781
if not name:
792782
return json.dumps({"error": "retire requires 'name' and 'reason'."})
793783
if not reason:
794-
return json.dumps(
795-
{"error": "retire requires 'reason' (audit trail, design §4.1)."}
796-
)
784+
return json.dumps({"error": "retire requires 'reason' (audit trail, design §4.1)."})
797785
draft = _skills_dir(output_dir) / name / "SKILL.md"
798786
if not draft.is_file():
799787
return json.dumps({"error": f"draft skills/{name}/SKILL.md not found."})
@@ -878,8 +866,10 @@ def handle_skill_creator(arguments: Dict[str, Any], store: Any) -> str:
878866

879867
mode = str(arguments.get("mode") or "prepare").lower()
880868
if mode in ("install", "retire"):
881-
return _mode_install(arguments, output_dir) if mode == "install" else _mode_retire(
882-
arguments, output_dir
869+
return (
870+
_mode_install(arguments, output_dir)
871+
if mode == "install"
872+
else _mode_retire(arguments, output_dir)
883873
)
884874
if mode not in ("prepare", "submit"):
885875
return json.dumps(
@@ -898,23 +888,17 @@ def handle_skill_creator(arguments: Dict[str, Any], store: Any) -> str:
898888
if isinstance(raw_sources, str):
899889
raw_sources = [raw_sources]
900890
if isinstance(raw_sources, list):
901-
mapped = {
902-
_KIND_ALIASES.get(str(s).strip().lower()) for s in raw_sources
903-
} - {None}
891+
mapped = {_KIND_ALIASES.get(str(s).strip().lower()) for s in raw_sources} - {None}
904892
if mapped:
905893
kinds = mapped
906894

907895
skills = _scan_skills(output_dir)
908896
absorbed = _absorbed_paths(skills)
909897
scenarios, scen_avail = (
910-
_candidate_scenarios(output_dir, absorbed, limit)
911-
if "scenarios" in kinds
912-
else ([], 0)
898+
_candidate_scenarios(output_dir, absorbed, limit) if "scenarios" in kinds else ([], 0)
913899
)
914900
notes, note_avail = (
915-
_candidate_notes(output_dir, absorbed, limit)
916-
if "notes" in kinds
917-
else ([], 0)
901+
_candidate_notes(output_dir, absorbed, limit) if "notes" in kinds else ([], 0)
918902
)
919903
scen_trunc = scen_avail > len(scenarios)
920904
note_trunc = note_avail > len(notes)
@@ -938,8 +922,7 @@ def handle_skill_creator(arguments: Dict[str, Any], store: Any) -> str:
938922
},
939923
"open_issues_by_skill": open_issues,
940924
"skills_index": [
941-
{k: s[k] for k in ("name", "file", "status", "summary")}
942-
for s in skills
925+
{k: s[k] for k in ("name", "file", "status", "summary")} for s in skills
943926
],
944927
"conflict_precheck": conflict,
945928
"capacity": capacity,
@@ -996,7 +979,9 @@ def handle_skill_creator(arguments: Dict[str, Any], store: Any) -> str:
996979
seen_names: Set[str] = set()
997980
for entry in entries:
998981
if not isinstance(entry, dict):
999-
errors.append({"name": "<invalid>", "rule": "entry_invalid", "message": "not an object"})
982+
errors.append(
983+
{"name": "<invalid>", "rule": "entry_invalid", "message": "not an object"}
984+
)
1000985
continue
1001986
err, values = _validate_entry(entry, output_dir)
1002987
if err:

‎codewiki/src/secret_redact.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@
6868
(
6969
"env-assign",
7070
re.compile(
71-
r"(?i)(\$env:)(?P<name>" + _SECRET_ASSIGN_NAME + r")\s*=\s*['\"]?(?P<value>[^\s'\"&|;]{8,})"
71+
r"(?i)(\$env:)(?P<name>"
72+
+ _SECRET_ASSIGN_NAME
73+
+ r")\s*=\s*['\"]?(?P<value>[^\s'\"&|;]{8,})"
7274
),
7375
),
7476
]

0 commit comments

Comments
 (0)