Repository navigation
fix(scanner): aliased Python imports resolve; declared npm packages and "*" paths keys are not unresolved project imports - #222
Merged
Conversation
…nd "*" paths keys are not unresolved project imports Two wrong answers in the unresolved-import tally from #204, found in the pre-release smoke on real repositories. openclaw's tsconfig has a "*" paths key, so every bare specifier looked alias-shaped and 3,732 declared npm packages were reported as missing edges (3,732 of 14,595). A paths key with no literal prefix is no longer an alias, and a package the nearest package.json declares is external regardless of aliases: 2 of 10,615 remain, both genuine. "import pkg.mod as alias" captured the alias inside $PATH, so the resolver looked up "pkg.mod as alias": the edge was lost on every aliased Python import and the tally reported it with the alias text. The alias is stripped at extraction, so resolver and tally see the same module: docling goes from 3 false misses and partial to 0 and complete, and gains the edge. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NRaBgKRAZMX9hjbkkefA7T
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.
Pre-release smoke on main
30b89d7found two wrong answers in the unresolved-project-import tally (#204, surfaced asCoverage.Issuessince #211). Both flipped a clean repo topartialand listed imports as missing that are not.Before / after on real repositories
TypeScript: 3732 of 14595 project-relative imports did not resolve to a file; ... (.pi/extensions/diff.ts -> @mariozechner/pi-coding-agent, ...)TypeScript: 2 of 10615 project-relative imports did not resolve to a file; ... (src/auto-reply/...security.test.ts -> ../templating.js, src/telegram/draft-chunking.test.ts -> ../../config/config.js)Python: 3 of 1215 ... (tests/test_backend_msword.py -> docling.backend.msword_backend as msword_backend_module, ...), 1184 depsTypeScript: 10 of 3671 ...The two openclaw remainders are genuine:
src/auto-reply/*.test.ts -> ../templating.jsnamessrc/templating.ts, which does not exist (the file issrc/auto-reply/templating.ts);src/telegram/*.test.ts -> ../../config/config.jsnames a repo-rootconfig/config.js, which does not exist (the file issrc/config/config.ts).Causes
tsconfig.jsonhaspaths: {"*": [...]}. The alias test did a prefix match on paths keys, and the empty prefix matched every bare specifier, so declared npm packages were "project-looking". Now a paths key with no literal prefix before*is never an alias, and a specifier whose package name (@scope/nameor first segment) is in the nearestpackage.json'sdependencies/devDependencies/peerDependencies/optionalDependenciesis external. The JS workspace resolver already parses everypackage.json; it now keeps those names.import $PATHcapturespkg.mod as aliaswhole, so the resolver looked up the aliased text and found nothing: every aliased Python import was a missing edge, and the tally echoed the alias text. The alias is stripped once, at extraction, so resolver and tally cannot diverge.gumroad: not this bug
$app/*is a real tsconfig alias there. Of the 10 misses, 7 targetapp/javascript/json_schemas/*, which is git-ignored generated output absent on disk (genuine), and 3 are resolver gaps outside this change:$app/types/usernamestypes/user.d.ts(declaration file, no.d.tscandidate in the extension list) and./inertiafrompacks/base.tsnames trackedpacks/inertia.js(TS importer, JS sibling). Both deserve their own issue.Tests
TestDeclaredPackagesAreNotUnresolvedProjectImportsandTestPythonImportAsAliasResolvesinscanner/unresolved_false_positive_test.go; both failed before the fix (3 issues instead of 1;imports = [], want pkg/mod.py).go build ./... && go test ./... && gofmt -l .clean.Not changed:
node_moduleson disk is not consulted (package.json is the declaration; a package installed but undeclared stays a reported miss);import a, bmulti-module Python imports; the two gumroad resolver gaps.Refs #183
Refs #137
🤖 Generated with Claude Code
https://claude.ai/code/session_01NRaBgKRAZMX9hjbkkefA7T