Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(python): Chained assignments support
  • Loading branch information
lexdotdev committed Sep 4, 2025
commit c6390ae4da5b49cb0e2a787f2892b74519de759c
26 changes: 16 additions & 10 deletions languages/tree-sitter-stack-graphs-python/src/stack-graphs.tsg
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ attribute node_symbol = node => symbol = (source-text node), source_n
; with item
(with_item)

; assignment
(assignment)

; pattern list
(pattern_list)

Expand Down Expand Up @@ -1285,16 +1288,19 @@ inherit .parent_module
edge @case.new_bindings -> @pattern.new_bindings
}

[
(assignment
left: (_) @pattern
right: (_) @value)
(with_item
value:
(as_pattern
(_) @value
alias: (as_pattern_target (_) @pattern)))
]
(assignment
left: (_) @pattern
right: (_) @value) @assignment
{
edge @pattern.input -> @value.output
edge @assignment.output -> @value.output
}

(with_item
value:
(as_pattern
(_) @value
alias: (as_pattern_target (_) @pattern)))
{
edge @pattern.input -> @value.output
}
Expand Down
12 changes: 12 additions & 0 deletions languages/tree-sitter-stack-graphs-python/test/assignments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
exponent = exp = 3
digits = decimals = abs(exp)
# ^ defined: 1

print digits
# ^ defined: 2

print decimals
# ^ defined: 2

print exponent
# ^ defined: 1