COD-44: Read Python symbols, imports and calls #94
All Vouch review confidence checks passed
Residual risk 0.33 = Change Risk (0.52) × (1 − Review Confidence (0.37)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 60% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #94"
general
weight: 0.35
greptile-apps[bot]
What
Code layer 4/5 (COD-44).
@codechart/core0.5.0 reads Python at the same level as TS/JS: symbols, resolved imports and calls.tree-sitter-python@0.25.0(dev dependency, with MIT notice) joins the grammar assets and is loaded the same lazy way..pyand.pyinow get the Python grammar instead of no symbols.tags.scmalready reads classes, functions and module constants; adefdirectly in a class body is turned into amethod(decorated ones too), and a method's range starts at itsdefline so aself.m()call inside it belongs to the method, not the class.import,from … import,from __future__,importlib.import_module("x")and__import__("x"), with the names each binds. Module-level definitions, assignments and import bindings are the module's exports, which is how a package's__init__.pyre-exports through the existing tracer.if TYPE_CHECKING:andexcept ImportError:imports aretypeOnly;__all__narrows the list, and a star import,__getattr__or computed__all__makes it incomplete.self.x()/cls.x()arethis;a.b.f()keeps its receiver chain;import ns+ns.f()andfrom pkg import mod+mod.f()follow the module;service = PaymentService(…)+service.charge()follows the constructed class; a name both defined and imported in one file staysname-onlybecause execution order decides it.Resolution
A Python spec is resolved against the repo's own layout, never a virtualenv:
pkg/__init__.py, thenmod.py, thenmod.pyi, then a namespace folder (a folder with Python files but no__init__.py).src/folder — or the project root when there is nosrc/layout. A project is the nearest folder withpyproject.toml,setup.pyorsetup.cfg. Another project'ssrc/is never searched.sys.pathedits: a file that writessys.pathgetsunknownfor every absolute import, and the flag survives incremental edits.external; a name declared in the project'spyproject.toml/setup.py/setup.cfg/Pipfile/requirements.txtisexternal; anything else that does not match isunknown.unknown, butfrom nspkg import modstill recordsmod's submodule file on the name, somod.f()resolves.__init__.py, module file or dependency file changes what an import means, and probes/re-resolution handle it like the TS config files.One shared fix
resolve/link.tsused to resolve calls against the imports from before the pass, so a call through a barrel or a submodule missed thedefinedInits imports had just gained. The link pass now hands calls the freshened imports. This changes TS/JS behavior only for calls through a barrel in an incremental update (the case COD-43 already tested), and it is what Python's re-exports need.Spot-check on real repos
Script (outside the repo) compares every
resolvedimport against Python's own importer with the samesys.path, usingpathlib/PathFindersemantics and the importing file's package:| Repo | Resolved imports checked | Wrong |
|---|---|---|
|
pallets/flask| 264 | 0 ||
encode/httpx| 125 | 0 |flask's tutorial examples resolve tounknownbecause they have no project file, which is correct: nothing proves their roots.Tests
python-symbols.test.ts: fixture outline, decorated/async methods, stubs, broken text, calls and callers.python-imports.test.ts:src/layout, relative imports one and two levels up, barrels, stdlib, declared dependencies,TYPE_CHECKING, namespace package,sys.pathhack, module and constructed-class calls.python-incremental.test.ts: single-file edit with a local ripple, new module, namespace → regular package, module appearing under a package, dependency file,sys.pathflag across an edit.py-srcfixture;languages.test.tsandsymbols.test.tsupdated where Python used to have no grammar.Known limits
a.b.f()whereimport a.bnames the whole chain resolves;import a.b.cfollowed bya.b.f()where the receiver path is shorter than the spec does not.name-only; the parse does not keep statement order.super().m()staysname-only.Map _(key: + new ~ changed - removed ◆ config · unmarked = unchanged)_
[Open full map](file:///Users/alex.maza/.cache/codechart/codechart-9266c63c/20261122-211546-cod-44-python-symbols-imports-and-calls.html)
Flow _(key: + new ~ changed ? planned ◇ decision ⤷ shared step)_
[Open full map](file:///Users/alex.maza/.cache/codechart/codechart-9266c63c/20261122-211634-how-a-python-import-resolves.flow.html)