From 14d7444abe5b0247b79c29b80e6e04625b9ec15e Mon Sep 17 00:00:00 2001 From: Igor Lins e Silva <4753812+igorls@users.noreply.github.com> Date: Fri, 24 Apr 2026 00:27:09 -0300 Subject: [PATCH] fix(deps): add tomli fallback for Python <3.11 `tomllib` is stdlib only in Python 3.11+. On Python 3.9/3.10 (and the macOS runner) the scanner's toml parsing returned empty, so manifest lookups for `pyproject.toml` / `Cargo.toml` produced no name. CI surfaced this via 4 test_project_scanner.py failures on the 3.9 matrix. Add `tomli>=2.0.0` as a conditional dependency for `python_version < '3.11'` and fall back to it in `project_scanner.py`. The project still declares `requires-python = ">=3.9"` so the fallback is the correct shape. --- mempalace/project_scanner.py | 7 +++++-- pyproject.toml | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mempalace/project_scanner.py b/mempalace/project_scanner.py index e078b6e..c03b883 100644 --- a/mempalace/project_scanner.py +++ b/mempalace/project_scanner.py @@ -28,7 +28,10 @@ from typing import Optional try: import tomllib # Python 3.11+ except ImportError: # pragma: no cover - tomllib = None # type: ignore + try: + import tomli as tomllib # Python 3.9/3.10 backport + except ImportError: + tomllib = None # type: ignore SKIP_DIRS = { @@ -130,7 +133,7 @@ def _parse_toml(path: Path) -> dict: try: with open(path, "rb") as f: return tomllib.load(f) - except (OSError, Exception): + except (OSError, tomllib.TOMLDecodeError): return {} diff --git a/pyproject.toml b/pyproject.toml index 8733ec3..617c067 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,6 +29,7 @@ classifiers = [ dependencies = [ "chromadb>=1.5.4,<2", "pyyaml>=6.0,<7", + "tomli>=2.0.0; python_version < '3.11'", ] [project.urls]