Skip to content

Commit 8196cfd

Browse files
committed
Python: Attempt at clearer naming of parameters
1 parent 35b0b6b commit 8196cfd

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

python/ql/src/experimental/dataflow/internal/DataFlowPrivate.qll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ private Node update(Node node) {
273273
* When a call contains a dictionary unpacking argument, such as `func(**kwargs)`, with entries corresponding to a keyword parameter,
274274
* the value at such a key is unpacked and passed to the parameter. This is achieved
275275
* by synthesising an argument node `TKwUnpacked(call, callable, name)` representing the unpacked
276-
* value. This is used as the argument passed to the matching keyword parameter. There is a read
276+
* value. This node is used as the argument passed to the matching keyword parameter. There is a read
277277
* step from the dictionary argument to the synthesized argument node.
278278
*
279279
* When a call contains a dictionary unpacking argument, such as `func(**kwargs)`, and the callee contains a doubly starred parameter,
@@ -352,38 +352,38 @@ module ArgumentPassing {
352352
}
353353

354354
/**
355-
* Gets the argument to `call` that is passed to the `n`th parameter of `callable`.
356-
* If it is a positional argument, it must appear at position `argNr`.
357-
* `argNr` will differ from `n` for method- or class calls, where the first parameter
355+
* Gets the argument to `call` that is passed to the parameter at position `paramNr` in `callable`.
356+
* If it is a positional argument, it must appear at position `argNr` in `call`.
357+
* `argNr` will differ from `paramNr` for method- or constructor calls, where the first parameter
358358
* is `self` and the first positional argument is passed to the second positional parameter.
359359
*/
360-
Node getArg(CallNode call, int argNr, CallableValue callable, int n) {
360+
Node getArg(CallNode call, int argNr, CallableValue callable, int paramNr) {
361361
connects(call, callable) and
362-
n - argNr in [0, 1] and // constrain for now to limit the size of the predicate; we only use it to insert one argument (self).
362+
paramNr - argNr in [0, 1] and // constrain for now to limit the size of the predicate; we only use it to insert one argument (self).
363363
(
364364
// positional argument
365365
result = TCfgNode(call.getArg(argNr))
366366
or
367367
// keyword argument
368368
exists(Function f, string argName |
369369
f = callable.getScope() and
370-
f.getArgName(n) = argName and
370+
f.getArgName(paramNr) = argName and
371371
result = TCfgNode(call.getArgByName(argName))
372372
)
373373
or
374374
// a synthezised argument passed to the starred parameter (at position -1)
375375
callable.getScope().hasVarArg() and
376-
n = -1 and
376+
paramNr = -1 and
377377
result = TPosOverflowNode(call, callable)
378378
or
379379
// a synthezised argument passed to the doubly starred parameter (at position -2)
380380
callable.getScope().hasKwArg() and
381-
n = -2 and
381+
paramNr = -2 and
382382
result = TKwOverflowNode(call, callable)
383383
or
384384
// argument unpacked from dict
385385
exists(string name |
386-
call_unpacks(call, argNr, callable, name, n) and
386+
call_unpacks(call, argNr, callable, name, paramNr) and
387387
result = TKwUnpacked(call, callable, name)
388388
)
389389
)

0 commit comments

Comments
 (0)