From df135fc4fb997dff7c92a5a6af5acdca3b361706 Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Thu, 19 Sep 2013 20:57:12 +0400 Subject: [PATCH] Disabled call arguments inspection for decorated functions (PY-10601) --- .../inspections/PyArgumentListInspection.java | 13 ++++++++++++- .../decoratedChangedParameters.py | 10 ++++++++++ .../inspections/PyArgumentListInspectionTest.java | 5 +++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 python/testData/inspections/PyArgumentListInspection/decoratedChangedParameters.py diff --git a/python/src/com/jetbrains/python/inspections/PyArgumentListInspection.java b/python/src/com/jetbrains/python/inspections/PyArgumentListInspection.java index b6c5b7be30a2..d412d23e2ea6 100644 --- a/python/src/com/jetbrains/python/inspections/PyArgumentListInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyArgumentListInspection.java @@ -10,7 +10,10 @@ import com.jetbrains.python.PyNames; import com.jetbrains.python.PyTokenTypes; import com.jetbrains.python.psi.*; import com.jetbrains.python.psi.resolve.PyResolveContext; -import com.jetbrains.python.psi.types.*; +import com.jetbrains.python.psi.types.PyABCUtil; +import com.jetbrains.python.psi.types.PyType; +import com.jetbrains.python.psi.types.PyTypeChecker; +import com.jetbrains.python.psi.types.TypeEvalContext; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; @@ -88,6 +91,14 @@ public class PyArgumentListInspection extends PyInspection { public static void inspectPyArgumentList(PyArgumentList node, ProblemsHolder holder, final TypeEvalContext context, int implicitOffset) { if (node.getParent() instanceof PyClass) return; // class Foo(object) is also an arg list CallArgumentsMapping result = node.analyzeCall(PyResolveContext.noImplicits().withTypeEvalContext(context), implicitOffset); + final PyCallExpression.PyMarkedCallee callee = result.getMarkedCallee(); + if (callee != null) { + final Callable callable = callee.getCallable(); + // Decorate functions may have different parameter lists. We don't match arguments with parameters of decorators yet + if (callable instanceof PyFunction && PyUtil.hasCustomDecorators((PyFunction)callable)) { + return; + } + } highlightIncorrectArguments(holder, result, context); highlightMissingArguments(node, holder, result); highlightStarArgumentTypeMismatch(node, holder, context); diff --git a/python/testData/inspections/PyArgumentListInspection/decoratedChangedParameters.py b/python/testData/inspections/PyArgumentListInspection/decoratedChangedParameters.py new file mode 100644 index 000000000000..83f7873005f4 --- /dev/null +++ b/python/testData/inspections/PyArgumentListInspection/decoratedChangedParameters.py @@ -0,0 +1,10 @@ +def fill(f): + return lambda: f('test') + + +@fill +def test(x): + return x + + +test() diff --git a/python/testSrc/com/jetbrains/python/inspections/PyArgumentListInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyArgumentListInspectionTest.java index 1c441fcb3533..b9e9cb53b3d3 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyArgumentListInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyArgumentListInspectionTest.java @@ -133,4 +133,9 @@ public class PyArgumentListInspectionTest extends PyTestCase { public void testFloatConstructor() { doTest(); } + + // PY-10601 + public void testDecoratedChangedParameters() { + doTest(); + } }