diff --git a/python/python-psi-api/resources/META-INF/PythonPsi.xml b/python/python-psi-api/resources/META-INF/PythonPsi.xml
index cc455adc1a3d..bb647d9a4f0d 100644
--- a/python/python-psi-api/resources/META-INF/PythonPsi.xml
+++ b/python/python-psi-api/resources/META-INF/PythonPsi.xml
@@ -36,6 +36,9 @@
+
EP_NAME = ExtensionPointName.create("Pythonid.statementEffectQuickFixProvider");
+
+
+ @Nullable
+ LocalQuickFix getQuickFix(@NotNull PyExpressionStatement expressionStatement);
+}
\ No newline at end of file
diff --git a/python/python-psi-impl/resources/messages/PyPsiBundle.properties b/python/python-psi-impl/resources/messages/PyPsiBundle.properties
index efb06daeb10a..36396345e88a 100644
--- a/python/python-psi-impl/resources/messages/PyPsiBundle.properties
+++ b/python/python-psi-impl/resources/messages/PyPsiBundle.properties
@@ -1147,7 +1147,7 @@ INSP.typeddict.required.notrequired.must.have.exactly.one.type.argument=''{0}''
# PyTypeHintsInspection
INSP.NAME.type.hints=Invalid type hints definitions and usages
INSP.type.hints.builtin.cannot.be.parameterized.directly=Builtin ''{0}'' cannot be parameterized directly
-INSP.type.hints.typing.self.cannot.be.parameterized='Self' cannot be parameterized
+INSP.type.hints.typing.self.cannot.be.parameterized='Self' cannot be parameterized
INSP.type.hints.invalid.type.self=Invalid type 'self'
INSP.type.hints.literal.must.have.at.least.one.parameter='Literal' must have at least one parameter
INSP.type.hints.annotated.must.be.called.with.at.least.two.arguments='Annotated' must be called with at least two arguments
diff --git a/python/python-psi-impl/src/com/jetbrains/python/inspections/PyStatementEffectInspection.java b/python/python-psi-impl/src/com/jetbrains/python/inspections/PyStatementEffectInspection.java
index 193fb814efcc..143ce2c1c74f 100644
--- a/python/python-psi-impl/src/com/jetbrains/python/inspections/PyStatementEffectInspection.java
+++ b/python/python-psi-impl/src/com/jetbrains/python/inspections/PyStatementEffectInspection.java
@@ -16,10 +16,12 @@
package com.jetbrains.python.inspections;
import com.intellij.codeInspection.LocalInspectionToolSession;
+import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.ResolveResult;
import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
import com.jetbrains.python.PyPsiBundle;
import com.jetbrains.python.PyTokenTypes;
@@ -31,6 +33,8 @@ import com.jetbrains.python.psi.types.TypeEvalContext;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.util.List;
+
public class PyStatementEffectInspection extends PyInspection {
@NotNull
@@ -73,13 +77,13 @@ public class PyStatementEffectInspection extends PyInspection {
return;
}
}
- if (expression instanceof PyReferenceExpression && !((PyReferenceExpression)expression).isQualified()) {
- registerProblem(expression, PyPsiBundle.message("INSP.statement.effect.statement.seems.to.have.no.effect"));
- }
- else {
- registerProblem(expression, PyPsiBundle.message("INSP.statement.effect.statement.seems.to.have.no.effect"),
- new StatementEffectIntroduceVariableQuickFix());
+ List quickFixes = new SmartList<>(getQuickFixesFromExtensions(node));
+ if (!(expression instanceof PyReferenceExpression reference) || reference.isQualified()) {
+ quickFixes.add(new StatementEffectIntroduceVariableQuickFix());
}
+ registerProblem(expression,
+ PyPsiBundle.message("INSP.statement.effect.statement.seems.to.have.no.effect"),
+ quickFixes.toArray(LocalQuickFix.EMPTY_ARRAY));
}
private boolean hasEffect(@Nullable PyExpression expression) {
@@ -157,4 +161,10 @@ public class PyStatementEffectInspection extends PyInspection {
return false;
}
}
+
+ @NotNull
+ private static List getQuickFixesFromExtensions(@NotNull PyExpressionStatement expressionStatement) {
+ return ContainerUtil.mapNotNull(PyStatementEffectQuickFixProvider.EP_NAME.getExtensionList(),
+ extension -> extension.getQuickFix(expressionStatement));
+ }
}