Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Conversation

@bm-w
Copy link

@bm-w bm-w commented Apr 1, 2025

This addresses issue #476.

Eliding the identifier node type in the stanza query allows it to erroneously match list_splat_pattern or dictionary_splat_pattern when those appear within a typed_parameter. This causes the stack graph generation to fail with an error:

0: Error executing statement edge @name.def -> @param.param_name at (871, 3)
    src/stack-graphs.tsg:871:3:
    871 |   edge @name.def -> @param.param_name
        |   ^
    in stanza
    src/stack-graphs.tsg:861:1:
    861 | [
        | ^
    matching (typed_parameter) node
    test/typed_splat_parameters.py:3:9:
    5 | def foo(*bar: typing.Any):
        |         ^
1: Evaluating edge source
2: Undefined scoped variable [syntax node list_splat_pattern (3, 9)].def

The fragment of the parsed Tree-sitter tree for such a parameter is:

(typed_parameter [3, 9] - [3, 25])
  (list_splat_pattern [3, 9] - [3, 13])
    (identifier [3, 10] - [3, 13]))
  type: (…))

As of v0.23.5 of the Python grammar, typed_parameter may contain identifier or either of the *_splat_pattern node types. As such, making the identifier node type explicit fixes the issue precisely without introducing other problems.

Copilot AI review requested due to automatic review settings April 1, 2025 20:16
@bm-w bm-w requested review from a team as code owners April 1, 2025 20:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue with the Tree-sitter Python grammar by explicitly eliding the identifier node type in typed_parameter nodes. The changes ensure that list_splat_pattern and dictionary_splat_pattern are not erroneously matched, resolving stack graph generation errors.

  • Updated tests to validate proper behavior for typed splat function parameters.
  • Added two test cases to confirm correct handling of both *args and **kwargs.
Files not reviewed (1)
  • languages/tree-sitter-stack-graphs-python/src/stack-graphs.tsg: Language not supported

@bm-w bm-w force-pushed the bm-w/fix-python-typed-splats branch from a843137 to 07d950a Compare April 1, 2025 20:20
@CleanCut
Copy link
Contributor

CleanCut commented Sep 9, 2025

The github/stack-graphs repository is no longer being maintained. As per #502, I'm closing all issues and pull requests before archiving the repository.

@CleanCut CleanCut closed this Sep 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants