mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-19723 Fixed: Type hinting of arbitrary argument lists and default argument values
Update PyDocStringTypeProvider to correctly handle `:type args: T1` and `:type kwargs: T2`, and wrap their types to `Tuple[T1, ...]` and `Dict[str, T2]`.
This commit is contained in:
@@ -1428,6 +1428,26 @@ public class PyTypeTest extends PyTestCase {
|
||||
"expr = raw_input()");
|
||||
}
|
||||
|
||||
// PY-19723
|
||||
public void testPositionalArgs() {
|
||||
doTest("Tuple[int, ...]",
|
||||
"def foo(*args):\n" +
|
||||
" \"\"\"\n" +
|
||||
" :type args: int\n" +
|
||||
" \"\"\"\n" +
|
||||
" expr = args");
|
||||
}
|
||||
|
||||
// PY-19723
|
||||
public void testKeywordArgs() {
|
||||
doTest("Dict[str, int]",
|
||||
"def foo(**kwargs):\n" +
|
||||
" \"\"\"\n" +
|
||||
" :type kwargs: int\n" +
|
||||
" \"\"\"\n" +
|
||||
" expr = kwargs");
|
||||
}
|
||||
|
||||
private static List<TypeEvalContext> getTypeEvalContexts(@NotNull PyExpression element) {
|
||||
return ImmutableList.of(TypeEvalContext.codeAnalysis(element.getProject(), element.getContainingFile()).withTracing(),
|
||||
TypeEvalContext.userInitiated(element.getProject(), element.getContainingFile()).withTracing());
|
||||
|
||||
Reference in New Issue
Block a user