Commit 23e382c
feat(analyzers): tree-sitter Python symbol resolver (T18 #689)
Replace jedi-based resolution with a pure tree-sitter static resolver
behind CODE_GRAPH_PY_RESOLVER=tree_sitter. Default remains jedi for
backwards compatibility.
Benchmark on pytest-dev/pytest-6202 (204 files):
- jedi: 247.1s wall, CALLS=1976, EXTENDS=71
- tree-sitter: 6.9s wall, CALLS=4833, EXTENDS=83
~36x speedup, broader call recall (jedi returns None ~80% of the time).
Mechanism:
- TreeSitterPythonResolver builds a project-wide symbol table
(top-level funcs/classes/assigns, class methods, import maps)
keyed by id(files) for lazy construction.
- Resolution: head lookup (local module -> import map ->
cross-project bare-name fallback) + tail walk through attributes
and class methods.
- Handles relative imports, aliased imports, import-of-package,
Optional[T]/generic_type subscript unwrapping.
- AbstractAnalyzer.needs_lsp() hook + PythonAnalyzer override let
source_analyzer skip LSP startup and venv setup entirely when
the static resolver is active. This is where the wall-time win
actually lives (jedi warm-up was ~240s of the 247s baseline).
Closes #689.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent bf339b6 commit 23e382c
5 files changed
Lines changed: 824 additions & 3 deletions
File tree
- api/analyzers
- python
- tests/analyzers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
61 | 72 | | |
62 | 73 | | |
63 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
| 11 | + | |
9 | 12 | | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
17 | 26 | | |
18 | 27 | | |
19 | 28 | | |
| |||
26 | 35 | | |
27 | 36 | | |
28 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
29 | 72 | | |
30 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
31 | 80 | | |
32 | 81 | | |
33 | 82 | | |
| |||
0 commit comments