style: fix ruff lint and formatting errors
- E741: rename ambiguous variable `l` → `line_text` in enhance_skill_local.py - ARG001: suppress unused `doc` param in word_scraper _build_section() - SIM108: use ternary for code_text assignment in word_scraper - F841: remove unused `metadata` variable in test_chunking_integration - F401: remove unused imports in test_pinecone_adaptor - ARG001: rename unused `docs` → `_docs` in test_pinecone_adaptor - Format 20 files to match ruff formatting rules Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -367,7 +367,7 @@ class LocalSkillEnhancer:
|
||||
if line.startswith("#"):
|
||||
# Found heading - keep it and next 3 lines
|
||||
chunk = lines[i : min(i + 4, len(lines))]
|
||||
chunk_chars = sum(len(l) for l in chunk)
|
||||
chunk_chars = sum(len(line_text) for line_text in chunk)
|
||||
if current_chars + chunk_chars > max_chars:
|
||||
break
|
||||
result.extend(chunk)
|
||||
|
||||
@@ -79,7 +79,9 @@ class WordToSkillConverter:
|
||||
self.config = config
|
||||
self.name = config["name"]
|
||||
self.docx_path = config.get("docx_path", "")
|
||||
self.description = config.get("description") or f"Use when referencing {self.name} documentation"
|
||||
self.description = (
|
||||
config.get("description") or f"Use when referencing {self.name} documentation"
|
||||
)
|
||||
|
||||
# Paths
|
||||
self.skill_dir = f"output/{self.name}"
|
||||
@@ -110,9 +112,7 @@ class WordToSkillConverter:
|
||||
raise FileNotFoundError(f"Word document not found: {self.docx_path}")
|
||||
|
||||
if not self.docx_path.lower().endswith(".docx"):
|
||||
raise ValueError(
|
||||
f"Not a Word document (expected .docx): {self.docx_path}"
|
||||
)
|
||||
raise ValueError(f"Not a Word document (expected .docx): {self.docx_path}")
|
||||
|
||||
# --- Extract metadata via python-docx ---
|
||||
doc = python_docx.Document(self.docx_path)
|
||||
@@ -733,12 +733,13 @@ class WordToSkillConverter:
|
||||
# HTML-to-sections helper (module-level for clarity)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def _build_section(
|
||||
section_number: int,
|
||||
heading: str | None,
|
||||
heading_level: str | None,
|
||||
elements: list,
|
||||
doc,
|
||||
doc, # noqa: ARG001
|
||||
) -> dict:
|
||||
"""Build a section dict from a list of BeautifulSoup elements.
|
||||
|
||||
@@ -774,10 +775,7 @@ def _build_section(
|
||||
# Code blocks
|
||||
if tag == "pre" or (tag == "code" and elem.find_parent("pre") is None):
|
||||
code_elem = elem.find("code") if tag == "pre" else elem
|
||||
if code_elem:
|
||||
code_text = code_elem.get_text()
|
||||
else:
|
||||
code_text = elem.get_text()
|
||||
code_text = code_elem.get_text() if code_elem else elem.get_text()
|
||||
|
||||
code_text = code_text.strip()
|
||||
if code_text:
|
||||
@@ -961,7 +959,8 @@ def main():
|
||||
name = Path(args.from_json).stem.replace("_extracted", "")
|
||||
config = {
|
||||
"name": getattr(args, "name", None) or name,
|
||||
"description": getattr(args, "description", None) or f"Use when referencing {name} documentation",
|
||||
"description": getattr(args, "description", None)
|
||||
or f"Use when referencing {name} documentation",
|
||||
}
|
||||
try:
|
||||
converter = WordToSkillConverter(config)
|
||||
@@ -1049,6 +1048,7 @@ def main():
|
||||
except Exception as e:
|
||||
print(f"\n❌ Unexpected error during Word processing: {e}", file=sys.stderr)
|
||||
import traceback
|
||||
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user