mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-27 01:35:12 +00:00
fix: resolve all CI failures — format, lint, mypy, and review comments
- Format: auto-reformat agent_tui.py, benchmark.py, coworker_tools.py via ruff - Lint: 0 remaining errors after format pass - Mypy: fix _NullPrinter to subclass Printer for type compatibility in executor.py, planning.py, and skill_builder.py; add isinstance(r, Message) guards in spawn_tools.py; annotate return types and fix dict type params and MCPToolResolver logger type in new_agent.py; add missing printer args to get_llm_response calls - cli.py: fix _read_config to use sentinel so falsy values (0, false) are returned correctly instead of being treated as missing keys - create_agent.py: replace regex-based JSONC comment stripper with a token-aware parser that preserves // inside quoted strings (e.g. URLs) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -533,8 +533,13 @@ class AgentTUI(App[None]):
|
||||
yield Static("AGENTS", classes="sidebar-label")
|
||||
yield OptionList(id="agent-list")
|
||||
with TabPane("Memory", id="tab-memory"):
|
||||
yield Static("Click below to open the memory browser.", id="memory-scope-label")
|
||||
yield Button("Open Memory Browser", id="btn-memory", variant="default")
|
||||
yield Static(
|
||||
"Click below to open the memory browser.",
|
||||
id="memory-scope-label",
|
||||
)
|
||||
yield Button(
|
||||
"Open Memory Browser", id="btn-memory", variant="default"
|
||||
)
|
||||
with Vertical(id="chat-area"):
|
||||
yield VerticalScroll(id="chat-scroll")
|
||||
with Horizontal(id="input-row"):
|
||||
@@ -1617,6 +1622,7 @@ class AgentTUI(App[None]):
|
||||
callback=self._on_room_created,
|
||||
)
|
||||
return
|
||||
|
||||
# ── Room creation ──
|
||||
|
||||
def _on_room_created(self, result: dict[str, Any] | None) -> None:
|
||||
|
||||
@@ -111,7 +111,6 @@ def load_benchmark_cases(path: str | Path) -> LoadedCases:
|
||||
return LoadedCases(cases, threshold)
|
||||
|
||||
|
||||
|
||||
def _check_expected(expected: str, actual: str) -> tuple[bool, float]:
|
||||
"""Check if expected output is found in actual (case-insensitive substring match).
|
||||
|
||||
|
||||
@@ -604,10 +604,12 @@ def _read_config(*keys: str) -> Any:
|
||||
"""Read a nested value from config.json (JSONC-safe).
|
||||
|
||||
Example: _read_config("test", "threshold") reads config["test"]["threshold"].
|
||||
Returns None only when the key is missing, not when the value is falsy.
|
||||
"""
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
_MISSING = object()
|
||||
config_path = Path("config.json")
|
||||
if not config_path.exists():
|
||||
return None
|
||||
@@ -618,8 +620,8 @@ def _read_config(*keys: str) -> Any:
|
||||
for k in keys:
|
||||
if not isinstance(data, dict):
|
||||
return None
|
||||
data = data.get(k)
|
||||
if data is None:
|
||||
data = data.get(k, _MISSING)
|
||||
if data is _MISSING:
|
||||
return None
|
||||
return data
|
||||
except Exception:
|
||||
|
||||
@@ -812,10 +812,30 @@ def _prompt_agent_name() -> str:
|
||||
)
|
||||
|
||||
|
||||
_JSONC_TOKEN_RE = re.compile(
|
||||
r'"(?:[^"\\]|\\.)*"' # double-quoted string
|
||||
r"|'(?:[^'\\]|\\.)*'" # single-quoted string (not standard JSON, but safe)
|
||||
r"|/\*.*?\*/" # /* block comment */
|
||||
r"|//[^\n]*" # // line comment
|
||||
r"|.", # any other character
|
||||
re.DOTALL,
|
||||
)
|
||||
|
||||
|
||||
def _strip_jsonc(text: str) -> str:
|
||||
"""Strip // and /* */ comments from JSONC text, then fix trailing commas."""
|
||||
result = re.sub(r"(?<!:)//.*?$", "", text, flags=re.MULTILINE)
|
||||
result = re.sub(r"/\*.*?\*/", "", result, flags=re.DOTALL)
|
||||
"""Strip // and /* */ comments from JSONC text, then fix trailing commas.
|
||||
|
||||
Only strips comments that appear outside of quoted strings, so double
|
||||
slashes inside string values (e.g. URLs) are preserved correctly.
|
||||
"""
|
||||
|
||||
def _replacer(match: re.Match[str]) -> str:
|
||||
token = match.group(0)
|
||||
if token.startswith(("//", "/*")):
|
||||
return ""
|
||||
return token
|
||||
|
||||
result = _JSONC_TOKEN_RE.sub(_replacer, text)
|
||||
result = re.sub(r",\s*([}\]])", r"\1", result)
|
||||
return result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user