refactor(tools): discovery scan sees loop-registered tools; fix lint module import

This commit is contained in:
Teknium
2026-09-02 09:45:53 -07:00
parent d4cec15b47
commit 3f5564d727
2 changed files with 9 additions and 2 deletions

View File

@@ -11,7 +11,7 @@ import os
import tomllib
from typing import Callable, Dict, Optional
from tools.file_operations_types import LintResult
from tools.file_operations_common import LintResult
# Shell linters by extension, run via _exec() for languages whose check needs an
# external toolchain. ``.tsx`` is deliberately absent: it has never had a shell

View File

@@ -105,7 +105,14 @@ def _module_registers_tools(module_path: Path) -> bool:
except SyntaxError:
return False
return any(_is_registry_register_call(stmt) for stmt in tree.body)
# Module-level ``for`` loops count too: table-driven modules register
# several tools from one loop, which still runs at import time.
for stmt in tree.body:
if _is_registry_register_call(stmt):
return True
if isinstance(stmt, ast.For) and any(_is_registry_register_call(s) for s in stmt.body):
return True
return False
def discover_builtin_tools(tools_dir: Optional[Path] = None) -> List[str]: