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:
yusyus
2026-03-01 10:54:32 +03:00
parent 064405c052
commit 6c31990941
7 changed files with 108 additions and 53 deletions

View File

@@ -31,8 +31,9 @@ except ImportError:
WORD_AVAILABLE = False
def _make_sample_extracted_data(num_sections=2, include_code=False, include_tables=False,
include_images=False):
def _make_sample_extracted_data(
num_sections=2, include_code=False, include_tables=False, include_images=False
):
"""Helper to build a minimal extracted_data dict for testing."""
mock_image_bytes = (
b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01"
@@ -54,23 +55,29 @@ def _make_sample_extracted_data(num_sections=2, include_code=False, include_tabl
}
if include_code:
section["code_samples"] = [
{"code": f"def hello_{i}():\n return 'world'", "language": "python",
"quality_score": 7.5}
{
"code": f"def hello_{i}():\n return 'world'",
"language": "python",
"quality_score": 7.5,
}
]
if include_tables:
section["tables"] = [
{"headers": ["Col A", "Col B"], "rows": [["val1", "val2"], ["val3", "val4"]]}
]
if include_images:
section["images"] = [
{"index": 0, "data": mock_image_bytes, "width": 100, "height": 80}
]
section["images"] = [{"index": 0, "data": mock_image_bytes, "width": 100, "height": 80}]
pages.append(section)
return {
"source_file": "test.docx",
"metadata": {"title": "Test Doc", "author": "Test Author", "created": "", "modified": "",
"subject": ""},
"metadata": {
"title": "Test Doc",
"author": "Test Author",
"created": "",
"modified": "",
"subject": "",
},
"total_sections": num_sections,
"total_code_blocks": num_sections if include_code else 0,
"total_images": num_sections if include_images else 0,
@@ -86,6 +93,7 @@ class TestWordToSkillConverterInit(unittest.TestCase):
if not WORD_AVAILABLE:
self.skipTest("mammoth and python-docx not installed")
from skill_seekers.cli.word_scraper import WordToSkillConverter
self.WordToSkillConverter = WordToSkillConverter
self.temp_dir = tempfile.mkdtemp()
@@ -131,6 +139,7 @@ class TestWordToSkillConverterInit(unittest.TestCase):
def test_name_auto_detected_from_filename(self):
"""Test name can be extracted from filename via infer_description_from_word."""
from skill_seekers.cli.word_scraper import infer_description_from_word
desc = infer_description_from_word({}, name="my_doc")
self.assertIn("my_doc", desc)
@@ -142,6 +151,7 @@ class TestWordCategorization(unittest.TestCase):
if not WORD_AVAILABLE:
self.skipTest("mammoth and python-docx not installed")
from skill_seekers.cli.word_scraper import WordToSkillConverter
self.WordToSkillConverter = WordToSkillConverter
self.temp_dir = tempfile.mkdtemp()
@@ -175,10 +185,22 @@ class TestWordCategorization(unittest.TestCase):
converter.docx_path = ""
converter.extracted_data = {
"pages": [
{"section_number": 1, "heading": "API Reference", "text": "api reference docs",
"code_samples": [], "tables": [], "images": []},
{"section_number": 2, "heading": "Getting Started", "text": "getting started guide",
"code_samples": [], "tables": [], "images": []},
{
"section_number": 1,
"heading": "API Reference",
"text": "api reference docs",
"code_samples": [],
"tables": [],
"images": [],
},
{
"section_number": 2,
"heading": "Getting Started",
"text": "getting started guide",
"code_samples": [],
"tables": [],
"images": [],
},
]
}
@@ -205,6 +227,7 @@ class TestWordSkillBuilding(unittest.TestCase):
if not WORD_AVAILABLE:
self.skipTest("mammoth and python-docx not installed")
from skill_seekers.cli.word_scraper import WordToSkillConverter
self.WordToSkillConverter = WordToSkillConverter
self.temp_dir = tempfile.mkdtemp()
@@ -297,6 +320,7 @@ class TestWordCodeBlocks(unittest.TestCase):
if not WORD_AVAILABLE:
self.skipTest("mammoth and python-docx not installed")
from skill_seekers.cli.word_scraper import WordToSkillConverter
self.WordToSkillConverter = WordToSkillConverter
self.temp_dir = tempfile.mkdtemp()
@@ -351,6 +375,7 @@ class TestWordTables(unittest.TestCase):
if not WORD_AVAILABLE:
self.skipTest("mammoth and python-docx not installed")
from skill_seekers.cli.word_scraper import WordToSkillConverter
self.WordToSkillConverter = WordToSkillConverter
self.temp_dir = tempfile.mkdtemp()
@@ -393,6 +418,7 @@ class TestWordImages(unittest.TestCase):
if not WORD_AVAILABLE:
self.skipTest("mammoth and python-docx not installed")
from skill_seekers.cli.word_scraper import WordToSkillConverter
self.WordToSkillConverter = WordToSkillConverter
self.temp_dir = tempfile.mkdtemp()
@@ -434,6 +460,7 @@ class TestWordErrorHandling(unittest.TestCase):
if not WORD_AVAILABLE:
self.skipTest("mammoth and python-docx not installed")
from skill_seekers.cli.word_scraper import WordToSkillConverter
self.WordToSkillConverter = WordToSkillConverter
self.temp_dir = tempfile.mkdtemp()
@@ -496,6 +523,7 @@ class TestWordJSONWorkflow(unittest.TestCase):
if not WORD_AVAILABLE:
self.skipTest("mammoth and python-docx not installed")
from skill_seekers.cli.word_scraper import WordToSkillConverter
self.WordToSkillConverter = WordToSkillConverter
self.temp_dir = tempfile.mkdtemp()