diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 0000000000..ab422b9254 --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,3 @@ +## 2025-06-03 - Nested MagicMock Requires Full Paths +**Learning:** When testing scripts in isolation and mocking missing dependencies with `sys.modules['module'] = MagicMock()`, if the codebase imports from deeply nested submodules (like `litellm.types.utils`), mocking just the top-level `litellm` package is insufficient and raises a `ModuleNotFoundError: No module named 'litellm.types'; 'litellm' is not a package` error. +**Action:** When creating scratchpad tests that use `sys.modules` mocks, ensure you mock every part of the nested import path required by the test environment. diff --git a/helpers/skills.py b/helpers/skills.py index 1112d2973f..12fad2b3e0 100644 --- a/helpers/skills.py +++ b/helpers/skills.py @@ -125,17 +125,17 @@ def _coerce_list(value: Any) -> List[str]: if value is None: return [] if isinstance(value, list): - return [str(v).strip() for v in value if str(v).strip()] + return [stripped for v in value if (stripped := str(v).strip())] if isinstance(value, tuple): - return [str(v).strip() for v in list(value) if str(v).strip()] + return [stripped for v in value if (stripped := str(v).strip())] if isinstance(value, str): # Support comma-separated or space-delimited strings if "," in value: parts = [p.strip() for p in value.split(",")] + return [p for p in parts if p] else: - parts = [p.strip() for p in re.split(r"\s+", value)] - return [p for p in parts if p] - return [str(value).strip()] if str(value).strip() else [] + return value.split() + return [stripped] if (stripped := str(value).strip()) else [] def _normalize_name(name: str) -> str: @@ -475,7 +475,7 @@ def search_skills( if not q: return [] - raw_terms = [t for t in re.split(r"\s+", q) if t] + raw_terms = q.split() terms = [ t for t in raw_terms if len(t) >= 3 or any(ch.isdigit() for ch in t)