[pysrc2cpg] Fix **kwargs handling, add match pattern AST nodes, and test coverage#5910
Open
allsmog wants to merge 1 commit intojoernio:masterfrom
Open
[pysrc2cpg] Fix **kwargs handling, add match pattern AST nodes, and test coverage#5910allsmog wants to merge 1 commit intojoernio:masterfrom
allsmog wants to merge 1 commit intojoernio:masterfrom
Conversation
…est coverage - Fix **kwargs unpacking to preserve dict argument for taint tracking - Convert match statement patterns to proper AST nodes in case body blocks - Add walrus operator tests verifying expression semantics - Add comprehensive comprehension tests (list, set, dict, generator)
ml86
requested changes
Mar 31, 2026
| } | ||
| } | ||
|
|
||
| "walrus operator (named expression)" should { |
Contributor
There was a problem hiding this comment.
Not (named expression) but rather (assignment expression)
| } | ||
|
|
||
| "call with **kwargs unpacking" should { | ||
| lazy val cpg = code("""func(a, **my_dict)""".stripMargin, "test.py") |
Contributor
There was a problem hiding this comment.
Remove lazy. The cpgs returned by code are always created lazily.
There is also no need to explicitly specify the filename of the test code.
There are multiple other instances of this. Fix those as well.
|
|
||
| blockFirstCase.label shouldBe NodeTypes.BLOCK | ||
| blockFirstCase.code shouldBe "print(1)" | ||
| blockFirstCase.astChildren.code.l should contain allOf ("a", "b", "print(1)") |
Contributor
There was a problem hiding this comment.
Having the case values a, b as individual statements in the first case block does not seem like a good representation. It does not encode the semantic and I fail to see in which scenarios that helps. Please explain.
| None | ||
| // We use a synthetic argument name to preserve the unpacked dict as an argument | ||
| // in the CPG so that data flow tracking can follow through it. | ||
| ("**", convert(keyword.value)) |
Contributor
There was a problem hiding this comment.
Use a val instead of string constant and instead of ** use <keyword_dict>.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes Python structural/AST issues and adds test coverage.
Test plan