Skip to content

Commit 1e3cb07

Browse files
committed
Improve support for Python arguments
1 parent 351bc64 commit 1e3cb07

File tree

1 file changed

+12
-2
lines changed
  • extensions/ql-vscode/src/model-editor/languages/python

1 file changed

+12
-2
lines changed

extensions/ql-vscode/src/model-editor/languages/python/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,26 @@ export const python: ModelsAsDataLanguage = {
177177
// Argument and Parameter are equivalent in Python, but we'll use Argument in the model editor
178178
const argumentsList = getArgumentsList(method.methodParameters).map(
179179
(argument, index): MethodArgument => {
180+
// Keyword-only arguments end with `:` in the query
180181
if (argument.endsWith(":")) {
181182
return {
182183
path: `Argument[${argument}]`,
183184
label: `Argument[${argument}]`,
184185
};
185186
}
186187

188+
// Positional-only arguments end with `/` in the query
189+
if (argument.endsWith("/")) {
190+
return {
191+
path: `Argument[${index}]`,
192+
label: `Argument[${index}]: ${argument.substring(0, argument.length - 1)}`,
193+
};
194+
}
195+
196+
// All other arguments are both keyword and positional
187197
return {
188-
path: `Argument[${index}]`,
189-
label: `Argument[${index}]: ${argument}`,
198+
path: `Argument[${index},${argument}:]`,
199+
label: `Argument[${index},${argument}:]: ${argument}`,
190200
};
191201
},
192202
);

0 commit comments

Comments
 (0)