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 PyTypingTypeProvider to correctly handle `args: T1` and `kwargs: T2`, and wrap their types to `Tuple[T1, ...]` and `Dict[str, T2]`.
This commit is contained in:
@@ -31,7 +31,6 @@ import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.psi.PyExpression;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.intellij.lang.annotations.Language;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -736,6 +735,34 @@ public class PyTypingTest extends PyTestCase {
|
||||
"expr = (w, x, y, z)\n");
|
||||
}
|
||||
|
||||
// PY-19723
|
||||
public void testAnnotatedPositionalArgs() {
|
||||
doTest("Tuple[str, ...]",
|
||||
"def foo(*args: str):\n" +
|
||||
" expr = args\n");
|
||||
}
|
||||
|
||||
// PY-19723
|
||||
public void testAnnotatedKeywordArgs() {
|
||||
doTest("Dict[str, int]",
|
||||
"def foo(**kwargs: int):\n" +
|
||||
" expr = kwargs\n");
|
||||
}
|
||||
|
||||
// PY-19723
|
||||
public void testTypeCommentedPositionalArgs() {
|
||||
doTest("Tuple[str, ...]",
|
||||
"def foo(*args # type: str\n):\n" +
|
||||
" expr = args\n");
|
||||
}
|
||||
|
||||
// PY-19723
|
||||
public void testTypeCommentedKeywordArgs() {
|
||||
doTest("Dict[str, int]",
|
||||
"def foo(**kwargs # type: int\n):\n" +
|
||||
" expr = kwargs\n");
|
||||
}
|
||||
|
||||
private void doTestNoInjectedText(@NotNull String text) {
|
||||
myFixture.configureByText(PythonFileType.INSTANCE, text);
|
||||
final InjectedLanguageManager languageManager = InjectedLanguageManager.getInstance(myFixture.getProject());
|
||||
|
||||
Reference in New Issue
Block a user