diff --git a/python/src/com/jetbrains/python/inspections/PyUnusedLocalInspectionVisitor.java b/python/src/com/jetbrains/python/inspections/PyUnusedLocalInspectionVisitor.java
index 31e1f17de58d..35f9b1baa775 100644
--- a/python/src/com/jetbrains/python/inspections/PyUnusedLocalInspectionVisitor.java
+++ b/python/src/com/jetbrains/python/inspections/PyUnusedLocalInspectionVisitor.java
@@ -224,10 +224,10 @@ public class PyUnusedLocalInspectionVisitor extends PyInspectionVisitor {
}
}
- private void analyzeReadsInScope(@NotNull String name,
+ private void analyzeReadsInScope(@NotNull String name,
@NotNull ScopeOwner owner,
@NotNull Instruction[] instructions,
- int startInstruction,
+ int startInstruction,
@Nullable PsiElement scopeAnchor) {
// Check if the element is declared out of scope, mark all out of scope write accesses as used
if (scopeAnchor != null) {
@@ -343,10 +343,8 @@ public class PyUnusedLocalInspectionVisitor extends PyInspectionVisitor {
if (paramList != null && paramList.getParent() instanceof PyFunction) {
final PyFunction func = (PyFunction) paramList.getParent();
containingClass = func.getContainingClass();
- if (PyNames.INIT.equals(func.getName()) && containingClass != null) {
- if (!namedParameter.isKeywordContainer() && !namedParameter.isPositionalContainer()) {
- mayBeField = true;
- }
+ if (PyNames.INIT.equals(func.getName()) && containingClass != null && !namedParameter.isKeywordContainer() && !namedParameter.isPositionalContainer()) {
+ mayBeField = true;
}
else if (ignoreUnusedParameters(func, functionsWithInheritors)) {
continue;
@@ -412,7 +410,7 @@ public class PyUnusedLocalInspectionVisitor extends PyInspectionVisitor {
if (functionsWithInheritors.contains(func)) {
return true;
}
- if (PySuperMethodsSearch.search(func, myTypeEvalContext).findFirst() != null ||
+ if (!PyNames.INIT.equals(func.getName()) && PySuperMethodsSearch.search(func, myTypeEvalContext).findFirst() != null ||
PyOverridingMethodsSearch.search(func, true).findFirst() != null) {
functionsWithInheritors.add(func);
return true;
diff --git a/python/testData/inspections/PyUnusedParameterInspection/test.py b/python/testData/inspections/PyUnusedParameterInspection/test.py
new file mode 100644
index 000000000000..2f8e4653951e
--- /dev/null
+++ b/python/testData/inspections/PyUnusedParameterInspection/test.py
@@ -0,0 +1,30 @@
+# PY-19491
+class A(object):
+ def __init__(self, *args, **kwargs):
+ self.foo = "foo"
+
+
+
+# PY-19491
+class B(object):
+ def __init__(self, *args, **kwargs):
+ self.foo = "foo"
+
+
+# PY-19491
+class C(B):
+ pass
+
+
+
+# PY-19491
+class D(object):
+ def __init__(self, *args, **kwargs):
+ self.foo = "foo"
+
+
+# PY-19491
+class E(D):
+ def __init__(self, *args, **kwargs):
+ super(E, self).__init__(*args, **kwargs)
+
diff --git a/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java b/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java
index f301e4ec0f20..c6a3ee5e4bf5 100644
--- a/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java
+++ b/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -114,6 +114,10 @@ public class PythonInspectionsTest extends PyTestCase {
doHighlightingTest(PyUnusedLocalInspection.class, LanguageLevel.PYTHON34);
}
+ public void testPyUnusedParameterInspection() {
+ doHighlightingTest(PyUnusedLocalInspection.class);
+ }
+
// PY-20805
public void testUnusedLocalFStringReferences() {
doHighlightingTest(PyUnusedLocalInspection.class, LanguageLevel.PYTHON36);