fix: resolve all ruff linting errors (W293, F401, B904, UP007, UP045, E741, SIM102, SIM117, ARG)
Auto-fixed (whitespace, imports, type annotations): - codebase_scraper.py: W293 blank lines with whitespace - doc_scraper.py: W293 blank lines with whitespace - parsers/extractors/__init__.py: W293 - parsers/extractors/base_parser.py: W293, UP007, UP045, F401 Manual fixes: - enhancement_workflow.py: B904 raise without `from exc`, remove unused `os` import - parsers/extractors/quality_scorer.py: E741 ambiguous var `l` → `line` - parsers/extractors/rst_parser.py: SIM102 nested if → combined conditions (x2) - pdf_scraper.py: F821 undefined `logger` → `print()` (consistent with file style) - mcp/tools/workflow_tools.py: ARG001 unused `args` → `_args` - tests/test_workflow_runner.py: ARG005 unused lambda args → `_a`/`_kw`, ARG001 `kwargs` → `_kwargs` - tests/test_workflows_command.py: SIM117 nested with → combined with (x2) All 1922 tests pass. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -122,28 +122,28 @@ class TestCreateCommandArgvForwarding:
|
||||
|
||||
def _make_args(self, **kwargs):
|
||||
import argparse
|
||||
defaults = dict(
|
||||
enhance_workflow=None,
|
||||
enhance_stage=None,
|
||||
var=None,
|
||||
workflow_dry_run=False,
|
||||
enhance_level=0,
|
||||
output=None,
|
||||
name=None,
|
||||
description=None,
|
||||
config=None,
|
||||
api_key=None,
|
||||
dry_run=False,
|
||||
verbose=False,
|
||||
quiet=False,
|
||||
chunk_for_rag=False,
|
||||
chunk_size=512,
|
||||
chunk_overlap=50,
|
||||
preset=None,
|
||||
no_preserve_code_blocks=False,
|
||||
no_preserve_paragraphs=False,
|
||||
interactive_enhancement=False,
|
||||
)
|
||||
defaults = {
|
||||
"enhance_workflow": None,
|
||||
"enhance_stage": None,
|
||||
"var": None,
|
||||
"workflow_dry_run": False,
|
||||
"enhance_level": 0,
|
||||
"output": None,
|
||||
"name": None,
|
||||
"description": None,
|
||||
"config": None,
|
||||
"api_key": None,
|
||||
"dry_run": False,
|
||||
"verbose": False,
|
||||
"quiet": False,
|
||||
"chunk_for_rag": False,
|
||||
"chunk_size": 512,
|
||||
"chunk_overlap": 50,
|
||||
"preset": None,
|
||||
"no_preserve_code_blocks": False,
|
||||
"no_preserve_paragraphs": False,
|
||||
"interactive_enhancement": False,
|
||||
}
|
||||
defaults.update(kwargs)
|
||||
return argparse.Namespace(**defaults)
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ Basic usage:
|
||||
.. code-block:: gdscript
|
||||
|
||||
extends Node
|
||||
|
||||
|
||||
func _ready():
|
||||
print("Hello, World!")
|
||||
position = Vector2(100, 100)
|
||||
@@ -414,7 +414,7 @@ def calculate_average(numbers):
|
||||
|
||||
def test_good_table_score(self):
|
||||
"""Test quality score for good table."""
|
||||
from skill_seekers.cli.parsers.extractors import QualityScorer, Table
|
||||
from skill_seekers.cli.parsers.extractors import QualityScorer
|
||||
|
||||
scorer = QualityScorer()
|
||||
good_table = Table(
|
||||
|
||||
@@ -12,8 +12,7 @@ Covers:
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
from unittest.mock import MagicMock, patch, call
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -186,7 +185,7 @@ class TestRunWorkflowsMultiple:
|
||||
m.workflow.description = "desc"
|
||||
m.workflow.stages = []
|
||||
# Track call order
|
||||
m.run.side_effect = lambda *a, _n=wf_name, **kw: run_order.append(_n)
|
||||
m.run.side_effect = lambda *_a, _n=wf_name, **_kw: run_order.append(_n)
|
||||
engines.append(m)
|
||||
|
||||
with patch(
|
||||
@@ -208,7 +207,7 @@ class TestRunWorkflowsMultiple:
|
||||
good_engine.workflow.description = "desc"
|
||||
good_engine.workflow.stages = []
|
||||
|
||||
def side_effect(name, **kwargs):
|
||||
def side_effect(name, **_kwargs):
|
||||
if name == "bad-workflow":
|
||||
raise FileNotFoundError("not found")
|
||||
return good_engine
|
||||
@@ -341,9 +340,8 @@ class TestRunWorkflowsDryRun:
|
||||
with patch(
|
||||
"skill_seekers.cli.enhancement_workflow.WorkflowEngine",
|
||||
return_value=mock_engine,
|
||||
):
|
||||
with pytest.raises(SystemExit) as exc:
|
||||
run_workflows(args)
|
||||
), pytest.raises(SystemExit) as exc:
|
||||
run_workflows(args)
|
||||
|
||||
assert exc.value.code == 0
|
||||
mock_engine.preview.assert_called_once()
|
||||
@@ -366,9 +364,8 @@ class TestRunWorkflowsDryRun:
|
||||
with patch(
|
||||
"skill_seekers.cli.enhancement_workflow.WorkflowEngine",
|
||||
side_effect=engines,
|
||||
):
|
||||
with pytest.raises(SystemExit):
|
||||
run_workflows(args)
|
||||
), pytest.raises(SystemExit):
|
||||
run_workflows(args)
|
||||
|
||||
for engine in engines:
|
||||
engine.preview.assert_called_once()
|
||||
|
||||
@@ -9,7 +9,6 @@ Covers:
|
||||
"""
|
||||
|
||||
import textwrap
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
@@ -290,7 +289,7 @@ class TestDeleteWorkflowTool:
|
||||
wf.write_text(MINIMAL_YAML, encoding="utf-8")
|
||||
|
||||
with _mock_bundled_names([]):
|
||||
result = delete_workflow_tool({"name": "my-wf"})
|
||||
delete_workflow_tool({"name": "my-wf"})
|
||||
|
||||
assert not wf.exists()
|
||||
|
||||
|
||||
@@ -10,11 +10,9 @@ Covers:
|
||||
"""
|
||||
|
||||
import textwrap
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
import pytest
|
||||
import yaml
|
||||
|
||||
# Import the MODULE object (not just individual symbols) so we can patch it
|
||||
# directly via patch.object(). This survives any sys.modules manipulation by
|
||||
@@ -168,9 +166,8 @@ class TestCmdCopy:
|
||||
assert dest.read_text(encoding="utf-8") == MINIMAL_YAML
|
||||
|
||||
def test_copy_nonexistent(self, capsys, tmp_user_dir):
|
||||
with _mock_bundled_text({}):
|
||||
with _mock_bundled([]):
|
||||
rc = cmd_copy(["ghost-workflow"])
|
||||
with _mock_bundled_text({}), _mock_bundled([]):
|
||||
rc = cmd_copy(["ghost-workflow"])
|
||||
assert rc == 1
|
||||
assert "not found" in capsys.readouterr().err.lower()
|
||||
|
||||
@@ -403,9 +400,8 @@ class TestMain:
|
||||
from skill_seekers.cli.workflows_command import main
|
||||
|
||||
# tmp_user_dir is empty; mock bundled to return nothing
|
||||
with _mock_bundled([]):
|
||||
with pytest.raises(SystemExit) as exc:
|
||||
main(["list"])
|
||||
with _mock_bundled([]), pytest.raises(SystemExit) as exc:
|
||||
main(["list"])
|
||||
assert exc.value.code == 0
|
||||
|
||||
def test_main_validate_success(self, capsys, sample_yaml_file):
|
||||
@@ -423,31 +419,27 @@ class TestMain:
|
||||
assert "name: test-workflow" in capsys.readouterr().out
|
||||
|
||||
def test_main_show_not_found_exits_1(self, capsys, tmp_user_dir):
|
||||
with patch.object(_wf_cmd, "_workflow_yaml_text", return_value=None):
|
||||
with pytest.raises(SystemExit) as exc:
|
||||
_wf_cmd.main(["show", "ghost"])
|
||||
with patch.object(_wf_cmd, "_workflow_yaml_text", return_value=None), pytest.raises(SystemExit) as exc:
|
||||
_wf_cmd.main(["show", "ghost"])
|
||||
assert exc.value.code == 1
|
||||
|
||||
def test_main_copy_single(self, capsys, tmp_user_dir):
|
||||
with _mock_bundled_text({"default": MINIMAL_YAML}):
|
||||
with pytest.raises(SystemExit) as exc:
|
||||
_wf_cmd.main(["copy", "default"])
|
||||
with _mock_bundled_text({"default": MINIMAL_YAML}), pytest.raises(SystemExit) as exc:
|
||||
_wf_cmd.main(["copy", "default"])
|
||||
assert exc.value.code == 0
|
||||
assert (tmp_user_dir / "default.yaml").exists()
|
||||
|
||||
def test_main_copy_multiple(self, capsys, tmp_user_dir):
|
||||
texts = {"default": MINIMAL_YAML, "minimal": MINIMAL_YAML}
|
||||
with _mock_bundled_text(texts):
|
||||
with pytest.raises(SystemExit) as exc:
|
||||
_wf_cmd.main(["copy", "default", "minimal"])
|
||||
with _mock_bundled_text(texts), pytest.raises(SystemExit) as exc:
|
||||
_wf_cmd.main(["copy", "default", "minimal"])
|
||||
assert exc.value.code == 0
|
||||
assert (tmp_user_dir / "default.yaml").exists()
|
||||
assert (tmp_user_dir / "minimal.yaml").exists()
|
||||
|
||||
def test_main_copy_not_found_exits_1(self, capsys, tmp_user_dir):
|
||||
with _mock_bundled_text({}), _mock_bundled([]):
|
||||
with pytest.raises(SystemExit) as exc:
|
||||
_wf_cmd.main(["copy", "ghost"])
|
||||
with _mock_bundled_text({}), _mock_bundled([]), pytest.raises(SystemExit) as exc:
|
||||
_wf_cmd.main(["copy", "ghost"])
|
||||
assert exc.value.code == 1
|
||||
|
||||
def test_main_add_single_file(self, capsys, tmp_user_dir, sample_yaml_file):
|
||||
@@ -484,32 +476,28 @@ class TestMain:
|
||||
|
||||
def test_main_remove_single(self, capsys, tmp_user_dir):
|
||||
(tmp_user_dir / "my-wf.yaml").write_text(MINIMAL_YAML, encoding="utf-8")
|
||||
with _mock_bundled([]):
|
||||
with pytest.raises(SystemExit) as exc:
|
||||
_wf_cmd.main(["remove", "my-wf"])
|
||||
with _mock_bundled([]), pytest.raises(SystemExit) as exc:
|
||||
_wf_cmd.main(["remove", "my-wf"])
|
||||
assert exc.value.code == 0
|
||||
assert not (tmp_user_dir / "my-wf.yaml").exists()
|
||||
|
||||
def test_main_remove_multiple(self, capsys, tmp_user_dir):
|
||||
(tmp_user_dir / "wf-a.yaml").write_text(MINIMAL_YAML, encoding="utf-8")
|
||||
(tmp_user_dir / "wf-b.yaml").write_text(MINIMAL_YAML, encoding="utf-8")
|
||||
with _mock_bundled([]):
|
||||
with pytest.raises(SystemExit) as exc:
|
||||
_wf_cmd.main(["remove", "wf-a", "wf-b"])
|
||||
with _mock_bundled([]), pytest.raises(SystemExit) as exc:
|
||||
_wf_cmd.main(["remove", "wf-a", "wf-b"])
|
||||
assert exc.value.code == 0
|
||||
assert not (tmp_user_dir / "wf-a.yaml").exists()
|
||||
assert not (tmp_user_dir / "wf-b.yaml").exists()
|
||||
|
||||
def test_main_remove_bundled_refused(self, capsys, tmp_user_dir):
|
||||
with _mock_bundled(["default"]):
|
||||
with pytest.raises(SystemExit) as exc:
|
||||
_wf_cmd.main(["remove", "default"])
|
||||
with _mock_bundled(["default"]), pytest.raises(SystemExit) as exc:
|
||||
_wf_cmd.main(["remove", "default"])
|
||||
assert exc.value.code == 1
|
||||
|
||||
def test_main_remove_not_found_exits_1(self, capsys, tmp_user_dir):
|
||||
with _mock_bundled([]):
|
||||
with pytest.raises(SystemExit) as exc:
|
||||
_wf_cmd.main(["remove", "ghost"])
|
||||
with _mock_bundled([]), pytest.raises(SystemExit) as exc:
|
||||
_wf_cmd.main(["remove", "ghost"])
|
||||
assert exc.value.code == 1
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user