Commit Graph
2 Commits
Author SHA1 Message Date
Colby MchenryandClaude Opus 5.5 4e35e0cb78 test(python): the module-resolution tests remove their temp dir after indexing (#2734)
python-module-resolution.test.ts removed a test's temp dir only when the
test never opened a CodeGraph (`if (cg) cg.destroy(); else if ...`), and
destroy() closes the database without deleting anything. So every test
that indexed left its codegraph-pymod-* dir behind, 47 per full run,
passing or not, since PR #1921 added the file. The dev box's %TEMP% held
1,739 of them by 2026-10-21.

The dir is now removed after destroy(), as the other test files do.

Checked with a private TEMP: main's file leaves 47 codegraph-pymod-* dirs,
this one none, and its 50 tests pass both ways.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 07:34:41 +00:00
Eric MinishandClaude Opus 5.5 6fe9dc1266 fix(python): resolve imports from the package roots the project has (#1921)
Python imports now resolve the way the interpreter finds modules: from
the package roots the project has, not by any file whose path merely
ends in the module's name. A project root is the repository, each
service with its own pyproject.toml, setup.cfg or setup.py, its src/,
and the package directories its build config declares; a local root
answers only importers within its reach, so a test fixture's copy of a
package never becomes the application's. Relative imports climb from
the importer's own package.

Before, `import json` or `from datetime import date` could link to a
project file or function of that name, and a src-layout package like
flask's was found through a test fixture named flask.py. On flask,
fastapi, mealie and django, relative imports now resolve (about 2,200
links added), stdlib and third-party names stop linking to project
namesakes (about 1,300 wrong links removed), and imports of a module's
function land on the function rather than its file. A sync re-opens
what an added or removed module, an edited __init__.py or a changed
package root can move. Indexing CPU time is unchanged.

Merged with main: a function-local `import a.b as X` (PR 2607) now uses
the root-aware lookup, the outside-module receiver check (PR 2606)
passes the importer, and plain imports are read at module level only,
since the mappings apply to every function of the file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 18:07:07 +00:00