-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Python: properly support keyword only arguments #3362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ce2d7fe
Python: Improve QLDoc for Arguments
RasmusWL 96b36a7
Python: Clean up some QLdocs
RasmusWL 0cc8d49
Python: Add tests for full Python 3 parameters syntax
RasmusWL 4185edc
Python: Expand parameters/functions test
RasmusWL c508e89
Python: Handle keyword-only arguments properly
RasmusWL 8c1cfe5
Python: Use `getAKeywordOnlyArg` instead of `getAKwonlyarg`
RasmusWL 5f60583
Python: Improve QLdoc for Parameter.getPosition
RasmusWL 1fcbb6e
Python: Better test for Argument.getDefault(i)
RasmusWL c5e14f5
Python: Handle defaults and annotations for keyword-only arguments
RasmusWL 16e9d76
Merge branch 'master' into python-keyword-only-args
RasmusWL a15833d
Python: DB upgrade script for default-indexing change
RasmusWL 010d5fb
Python: Fix indexes of keyword-only defaults in upgrade script
RasmusWL f163098
Python: Cleanup default-indexing upgrade script
RasmusWL f099e0f
Merge branch 'master' into python-keyword-only-args
RasmusWL 8fc803f
Merge branch 'master' into python-keyword-only-args
RasmusWL a616704
Python: Fix typo
RasmusWL 5a18b08
Python: Add comment explaining kw-only default index upgrade
RasmusWL c78ca26
Merge branch 'master' into python-keyword-only-args
RasmusWL 26b7a30
Merge branch 'master' into python-keyword-only-args
RasmusWL b2f8638
Python: Update dbscheme with new comment
RasmusWL 513c297
Merge branch 'master' into python-keyword-only-args
RasmusWL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
16 changes: 16 additions & 0 deletions
16
python/ql/test/3/library-tests/functions/Function.getAChildNode.expected
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
| test.py:4:1:11:2 | Function func | test.py:5:5:5:12 | pos_only | | ||
| test.py:4:1:11:2 | Function func | test.py:7:5:7:10 | normal | | ||
| test.py:4:1:11:2 | Function func | test.py:8:6:8:9 | args | | ||
| test.py:4:1:11:2 | Function func | test.py:9:5:9:16 | keyword_only | | ||
| test.py:4:1:11:2 | Function func | test.py:10:7:10:12 | kwargs | | ||
| 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:28:5:28:15 | keyword_req | | ||
| test.py:23:1:31:2 | Function func2 | test.py:29:5:29:21 | keyword_w_default | | ||
| test.py:23:1:31:2 | Function func2 | test.py:30:5:30:20 | keyword_also_req | | ||
| 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 | |
4 changes: 4 additions & 0 deletions
4
python/ql/test/3/library-tests/functions/Function.getAChildNode.ql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import python | ||
|
||
from Function f | ||
select f, f.getAChildNode() |
5 changes: 5 additions & 0 deletions
5
python/ql/test/3/library-tests/functions/Function.getArg.expected
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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 | |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import python | ||
|
||
from Function f, int i | ||
select f, i, f.getArg(i) |
9 changes: 9 additions & 0 deletions
9
python/ql/test/3/library-tests/functions/Function.getArgByName.expected
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
| test.py:4:1:11:2 | Function func | keyword_only | test.py:9:5:9:16 | Parameter | | ||
| 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 | keyword_also_req | test.py:30:5:30:20 | Parameter | | ||
| test.py:23:1:31:2 | Function func2 | keyword_req | test.py:28:5:28:15 | Parameter | | ||
| test.py:23:1:31:2 | Function func2 | keyword_w_default | test.py:29:5:29:21 | 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 | |
4 changes: 4 additions & 0 deletions
4
python/ql/test/3/library-tests/functions/Function.getArgByName.ql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import python | ||
|
||
from Function f, string name | ||
select f, name, f.getArgByName(name) |
13 changes: 13 additions & 0 deletions
13
python/ql/test/3/library-tests/functions/FunctionExpr.getASubExpression.expected
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
| test.py:4:1:11:2 | FunctionExpr | test.py:5:15:5:17 | int | | ||
| test.py:4:1:11:2 | FunctionExpr | test.py:5:21:5:22 | UnaryExpr | | ||
| test.py:4:1:11:2 | FunctionExpr | test.py:7:13:7:15 | int | | ||
| test.py:4:1:11:2 | FunctionExpr | test.py:7:19:7:20 | UnaryExpr | | ||
| test.py:4:1:11:2 | FunctionExpr | test.py:8:12:8:23 | Str | | ||
| test.py:4:1:11:2 | FunctionExpr | test.py:9:19:9:21 | int | | ||
| 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:24:29:28 | Str | | ||
| test.py:23:1:31:2 | FunctionExpr | test.py:29:32:29:35 | None | |
4 changes: 4 additions & 0 deletions
4
python/ql/test/3/library-tests/functions/FunctionExpr.getASubExpression.ql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import python | ||
|
||
from FunctionExpr fe | ||
select fe, fe.getASubExpression() |
3 changes: 3 additions & 0 deletions
3
python/ql/test/3/library-tests/functions/FunctionExpr.getArgs.getAnnotation.expected
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
| test.py:4:1:11:2 | FunctionExpr | 0 | test.py:5:15:5:17 | int | | ||
| test.py:4:1:11:2 | FunctionExpr | 1 | test.py:7:13:7:15 | int | | ||
| test.py:23:1:31:2 | FunctionExpr | 1 | test.py:25:20:25:24 | Str | |
4 changes: 4 additions & 0 deletions
4
python/ql/test/3/library-tests/functions/FunctionExpr.getArgs.getAnnotation.ql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import python | ||
|
||
from FunctionExpr fe, int i | ||
select fe, i, fe.getArgs().getAnnotation(i) |
4 changes: 4 additions & 0 deletions
4
python/ql/test/3/library-tests/functions/FunctionExpr.getArgs.getDefault.expected
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
| test.py:4:1:11:2 | FunctionExpr | 0 | test.py:5:21:5:22 | UnaryExpr | | ||
| test.py:4:1:11:2 | FunctionExpr | 1 | test.py:7:19:7:20 | UnaryExpr | | ||
| test.py:23:1:31:2 | FunctionExpr | 1 | test.py:25:28:25:31 | None | | ||
| test.py:23:1:31:2 | FunctionExpr | 2 | test.py:26:20:26:23 | None | |
4 changes: 4 additions & 0 deletions
4
python/ql/test/3/library-tests/functions/FunctionExpr.getArgs.getDefault.ql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import python | ||
|
||
from FunctionExpr fe, int i | ||
select fe, i, fe.getArgs().getDefault(i) |
2 changes: 2 additions & 0 deletions
2
python/ql/test/3/library-tests/functions/FunctionExpr.getArgs.getKwAnnotation.expected
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
| test.py:4:1:11:2 | FunctionExpr | 0 | test.py:9:19:9:21 | int | | ||
| test.py:23:1:31:2 | FunctionExpr | 1 | test.py:29:24:29:28 | Str | |
4 changes: 4 additions & 0 deletions
4
python/ql/test/3/library-tests/functions/FunctionExpr.getArgs.getKwAnnotation.ql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import python | ||
|
||
from FunctionExpr fe, int i | ||
select fe, i, fe.getArgs().getKwAnnotation(i) |
2 changes: 2 additions & 0 deletions
2
python/ql/test/3/library-tests/functions/FunctionExpr.getArgs.getKwDefault.expected
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
| test.py:4:1:11:2 | FunctionExpr | 0 | test.py:9:25:9:26 | UnaryExpr | | ||
| test.py:23:1:31:2 | FunctionExpr | 1 | test.py:29:32:29:35 | None | |
4 changes: 4 additions & 0 deletions
4
python/ql/test/3/library-tests/functions/FunctionExpr.getArgs.getKwDefault.ql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import python | ||
|
||
from FunctionExpr fe, int i | ||
select fe, i, fe.getArgs().getKwDefault(i) |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.