fix pnpm-workspace.yaml packages:'.' crash on Python 3.10 (closes #1083)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Safi
2026-05-30 13:13:23 +01:00
co-authored by Claude Sonnet 4.6
parent 5056c72e67
commit d4e1d4b553
2 changed files with 29 additions and 1 deletions
+5 -1
View File
@@ -53,6 +53,9 @@ def _safe_extract(extractor: Callable, path: Path) -> dict:
print(f" warning: skipped {path} (recursion limit exceeded)", file=sys.stderr, flush=True)
return {"nodes": [], "edges": [], "error": "recursion_limit_exceeded"}
except Exception as e:
if os.environ.get("GRAPHIFY_DEBUG"):
import traceback
traceback.print_exc(file=sys.stderr)
print(f" warning: skipped {path} ({type(e).__name__}: {e})", file=sys.stderr, flush=True)
return {"nodes": [], "edges": [], "error": f"{type(e).__name__}: {e}"}
@@ -307,7 +310,8 @@ def _load_workspace_packages(start_dir: Path) -> dict[str, Path]:
packages: dict[str, Path] = {}
for pattern in _workspace_globs(root / "pnpm-workspace.yaml"):
for package_dir in root.glob(pattern):
package_dirs: list[Path] = [root] if pattern in (".", "./") else list(root.glob(pattern))
for package_dir in package_dirs:
manifest = package_dir / "package.json"
if not manifest.is_file():
continue
+24
View File
@@ -425,6 +425,30 @@ def test_workspace_package_cache_refreshes_between_extract_calls(tmp_path: Path)
assert _has_edge(second, "apps/web/src/page.ts", "packages/types/src/index.ts")
def test_pnpm_workspace_dot_package_does_not_crash(tmp_path: Path):
"""packages: - '.' in pnpm-workspace.yaml must not raise IndexError on any Python version."""
_write(
tmp_path / "pnpm-workspace.yaml",
"packages:\n - '.'\n - 'examples/*'\n",
)
_write(
tmp_path / "package.json",
json.dumps({"name": "my-app"}),
)
src = _write(
tmp_path / "index.ts",
"import { foo } from 'my-app';\n",
)
result = _extract_for([src], tmp_path)
nodes = result.get("nodes", [])
assert isinstance(nodes, list)
for node in nodes:
error = node.get("error", "") if isinstance(node, dict) else ""
assert "IndexError" not in error
def test_ts_type_relationships_and_contexts(tmp_path: Path):
base = _write(
tmp_path / "src/lib/base.ts",