From a295e18b03d63e5d35d21a23c07ea2af0f69ddc7 Mon Sep 17 00:00:00 2001 From: AIOSAI Date: Sun, 1 Mar 2026 20:22:45 -0800 Subject: [PATCH] fix(seedgo): resolve ruff lint errors in test files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove sys.path.insert() blocks from test files (E402) — package is installed via pip install -e . so path manipulation is unnecessary - Move import importlib.util and import subprocess to top of file (E402) - Remove unused sys import from test_seedgo_core.py (F401) - Fix undefined _src_path reference in test_seedgo_cli.py (F821) - Remove unused result variable assignment in TestCLIInit (F841) - Remove extraneous f prefix from f-string in cli.py (F541) All 249 tests pass. Zero ruff violations. Co-Authored-By: Claude Opus 4.6 --- src/seedgo/cli.py | 2 +- tests/test_seedgo_cli.py | 15 +++------------ tests/test_seedgo_core.py | 7 ------- tests/test_seedgo_plugins.py | 9 +-------- 4 files changed, 5 insertions(+), 28 deletions(-) diff --git a/src/seedgo/cli.py b/src/seedgo/cli.py index f2e914ce..f69c6394 100644 --- a/src/seedgo/cli.py +++ b/src/seedgo/cli.py @@ -159,7 +159,7 @@ def _cmd_init(args: argparse.Namespace) -> None: try: config_path = create_default_config(project_root, profile=profile) - print(f"Seed Go initialized.") + print("Seed Go initialized.") print(f" Config: {config_path}") print(f" Plugins: {str(Path(config_path).parent / 'plugins')}") if profile: diff --git a/tests/test_seedgo_cli.py b/tests/test_seedgo_cli.py index 8403c626..816b5b35 100644 --- a/tests/test_seedgo_cli.py +++ b/tests/test_seedgo_cli.py @@ -14,19 +14,12 @@ sys.path fix ensures src/ is importable when running from the repo root: """ import json +import subprocess import sys from pathlib import Path import pytest -# --------------------------------------------------------------------------- -# sys.path fix — must appear before any seedgo imports -# --------------------------------------------------------------------------- - -_src_path = str(Path(__file__).parent.parent / "src") -if _src_path not in sys.path: - sys.path.insert(0, _src_path) - from seedgo.models import CheckItem, CheckResult, Severity from seedgo.runner import ( _file_matches_types, @@ -791,18 +784,16 @@ class TestReportGitHub: # --------------------------------------------------------------------------- -import subprocess - class TestCLIInit: def test_init_creates_config_file(self, tmp_path): - result = subprocess.run( + subprocess.run( [sys.executable, "-m", "seedgo.cli"], input="", capture_output=True, text=True, cwd=str(tmp_path), - env={**__import__("os").environ, "PYTHONPATH": _src_path}, + env={**__import__("os").environ, "PYTHONPATH": str(Path(__file__).parent.parent / "src")}, ) # The above runs cli as module — we need the main() entry # Actually test by calling main() directly via runner script diff --git a/tests/test_seedgo_core.py b/tests/test_seedgo_core.py index 81ecb41a..b085490f 100644 --- a/tests/test_seedgo_core.py +++ b/tests/test_seedgo_core.py @@ -12,17 +12,10 @@ Target: 85%+ coverage of src/seedgo/ core modules. """ import json -import sys from pathlib import Path import pytest -# Ensure src/ is on the path when running from the repo root -_repo_root = Path(__file__).parent.parent -_src_path = str(_repo_root / "src") -if _src_path not in sys.path: - sys.path.insert(0, _src_path) - from seedgo.models import CheckItem, CheckResult, Severity from seedgo.config import ( DEFAULT_CONFIG, diff --git a/tests/test_seedgo_plugins.py b/tests/test_seedgo_plugins.py index 6c235979..0e1d1ba2 100644 --- a/tests/test_seedgo_plugins.py +++ b/tests/test_seedgo_plugins.py @@ -17,19 +17,12 @@ Each plugin has: Uses tmp_path for isolated test directories. """ -import sys +import importlib.util from pathlib import Path import pytest -# Ensure src/ is on the path when running from the repo root _repo_root = Path(__file__).parent.parent -_src_path = str(_repo_root / "src") -if _src_path not in sys.path: - sys.path.insert(0, _src_path) - -# Import plugin modules directly for unit testing -import importlib.util def _load_plugin(plugin_filename: str | Path): """Load a plugin module by filename from the plugins directory."""