mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
Python: Expand parameters/functions test
I want to ensure we handle when only _some_ parameters have default/annotations
This commit is contained in:
@@ -383,6 +383,7 @@ class CallableValue extends Value {
|
||||
exists(int n |
|
||||
call.getArg(n) = result and
|
||||
this.(PythonFunctionObjectInternal).getScope().getArg(n + offset).getName() = name
|
||||
// TODO: and not positional only argument (Python 3.8+)
|
||||
)
|
||||
or
|
||||
call.getArgByName(name) = result and
|
||||
|
||||
@@ -5,3 +5,8 @@
|
||||
| test.py:4:1:11:2 | Function func | test.py:12:5:12:41 | ExprStmt |
|
||||
| test.py:4:1:11:2 | Function func | test.py:13:5:13:15 | ExprStmt |
|
||||
| test.py:4:1:11:2 | Function func | test.py:14:5:14:17 | ExprStmt |
|
||||
| test.py:23:1:31:2 | Function func2 | test.py:24:5:24:11 | pos_req |
|
||||
| test.py:23:1:31:2 | Function func2 | test.py:25:5:25:17 | pos_w_default |
|
||||
| test.py:23:1:31:2 | Function func2 | test.py:26:5:26:18 | pos_w_default2 |
|
||||
| test.py:23:1:31:2 | Function func2 | test.py:32:5:32:18 | ExprStmt |
|
||||
| test.py:23:1:31:2 | Function func2 | test.py:33:5:40:5 | ExprStmt |
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
| test.py:4:1:11:2 | Function func | 0 | test.py:5:5:5:12 | Parameter |
|
||||
| test.py:4:1:11:2 | Function func | 1 | test.py:7:5:7:10 | Parameter |
|
||||
| test.py:23:1:31:2 | Function func2 | 0 | test.py:24:5:24:11 | Parameter |
|
||||
| test.py:23:1:31:2 | Function func2 | 1 | test.py:25:5:25:17 | Parameter |
|
||||
| test.py:23:1:31:2 | Function func2 | 2 | test.py:26:5:26:18 | Parameter |
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
| test.py:4:1:11:2 | Function func | normal | test.py:7:5:7:10 | Parameter |
|
||||
| test.py:4:1:11:2 | Function func | pos_only | test.py:5:5:5:12 | Parameter |
|
||||
| test.py:23:1:31:2 | Function func2 | pos_req | test.py:24:5:24:11 | Parameter |
|
||||
| test.py:23:1:31:2 | Function func2 | pos_w_default | test.py:25:5:25:17 | Parameter |
|
||||
| test.py:23:1:31:2 | Function func2 | pos_w_default2 | test.py:26:5:26:18 | Parameter |
|
||||
|
||||
@@ -5,3 +5,7 @@
|
||||
| test.py:4:1:11:2 | FunctionExpr | test.py:8:12:8:23 | Str |
|
||||
| test.py:4:1:11:2 | FunctionExpr | test.py:9:25:9:26 | UnaryExpr |
|
||||
| test.py:4:1:11:2 | FunctionExpr | test.py:10:15:10:30 | Str |
|
||||
| test.py:23:1:31:2 | FunctionExpr | test.py:25:20:25:24 | Str |
|
||||
| test.py:23:1:31:2 | FunctionExpr | test.py:25:28:25:31 | None |
|
||||
| test.py:23:1:31:2 | FunctionExpr | test.py:26:20:26:23 | None |
|
||||
| test.py:23:1:31:2 | FunctionExpr | test.py:29:32:29:35 | None |
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
| test.py:4:1:11:2 | FunctionExpr | Arguments | test.py:5:21:5:22 | UnaryExpr |
|
||||
| test.py:4:1:11:2 | FunctionExpr | Arguments | test.py:7:19:7:20 | UnaryExpr |
|
||||
| test.py:23:1:31:2 | FunctionExpr | Arguments | test.py:25:28:25:31 | None |
|
||||
| test.py:23:1:31:2 | FunctionExpr | Arguments | test.py:26:20:26:23 | None |
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
| test.py:4:1:11:2 | FunctionExpr | Arguments | test.py:9:25:9:26 | UnaryExpr |
|
||||
| test.py:23:1:31:2 | FunctionExpr | Arguments | test.py:29:32:29:35 | None |
|
||||
|
||||
@@ -18,3 +18,26 @@ func(1, 2, keyword_only=3)
|
||||
func(4, normal=5, keyword_only=6)
|
||||
|
||||
func(1, 2, "varargs0", "varargs1", keyword_only=3, kwargs0="0", kwargs1="1")
|
||||
|
||||
|
||||
def func2(
|
||||
pos_req,
|
||||
pos_w_default: "foo" = None,
|
||||
pos_w_default2=None,
|
||||
*,
|
||||
keyword_req,
|
||||
keyword_w_default: "foo" = None,
|
||||
keyword_also_req,
|
||||
):
|
||||
print("func2")
|
||||
print(
|
||||
pos_req,
|
||||
pos_w_default,
|
||||
pos_w_default2,
|
||||
keyword_req,
|
||||
keyword_w_default,
|
||||
keyword_also_req,
|
||||
)
|
||||
|
||||
|
||||
func2(1, keyword_req=2, keyword_also_req=3)
|
||||
|
||||
@@ -2,3 +2,4 @@
|
||||
| kwargs | test.py:10:15:10:30 | Str |
|
||||
| normal | test.py:7:13:7:15 | int |
|
||||
| pos_only | test.py:5:15:5:17 | int |
|
||||
| pos_w_default | test.py:25:20:25:24 | Str |
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
| normal | test.py:7:19:7:20 | UnaryExpr |
|
||||
| pos_only | test.py:5:21:5:22 | UnaryExpr |
|
||||
| pos_w_default | test.py:25:28:25:31 | None |
|
||||
| pos_w_default2 | test.py:26:20:26:23 | None |
|
||||
|
||||
@@ -2,3 +2,6 @@
|
||||
| kwargs | kwargs |
|
||||
| normal | normal |
|
||||
| pos_only | normal |
|
||||
| pos_req | normal |
|
||||
| pos_w_default | normal |
|
||||
| pos_w_default2 | normal |
|
||||
|
||||
@@ -18,3 +18,26 @@ func(1, 2, keyword_only=3)
|
||||
func(4, normal=5, keyword_only=6)
|
||||
|
||||
func(1, 2, "varargs0", "varargs1", keyword_only=3, kwargs0="0", kwargs1="1")
|
||||
|
||||
|
||||
def func2(
|
||||
pos_req,
|
||||
pos_w_default: "foo" = None,
|
||||
pos_w_default2=None,
|
||||
*,
|
||||
keyword_req,
|
||||
keyword_w_default: "foo" = None,
|
||||
keyword_also_req,
|
||||
):
|
||||
print("func2")
|
||||
print(
|
||||
pos_req,
|
||||
pos_w_default,
|
||||
pos_w_default2,
|
||||
keyword_req,
|
||||
keyword_w_default,
|
||||
keyword_also_req,
|
||||
)
|
||||
|
||||
|
||||
func2(1, keyword_req=2, keyword_also_req=3)
|
||||
|
||||
Reference in New Issue
Block a user