fix(callgraph): Add fallback stdlib check for direct module imports #339
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
Fixes stdlib resolution issue where calls like
os.path.join()were not being resolved when modules were imported directly withimport os.path.Depends on: #338 (PR #2 - Stdlib loader)
Problem
When Python code imports stdlib modules directly (e.g.,
import os.path), the resolution logic was failing:Why it failed:
"os.path"→"os.path"mappingos.path.join, we split intobase="os"andrest="path.join"importMap.Resolve("os")returns false (because import is "os.path", not "os")Result: 310+ stdlib calls marked as
external_frameworkfailuresSolution
Added fallback stdlib check before giving up on resolution:
This checks the full target string (e.g.,
os.path.join) against the stdlib registry with platform-specific aliasing (os.path→posixpath).Impact
Resolution Improvement
Before this fix (PR #2 only):
os.path.joinin top unresolved: 107 occurrencesexternal_frameworkfailures: 311 (includingos.*: 311)After this fix:
os.path.join: FULLY RESOLVED (not in top 20 unresolved)external_frameworkfailures: 1 (down from 311)os.*: 1(99.7% reduction)Net improvement:
Top 20 Unresolved (After Fix)
Now mostly pytest fixtures and third-party libraries:
Remaining Stdlib Calls Analysis
~135 stdlib calls still unresolved (all require type inference):
fis a file objectThese require Phase 3 type inference enhancements (out of scope):
logger = logging.getLogger()parser: argparse.ArgumentParserwith open() as f~361 non-stdlib calls (cannot be resolved without external sources):
Test Results
Build & Tests
Validation (pre-commit codebase - 5,367 calls)
Total improvement from baseline:
Files Changed
graph/callgraph/builder.go- Added fallback stdlib check (8 lines)Part of Stdlib Registry System
🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]