Commit b1c7e1d
committed
parser: emit REFERENCES edges for Python callback arguments (#363)
The dispatcher in `_extract_value_references` only matched the
`arguments` AST node type, which is the JS/TS shape. Python's
tree-sitter grammar uses `argument_list` for the same construct, so
function references in callback positions — `executor.submit(handler)`,
`filter(predicate, xs)`, `map(transform, xs)`, `df.apply(fn)`, etc. —
silently produced no REFERENCES edges.
Downstream effect: `find_dead_code` already checks `has_references`
(refactor.py), but for Python the edge was never created, so callback
functions were systematically flagged as dead — exactly the high false
positive rate users report in #363 (executor pools, pandas .apply,
higher-order functions, returned closures).
Fix is one line of intent: introduce `_ARGUMENTS_TYPES = {"arguments",
"argument_list"}` and dispatch on set membership instead of string
equality. The existing `_ref_from_arguments` walker already handles
identifier children correctly and `_emit_reference_if_known` still
gates emission on the name being locally defined or imported, so this
does not introduce noise from arbitrary identifiers.
Scoped to the dispatcher only: JS/TS shorthand-property, pair-value,
and array-element handling are unchanged.1 parent 0919071 commit b1c7e1d
3 files changed
Lines changed: 89 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3113 | 3113 | | |
3114 | 3114 | | |
3115 | 3115 | | |
| 3116 | + | |
| 3117 | + | |
| 3118 | + | |
| 3119 | + | |
| 3120 | + | |
3116 | 3121 | | |
3117 | 3122 | | |
3118 | 3123 | | |
| |||
3185 | 3190 | | |
3186 | 3191 | | |
3187 | 3192 | | |
3188 | | - | |
| 3193 | + | |
3189 | 3194 | | |
3190 | 3195 | | |
3191 | 3196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
648 | 648 | | |
649 | 649 | | |
650 | 650 | | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
651 | 699 | | |
652 | 700 | | |
653 | 701 | | |
| |||
0 commit comments