mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed PY-3245 Should complain about named param after *args on Python ≤2.5
This commit is contained in:
@@ -430,6 +430,17 @@ public abstract class CompatibilityVisitor extends PyAnnotator {
|
||||
super.visitPyCallExpression(node);
|
||||
int len = 0;
|
||||
StringBuilder message = new StringBuilder(myCommonMessage);
|
||||
|
||||
if (myVersionsToProcess.contains(LanguageLevel.PYTHON24) || myVersionsToProcess.contains(LanguageLevel.PYTHON25)) {
|
||||
boolean hasStar = false;
|
||||
for (PyExpression argument : node.getArguments()) {
|
||||
if (hasStar && argument instanceof PyKeywordArgument) {
|
||||
registerProblem(argument, "Python version < 2.6 doesn't support this syntax. Named parameter cannot appear past *arg or **kwarg.");
|
||||
}
|
||||
if (argument instanceof PyStarArgument) hasStar = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i != myVersionsToProcess.size(); ++i) {
|
||||
LanguageLevel languageLevel = myVersionsToProcess.get(i);
|
||||
if (!languageLevel.isPy3K()) {
|
||||
|
||||
@@ -6,4 +6,11 @@ class A(B):
|
||||
<warning descr="Python version 3.0, 3.1 do not have method reduce">reduce()</warning>
|
||||
<warning descr="Python version 2.4 does not have method all">all()</warning>
|
||||
|
||||
<warning descr="Python version 3.0, 3.1 do not have method buffer">buffer()</warning>
|
||||
<warning descr="Python version 3.0, 3.1 do not have method buffer">buffer()</warning>
|
||||
|
||||
def foo(a,b,c):
|
||||
print (a,b,c)
|
||||
|
||||
args=['b']
|
||||
foo('a', c='c', *args) # OK
|
||||
foo('a', *args, <warning descr="Python version < 2.6 doesn't support this syntax. Named parameter cannot appear past *arg or **kwarg.">c='c'</warning>) # Not OK
|
||||
@@ -49,7 +49,13 @@ public class PyArgumentListInspectionTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testPy1268() {
|
||||
doTest();
|
||||
PythonLanguageLevelPusher.setForcedLanguageLevel(myFixture.getProject(), LanguageLevel.PYTHON30);
|
||||
try {
|
||||
doTest();
|
||||
}
|
||||
finally {
|
||||
PythonLanguageLevelPusher.setForcedLanguageLevel(myFixture.getProject(), null);
|
||||
}
|
||||
}
|
||||
|
||||
public void testInstanceMethodAsLambda() {
|
||||
|
||||
Reference in New Issue
Block a user