#PY-16228 fixed Enable PyArgumentEqualDefaultInspection for decorators
authorValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Wed, 23 Dec 2015 11:16:19 +0000 (14:16 +0300)
committerValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Thu, 24 Dec 2015 08:44:20 +0000 (11:44 +0300)
python/src/com/jetbrains/python/inspections/PyArgumentEqualDefaultInspection.java
python/testData/inspections/PyArgumentEqualDefaultInspection/test.py

index cd06a6d19e81f18abd9ecde5cbd8312a89cfdacf..97992f65e46e07111a5d61337a71687d2cde3b84 100644 (file)
@@ -80,6 +80,18 @@ public class PyArgumentEqualDefaultInspection extends PyInspection {
       checkArguments(node, node.getArguments());
     }
 
+    @Override
+    public void visitPyDecoratorList(final PyDecoratorList node) {
+      PyDecorator[] decorators = node.getDecorators();
+
+      for (PyDecorator decorator: decorators) {
+        if (decorator.hasArgumentList()) {
+          PyExpression[] arguments = decorator.getArguments();
+          checkArguments(decorator, arguments);
+        }
+      }
+    }
+
     private static boolean hasSpecialCasedDefaults(PyCallable callable, PsiElement anchor) {
       final String name = callable.getName();
       final PyBuiltinCache cache = PyBuiltinCache.getInstance(anchor);
index c53ac2b7a07c84449e716d0477110446cb78dcd0..27fc83beadbbd0baae8360d3a7c1f105b25bf4e9 100644 (file)
@@ -78,4 +78,11 @@ def f1(value=-1):
     print(value)
 
 def f2():
-    f1(value =-2)
\ No newline at end of file
+    f1(value =-2)
+
+def decorator(arg='baz'):
+    return lambda x: x
+
+@decorator(<weak_warning descr="Argument equals to default parameter value">arg='baz'</weak_warning>)
+def f<error descr="'(' expected">:</error>
+  pass
\ No newline at end of file