Python: Add basic support for *args

This commit is contained in:
Rasmus Wriedt Larsen
2022-09-12 16:45:57 +02:00
parent b6314dd19d
commit db921ac036
3 changed files with 48 additions and 4 deletions

View File

@@ -6,6 +6,8 @@ import semmle.python.dataflow.new.internal.DataFlowImplConsistency::Consistency
// `python/ql/consistency-queries`. For for now it resides here.
private class MyConsistencyConfiguration extends ConsistencyConfiguration {
override predicate argHasPostUpdateExclude(ArgumentNode n) {
exists(ArgumentPosition apos | n.argumentOf(_, apos) and apos.isStarArgs(_))
or
exists(ArgumentPosition apos | n.argumentOf(_, apos) and apos.isDictSplat())
}

View File

@@ -214,8 +214,8 @@ def test_only_starargs():
args = (arg2, "safe")
starargs_only(arg1, *args) # $ MISSING: arg1 arg2
args = (arg1, arg2, "safe")
starargs_only(*args) # $ MISSING: arg1 arg2
args = (arg1, arg2, "safe") # $ arg1 arg2 func=starargs_only
starargs_only(*args)
def starargs_mixed(a, *args):
@@ -227,8 +227,8 @@ def starargs_mixed(a, *args):
def test_stararg_mixed():
starargs_mixed(arg1, arg2, "safe") # $ arg1 MISSING: arg2
args = (arg2, "safe")
starargs_mixed(arg1, *args) # $ arg1 MISSING: arg2
args = (arg2, "safe") # $ arg2 func=starargs_mixed
starargs_mixed(arg1, *args) # $ arg1
args = (arg1, arg2, "safe")
starargs_mixed(*args) # $ MISSING: arg1 arg2