Files
codeql/python/ql/test/3/library-tests/functions/FunctionExpr.getArgs.getDefault.ql
Rasmus Wriedt Larsen 1fcbb6e9f4 Python: Better test for Argument.getDefault(i)
Default values for positional arugments follow a rule, so if an argument has a
default value, later positional arguments must also have default values.

The database only stores the actual default values, and nothing about the
arguments that doesn't have default values.

This turns out to be a major problem for Argument.getKwDefault(i), since default
values for keyword-only arguments doesn't have the same rule. So if you know
there is one default value, you can't tell if it is associated with `foo` or
`bar`, as in the examples below:

```
def a(*, foo=None, bar):
    pass

def b(*, foo, bar=None):
    pass
```
2020-04-27 17:22:56 +02:00

5 lines
84 B
Plaintext

import python
from FunctionExpr fe, int i
select fe, i, fe.getArgs().getDefault(i)