Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

fix(python): a star import from __future__ is a parse barrier

Martin Vogel728bb3b822d1
diff --git a/internal/cbm/extract_imports.c b/internal/cbm/extract_imports.c
index 596bd5f60..a32366cba 100644
--- a/internal/cbm/extract_imports.c
+++ b/internal/cbm/extract_imports.c
@@ -600,8 +600,6 @@ static bool py_ns_import_fact(PyNamespaceBuilder *b, TSNode child, bool from,
.module_name = module_name,
.relative_level = level};
if (from && strcmp(kind, "wildcard_import") == 0) {
- if (level == 0 && module_name && strcmp(module_name, "__future__") == 0)
- return false; /* a syntax error in Python: stays unsupported */
f.kind = CBM_PY_NS_IMPORT_STAR;
*out = f;
return true;
diff --git a/tests/test_extraction.c b/tests/test_extraction.c
index ed83612f2..454642f16 100644
--- a/tests/test_extraction.c
+++ b/tests/test_extraction.c
@@ -12314,8 +12314,9 @@ TEST(python_namespace_facts_string_statements_and_future_imports) {
{"concatenated f-string field", "from .impl import a\n\"x\" f\"{a!r}\"\n",
CBM_PY_NS_REASON_EFFECT},
{"call", "from .impl import a\nprint(a)\n", CBM_PY_NS_REASON_EFFECT},
+ /* Python rejects it, and so does the grammar: the whole file is unknown */
{"star from __future__", "from .impl import a\nfrom __future__ import *\n",
- CBM_PY_NS_REASON_UNSUPPORTED},
+ CBM_PY_NS_REASON_PARSE},
};
for (size_t i = 0; i < sizeof(barriers) / sizeof(barriers[0]); i++) {
r = extract(barriers[i].source, CBM_LANG_PYTHON, "t", "pkg/__init__.py");