diff --git a/packages/engine/src/external-dependencies.ts b/packages/engine/src/external-dependencies.ts index 6cee2dd..1b661a3 100644 --- a/packages/engine/src/external-dependencies.ts +++ b/packages/engine/src/external-dependencies.ts @@ -67,7 +67,9 @@ const PYTHON_STDLIB_ROOTS = new Set([ "tempfile", "threading", "time", + "tomllib", "traceback", + "types", "typing", "unittest", "urllib", diff --git a/tests/external-dependencies-regression.test.mjs b/tests/external-dependencies-regression.test.mjs new file mode 100644 index 0000000..41748ce --- /dev/null +++ b/tests/external-dependencies-regression.test.mjs @@ -0,0 +1,20 @@ +import assert from "node:assert/strict"; +import test from "node:test"; + +import { isPythonStdlibSpecifier } from "../packages/engine/dist/external-dependencies.js"; + +test("Python stdlib detection recognizes common Python 3.12 modules", () => { + assert.equal(isPythonStdlibSpecifier("hashlib"), true); + assert.equal(isPythonStdlibSpecifier("types"), true); + assert.equal(isPythonStdlibSpecifier("tomllib"), true); + assert.equal(isPythonStdlibSpecifier("types.SimpleNamespace"), true); + assert.equal(isPythonStdlibSpecifier("tomllib.loads"), true); +}); + +test("Python stdlib detection does not classify third-party imports as stdlib", () => { + assert.equal(isPythonStdlibSpecifier("requests"), false); + assert.equal(isPythonStdlibSpecifier("pydantic"), false); + assert.equal(isPythonStdlibSpecifier("toml"), false); + assert.equal(isPythonStdlibSpecifier(".") , false); + assert.equal(isPythonStdlibSpecifier("..local_module"), false); +});