fix(resolution): resolve direct calls through aliased Python function imports - #1518
Open
JacquesBLR wants to merge 1 commit into
Open
fix(resolution): resolve direct calls through aliased Python function imports#1518JacquesBLR wants to merge 1 commit into
JacquesBLR wants to merge 1 commit into
Conversation
… imports Two compounding gaps in `from mod import fn as alias; alias()`: 1. resolveViaImport's generic "reference name matches an import" loop resolved `imp.source` through resolveImportPath, which for Python only maps RELATIVE dotted paths (`.mod`, `..pkg.mod`). An ABSOLUTE dotted source (`from scripts.lire_fec import ...`) returned null there, and unlike resolvePythonModuleMember / resolveModuleImportToFile (colbymchenry#578), this loop had no findPythonModuleFile fallback — so it silently produced no edge for any direct (non-member) call through an absolute-module import, aliased or not. 2. Even once the file resolved, findExportedSymbol filters candidates on `n.isExported` — and the Python extractor never implemented `isExported`, so it was undefined/falsy for every Python symbol. This normally went unnoticed because an unaliased call (`from mod import summarize; summarize()`) still resolves via unrelated same-name fuzzy matching when the name is globally unique — but an aliased direct call has no name to fuzzy-match on, so this generic import path was its only route, and it always failed. Python has no export syntax, so every module/class-level def is importable by name; isExported is now false only for names nested inside a function body (closures). Found via a real project (`from scripts.lire_fec import summarize as fec_summary`, called as `fec_summary()`).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two compounding gaps in resolving
from mod import fn as aliasfollowed by a barealias()call:resolveViaImport's generic "reference name matches an import" loop resolvedimp.sourcethroughresolveImportPath, which for Python only maps relative dotted paths (.mod,..pkg.mod). An absolute dotted source (e.g.scripts.lire_fecfromfrom scripts.lire_fec import ...) returned null there, and unlikeresolvePythonModuleMember/resolveModuleImportToFile(Python: codegraph_callers misses module-attribute call sites (module.func(...) afterfrom pkg import module) — zero recall on a common test/namespacing pattern #578), this loop had nofindPythonModuleFilefallback — so it silently produced no edge for any direct (non-member) call through an absolute-module import, aliased or not.findExportedSymbolfilters candidates onn.isExported— and the Python extractor never implementedisExported, so it wasundefined/falsy for every Python symbol. This normally went unnoticed because an unaliased call (from mod import summarize; summarize()) still resolves via unrelated same-name fuzzy matching when the name is globally unique — but an aliased direct call has no name to fuzzy-match on, so this generic import path was its only route, and it always failed.Found on a real project (
from scripts.lire_fec import summarize as fec_summary, called asfec_summary()).Fix
findPythonModuleFilefallback already used elsewhere (Python: codegraph_callers misses module-attribute call sites (module.func(...) afterfrom pkg import module) — zero recall on a common test/namespacing pattern #578) toresolveViaImport's generic loop.isExportedfor the Python extractor: every module- and class-leveldef/classis exported (Python has no export syntax — a leading underscore is only convention, and__all__only restrictsimport *); only names nested inside a function body (closures) are not.Test plan