PY-16968 Consider variadic keyword arguments mapped to keyword-only parameters

We already to it for regular (positional/keyword) parameters even
though (**kwargs) is not strictly compatible with (arg1, arg2, ...).
Now we do it for (*, kwarg1, kwarg2, ...). We don't know much about
**kwargs so it's better not to show any warnings here.
This commit is contained in:
Andrey Vlasovskikh
2017-08-21 20:14:08 +03:00
parent 458b828ad2
commit 235b76c552
3 changed files with 16 additions and 0 deletions
@@ -921,6 +921,7 @@ public class PyCallExpressionHelper {
}
else {
parametersMappedToVariadicKeywordArguments.add(parameter);
mappedVariadicArgumentsToParameters = true;
}
}
else {
@@ -0,0 +1,10 @@
def f1(arg):
return 2
def f2(*, arg):
return 2
def test(**kwargs):
f1(**kwargs)
f2(**kwargs)
@@ -322,6 +322,11 @@ public class PyArgumentListInspectionTest extends PyTestCase {
runWithLanguageLevel(LanguageLevel.PYTHON35, this::doTest);
}
// PY-16968
public void testKwargsAgainstKeywordOnly() {
runWithLanguageLevel(LanguageLevel.PYTHON36, this::doTest);
}
private void doMultiFileTest() {
final String folderPath = "inspections/PyArgumentListInspection/" + getTestName(false) + "/";