mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-9687 PyUnusedLocalVariableInspection: rename to address flakey test
(cherry picked from commit 152b66d4f65a8c3095ad4b4bd36964c14e9bad28) GitOrigin-RevId: fb050cb0677b70be3fc81ddf370241e9d98d6423
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1b2d29fa8c
commit
aed26f4a71
@@ -233,7 +233,7 @@
|
||||
"codeQualityCategory": "Reliability"
|
||||
},
|
||||
{
|
||||
"id": "PyUnusedLocalInspection",
|
||||
"id": "PyUnusedLocalVariableInspection",
|
||||
"codeQualityCategory": "Code Style"
|
||||
},
|
||||
{
|
||||
|
||||
@@ -198,9 +198,10 @@
|
||||
|
||||
<statistics.applicationUsagesCollector implementation="com.jetbrains.python.psi.types.PyTypeEvaluationAggregatesCollector"/>
|
||||
|
||||
<localInspection language="Python" shortName="PyUnusedLocalInspection" suppressId="PyUnusedLocal" bundle="messages.PyPsiBundle" key="INSP.NAME.unused" groupKey="INSP.GROUP.python" enabledByDefault="true" level="WEAK WARNING" implementationClass="com.jetbrains.python.inspections.unusedLocal.PyUnusedLocalInspection"/>
|
||||
<localInspection language="Python" shortName="PyUnusedLocalVariableInspection" suppressId="PyUnusedLocal" bundle="messages.PyPsiBundle" key="INSP.NAME.unused" groupKey="INSP.GROUP.python" enabledByDefault="true" level="WEAK WARNING" implementationClass="com.jetbrains.python.inspections.unusedLocal.PyUnusedLocalVariableInspection"/>
|
||||
<localInspection language="Python" shortName="PyUnusedParameterInspection" suppressId="PyUnusedParameter" bundle="messages.PyPsiBundle" key="INSP.NAME.unused.parameter" groupKey="INSP.GROUP.python" enabledByDefault="true" level="WEAK WARNING" implementationClass="com.jetbrains.python.inspections.unusedLocal.PyUnusedParameterInspection"/>
|
||||
<localInspection language="Python" shortName="PyUnusedFunctionInspection" suppressId="PyUnusedFunction" bundle="messages.PyPsiBundle" key="INSP.NAME.unused.function" groupKey="INSP.GROUP.python" enabledByDefault="true" level="WEAK WARNING" implementationClass="com.jetbrains.python.inspections.unusedLocal.PyUnusedFunctionInspection"/>
|
||||
<inspectionElementsMerger implementation="com.jetbrains.python.inspections.unusedLocal.PyUnusedLocalVariableInspectionMerger"/>
|
||||
<inspectionElementsMerger implementation="com.jetbrains.python.inspections.unusedLocal.PyUnusedParameterInspectionMerger"/>
|
||||
<inspectionElementsMerger implementation="com.jetbrains.python.inspections.unusedLocal.PyUnusedFunctionInspectionMerger"/>
|
||||
<localInspection language="Python" shortName="PyRedundantParenthesesInspection" suppressId="PyRedundantParentheses" bundle="messages.PyPsiBundle" key="INSP.NAME.redundant.parentheses" groupKey="INSP.GROUP.python" enabledByDefault="true" level="WEAK WARNING" implementationClass="com.jetbrains.python.inspections.PyRedundantParenthesesInspection"/>
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package com.jetbrains.python.inspections.unusedLocal
|
||||
|
||||
/**
|
||||
* Reports unused local functions. Unused local variables and other local symbols are reported separately by
|
||||
* [PyUnusedLocalInspection]; both inspections share [PyUnusedLocalInspectionVisitor] for the analysis.
|
||||
* [PyUnusedLocalVariableInspection]; both inspections share [PyUnusedLocalInspectionVisitor] for the analysis.
|
||||
*/
|
||||
class PyUnusedFunctionInspection : PyUnusedSymbolInspection() {
|
||||
override val reportTarget: PyUnusedLocalInspectionVisitor.ReportTarget
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import static com.intellij.codeInspection.options.OptPane.checkbox;
|
||||
import static com.intellij.codeInspection.options.OptPane.pane;
|
||||
|
||||
public final class PyUnusedLocalInspection extends PyInspection {
|
||||
public final class PyUnusedLocalVariableInspection extends PyInspection {
|
||||
private static final Key<PyUnusedLocalInspectionVisitor> KEY = Key.create("PyUnusedLocal.Visitor");
|
||||
|
||||
public boolean ignoreTupleUnpacking = true;
|
||||
+1
-1
@@ -7,7 +7,7 @@ import com.jetbrains.python.PyPsiBundle
|
||||
|
||||
/**
|
||||
* Reports unused function parameters. Unused local variables and other local symbols are reported separately by
|
||||
* [PyUnusedLocalInspection]; both inspections share [PyUnusedLocalInspectionVisitor] for the analysis.
|
||||
* [PyUnusedLocalVariableInspection]; both inspections share [PyUnusedLocalInspectionVisitor] for the analysis.
|
||||
*/
|
||||
class PyUnusedParameterInspection : PyUnusedSymbolInspection() {
|
||||
@JvmField
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ import com.jetbrains.python.inspections.PyInspectionVisitor
|
||||
* Base class for the unused-parameter and unused-function inspections. Both report a single kind of unused symbol via the shared
|
||||
* [PyUnusedLocalInspectionVisitor]; the actual control-flow analysis is shared across all unused-symbol inspections running on the
|
||||
* same session (see [PyUnusedLocalInspectionVisitor.SharedAnalysis]). Unused local variables and other local symbols are reported
|
||||
* separately by [PyUnusedLocalInspection].
|
||||
* separately by [PyUnusedLocalVariableInspection].
|
||||
*/
|
||||
abstract class PyUnusedSymbolInspection : PyInspection() {
|
||||
private val visitorKey = Key.create<PyUnusedLocalInspectionVisitor>("${javaClass.simpleName}.Visitor")
|
||||
|
||||
+14
-6
@@ -6,13 +6,16 @@ import org.jdom.Element
|
||||
|
||||
/**
|
||||
* Migrates user inspection-profile settings (enabled state, severity, and shared options such as `ignoreLambdaParameters`) from
|
||||
* the former combined `PyUnusedLocalInspection` to the inspection that took over part of its reporting after PY-9687 split it into
|
||||
* separate unused-local / unused-parameter / unused-function inspections. Without this, a user who had disabled or reconfigured
|
||||
* `PyUnusedLocalInspection` would silently get the new inspections back at their defaults.
|
||||
* the former combined `PyUnusedLocalInspection` to one of the inspections it was split into by PY-9687: the unused local-variable,
|
||||
* unused-parameter, and unused-function inspections. Without this, a user who had disabled or reconfigured `PyUnusedLocalInspection`
|
||||
* would silently get the new inspections back at their defaults.
|
||||
*
|
||||
* Suppression is intentionally NOT inherited: `# noinspection PyUnusedLocal` no longer silences parameters or functions (the split
|
||||
* is a deliberate clean break), so [getSuppressIds] returns only this inspection's own id instead of letting the base fall back to
|
||||
* the source tool name.
|
||||
* `PyUnusedLocalInspection` is deliberately no longer a live inspection short name — it is retired into a pure migration source.
|
||||
* If it stayed live it would consume its own serialized settings while it initialized, and because inspection initialization order
|
||||
* is not deterministic the mergers would often run after the settings were already gone, dropping the migration.
|
||||
*
|
||||
* Suppression is intentionally NOT inherited across the split: each merged inspection only answers to its own suppress id, so
|
||||
* [getSuppressIds] returns that id instead of letting the base fall back to the source tool name.
|
||||
*/
|
||||
abstract class PyUnusedSymbolInspectionMerger : InspectionElementsMergerBase() {
|
||||
/** Suppress id of the merged (new) inspection. */
|
||||
@@ -48,6 +51,11 @@ abstract class PyUnusedSymbolInspectionMerger : InspectionElementsMergerBase() {
|
||||
}
|
||||
}
|
||||
|
||||
class PyUnusedLocalVariableInspectionMerger : PyUnusedSymbolInspectionMerger() {
|
||||
override fun getMergedToolName(): String = "PyUnusedLocalVariableInspection"
|
||||
override val mergedSuppressId: String get() = "PyUnusedLocal"
|
||||
}
|
||||
|
||||
class PyUnusedParameterInspectionMerger : PyUnusedSymbolInspectionMerger() {
|
||||
override fun getMergedToolName(): String = "PyUnusedParameterInspection"
|
||||
override val mergedSuppressId: String get() = "unused-parameter"
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.jetbrains.python.inspections.PySingleQuotedDocstringInspection;
|
||||
import com.jetbrains.python.inspections.PyStatementEffectInspection;
|
||||
import com.jetbrains.python.inspections.PyUnboundLocalVariableInspection;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedFunctionInspection;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedLocalInspection;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedLocalVariableInspection;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedParameterInspection;
|
||||
import com.jetbrains.python.psi.PythonVisitorFilter;
|
||||
import com.jetbrains.python.validation.PyDocStringHighlightingAnnotator;
|
||||
@@ -28,7 +28,7 @@ final class ConsoleVisitorFilter implements PythonVisitorFilter {
|
||||
//if we're in console
|
||||
if (PydevConsoleRunnerUtil.isInPydevConsole(file)) {
|
||||
//inspections
|
||||
if (visitorClass == PyUnusedLocalInspection.class || visitorClass == PyUnusedParameterInspection.class ||
|
||||
if (visitorClass == PyUnusedLocalVariableInspection.class || visitorClass == PyUnusedParameterInspection.class ||
|
||||
visitorClass == PyUnusedFunctionInspection.class || visitorClass == PyUnboundLocalVariableInspection.class ||
|
||||
visitorClass == PyStatementEffectInspection.class || visitorClass == PySingleQuotedDocstringInspection.class ||
|
||||
visitorClass == PyIncorrectDocstringInspection.class || visitorClass == PyMissingOrEmptyDocstringInspection.class ||
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.jetbrains.python.inspections.PyShadowingBuiltinsInspection;
|
||||
import com.jetbrains.python.inspections.PyStatementEffectInspection;
|
||||
import com.jetbrains.python.inspections.PyTypeCheckerInspection;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedFunctionInspection;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedLocalInspection;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedLocalVariableInspection;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedParameterInspection;
|
||||
import com.jetbrains.python.psi.PythonVisitorFilter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -21,7 +21,7 @@ import java.util.Set;
|
||||
public final class PyiVisitorFilter implements PythonVisitorFilter {
|
||||
|
||||
private static final @NotNull Set<Class<?>> disabledVisitors = ImmutableSet.of(
|
||||
PyUnusedLocalInspection.class,
|
||||
PyUnusedLocalVariableInspection.class,
|
||||
PyUnusedParameterInspection.class,
|
||||
PyUnusedFunctionInspection.class,
|
||||
PyStatementEffectInspection.class,
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
import com.jetbrains.python.inspections.PyInspection;
|
||||
import com.jetbrains.python.inspections.unresolvedReference.PyUnresolvedReferencesInspection;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedLocalInspection;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedLocalVariableInspection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class PySuppressInspectionsTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testSuppressedUnusedLocal() {
|
||||
doTestHighlighting(PyUnusedLocalInspection.class);
|
||||
doTestHighlighting(PyUnusedLocalVariableInspection.class);
|
||||
}
|
||||
|
||||
public void testSuppressForImport() { // PY-2240
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.idea.TestFor;
|
||||
import com.jetbrains.python.fixtures.PyInspectionTestCase;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedFunctionInspection;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedLocalInspection;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedLocalVariableInspection;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedParameterInspection;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -29,7 +29,7 @@ import java.util.List;
|
||||
public class PyUnusedLocalInspectionTest extends PyInspectionTestCase {
|
||||
|
||||
public void testPy2() {
|
||||
final PyUnusedLocalInspection inspection = new PyUnusedLocalInspection();
|
||||
final PyUnusedLocalVariableInspection inspection = new PyUnusedLocalVariableInspection();
|
||||
inspection.ignoreTupleUnpacking = false;
|
||||
final PyUnusedParameterInspection parameterInspection = new PyUnusedParameterInspection();
|
||||
parameterInspection.ignoreLambdaParameters = false;
|
||||
@@ -139,21 +139,21 @@ public class PyUnusedLocalInspectionTest extends PyInspectionTestCase {
|
||||
|
||||
// PY-27435
|
||||
public void testVariableStartingWithUnderscore() {
|
||||
final PyUnusedLocalInspection inspection = new PyUnusedLocalInspection();
|
||||
final PyUnusedLocalVariableInspection inspection = new PyUnusedLocalVariableInspection();
|
||||
inspection.ignoreVariablesStartingWithUnderscore = false;
|
||||
doTest(inspection);
|
||||
}
|
||||
|
||||
// PY-20893
|
||||
public void testExceptionTargetStartingWithUnderscore() {
|
||||
final PyUnusedLocalInspection inspection = new PyUnusedLocalInspection();
|
||||
final PyUnusedLocalVariableInspection inspection = new PyUnusedLocalVariableInspection();
|
||||
inspection.ignoreVariablesStartingWithUnderscore = true;
|
||||
doTest(inspection);
|
||||
}
|
||||
|
||||
// PY-31388
|
||||
public void testIgnoringVariablesStartingWithUnderscore() {
|
||||
final PyUnusedLocalInspection inspection = new PyUnusedLocalInspection();
|
||||
final PyUnusedLocalVariableInspection inspection = new PyUnusedLocalVariableInspection();
|
||||
inspection.ignoreVariablesStartingWithUnderscore = true;
|
||||
inspection.ignoreLoopIterationVariables = false;
|
||||
inspection.ignoreTupleUnpacking = false;
|
||||
@@ -312,7 +312,7 @@ def test():
|
||||
@NotNull
|
||||
@Override
|
||||
protected Class<? extends PyInspection> getInspectionClass() {
|
||||
return PyUnusedLocalInspection.class;
|
||||
return PyUnusedLocalVariableInspection.class;
|
||||
}
|
||||
|
||||
// Parameter and function reporting now live in separate inspections; enable them too so the shared testData keeps matching.
|
||||
@@ -322,12 +322,12 @@ def test():
|
||||
return List.of(PyUnusedParameterInspection.class, PyUnusedFunctionInspection.class);
|
||||
}
|
||||
|
||||
private void doTest(@NotNull PyUnusedLocalInspection inspection) {
|
||||
private void doTest(@NotNull PyUnusedLocalVariableInspection inspection) {
|
||||
doTest(inspection, new PyUnusedParameterInspection());
|
||||
}
|
||||
|
||||
private void doTest(@NotNull PyUnusedLocalInspection inspection, @NotNull PyUnusedParameterInspection parameterInspection) {
|
||||
final String path = "inspections/PyUnusedLocalInspection/" + getTestName(true) + ".py";
|
||||
private void doTest(@NotNull PyUnusedLocalVariableInspection inspection, @NotNull PyUnusedParameterInspection parameterInspection) {
|
||||
final String path = "inspections/PyUnusedLocalVariableInspection/" + getTestName(true) + ".py";
|
||||
myFixture.configureByFile(path);
|
||||
myFixture.enableInspections(inspection, parameterInspection, new PyUnusedFunctionInspection());
|
||||
myFixture.checkHighlighting(true, false, true);
|
||||
|
||||
@@ -38,6 +38,7 @@ class PyUnusedSymbolInspectionMergerTest : PyTestCase() {
|
||||
<option name="myName" value="Test" />
|
||||
<inspection_tool class="PyUnusedLocalInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||
</profile>"""))
|
||||
assertFalse(profile.getToolsOrNull("PyUnusedLocalVariableInspection", null)!!.isEnabled)
|
||||
assertFalse(profile.getToolsOrNull("PyUnusedParameterInspection", null)!!.isEnabled)
|
||||
assertFalse(profile.getToolsOrNull("PyUnusedFunctionInspection", null)!!.isEnabled)
|
||||
}
|
||||
|
||||
+13
-13
@@ -8,7 +8,7 @@ import com.jetbrains.python.PythonFileType;
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
import com.jetbrains.python.inspections.PyComparisonWithNoneInspection;
|
||||
import com.jetbrains.python.inspections.unresolvedReference.PyUnresolvedReferencesInspection;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedLocalInspection;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedLocalVariableInspection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Flake8InspectionSuppressorTest extends PyTestCase {
|
||||
@@ -16,25 +16,25 @@ public class Flake8InspectionSuppressorTest extends PyTestCase {
|
||||
public void testInlineComment() {
|
||||
doTestByText("def foo():\n" +
|
||||
" x = 1 # noqa",
|
||||
PyUnusedLocalInspection.class);
|
||||
PyUnusedLocalVariableInspection.class);
|
||||
}
|
||||
|
||||
public void testCaseInsensitiveness() {
|
||||
doTestByText("def foo():\n" +
|
||||
" x = 1 # NOQA",
|
||||
PyUnusedLocalInspection.class);
|
||||
PyUnusedLocalVariableInspection.class);
|
||||
}
|
||||
|
||||
public void testInlineCommentWithSuffix() {
|
||||
doTestByText("def foo():\n" +
|
||||
" x = 1 # noqa123 ",
|
||||
PyUnusedLocalInspection.class);
|
||||
PyUnusedLocalVariableInspection.class);
|
||||
}
|
||||
|
||||
public void testInlineCommentFollowedByPlainText() {
|
||||
doTestByText("def foo():\n" +
|
||||
" x = 1 # noqa # General purpose comment",
|
||||
PyUnusedLocalInspection.class);
|
||||
PyUnusedLocalVariableInspection.class);
|
||||
}
|
||||
|
||||
public void testSuppressingNonPythonSpecificInspections() {
|
||||
@@ -47,13 +47,13 @@ public class Flake8InspectionSuppressorTest extends PyTestCase {
|
||||
# flake8: noqa
|
||||
def foo():
|
||||
<weak_warning descr="Local variable 'x' value is not used">x</weak_warning> = 1""",
|
||||
PyUnusedLocalInspection.class);
|
||||
PyUnusedLocalVariableInspection.class);
|
||||
}
|
||||
|
||||
public void testIncompleteInlineComment() {
|
||||
doTestByText("def foo():\n" +
|
||||
" <weak_warning descr=\"Local variable 'x' value is not used\">x</weak_warning> = 1 # noq",
|
||||
PyUnusedLocalInspection.class);
|
||||
PyUnusedLocalVariableInspection.class);
|
||||
}
|
||||
|
||||
public void testUnrelatedCommentContainingNoqa() {
|
||||
@@ -63,7 +63,7 @@ public class Flake8InspectionSuppressorTest extends PyTestCase {
|
||||
def foo():
|
||||
<weak_warning descr="Local variable 'x' value is not used">x</weak_warning> = 1
|
||||
""",
|
||||
PyUnusedLocalInspection.class);
|
||||
PyUnusedLocalVariableInspection.class);
|
||||
}
|
||||
|
||||
public void testSingleErrorCode() {
|
||||
@@ -71,7 +71,7 @@ public class Flake8InspectionSuppressorTest extends PyTestCase {
|
||||
def func():
|
||||
<weak_warning descr="Local variable 'x' value is not used">x</weak_warning> = unresolved # noqa: F821
|
||||
""",
|
||||
PyUnusedLocalInspection.class, PyUnresolvedReferencesInspection.class);
|
||||
PyUnusedLocalVariableInspection.class, PyUnresolvedReferencesInspection.class);
|
||||
}
|
||||
|
||||
public void testMultipleErrorCodes() {
|
||||
@@ -79,7 +79,7 @@ public class Flake8InspectionSuppressorTest extends PyTestCase {
|
||||
def func():
|
||||
x = unresolved # noqa: F821, F841
|
||||
""",
|
||||
PyUnusedLocalInspection.class, PyUnresolvedReferencesInspection.class);
|
||||
PyUnusedLocalVariableInspection.class, PyUnresolvedReferencesInspection.class);
|
||||
}
|
||||
|
||||
public void testCommonErrorCodePrefix() {
|
||||
@@ -87,7 +87,7 @@ public class Flake8InspectionSuppressorTest extends PyTestCase {
|
||||
def func():
|
||||
x = unresolved # noqa: F8
|
||||
""",
|
||||
PyUnusedLocalInspection.class, PyUnresolvedReferencesInspection.class);
|
||||
PyUnusedLocalVariableInspection.class, PyUnresolvedReferencesInspection.class);
|
||||
}
|
||||
|
||||
public void testUnrelatedErrorCode() {
|
||||
@@ -95,12 +95,12 @@ public class Flake8InspectionSuppressorTest extends PyTestCase {
|
||||
def func():
|
||||
<weak_warning descr="Local variable 'x' value is not used">x</weak_warning> = <error descr="Unresolved reference 'unresolved'">unresolved</error> # noqa: F631
|
||||
""",
|
||||
PyUnusedLocalInspection.class, PyUnresolvedReferencesInspection.class);
|
||||
PyUnusedLocalVariableInspection.class, PyUnresolvedReferencesInspection.class);
|
||||
}
|
||||
|
||||
public void testUnusedImport() {
|
||||
myFixture.enableInspections(PyUnresolvedReferencesInspection.class);
|
||||
doTestByText("import sys # noqa", PyUnusedLocalInspection.class);
|
||||
doTestByText("import sys # noqa", PyUnusedLocalVariableInspection.class);
|
||||
}
|
||||
|
||||
// PY-16067
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.jetbrains.python.allure.Layers;
|
||||
import com.jetbrains.python.allure.Subsystems;
|
||||
import com.jetbrains.python.inspections.PyReturnFromInitInspection;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedFunctionInspection;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedLocalInspection;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedLocalVariableInspection;
|
||||
|
||||
@TestDataPath("$CONTENT_ROOT/../testData//quickFixes/PyRemoveStatementQuickFixTest/")
|
||||
@Subsystems.QuickFixes
|
||||
@@ -42,7 +42,7 @@ public class PyRemoveStatementQuickFixTest extends PyQuickFixTestCase {
|
||||
}
|
||||
|
||||
public void testVariable() {
|
||||
doQuickFixTest(PyUnusedLocalInspection.class, PyPsiBundle.message("QFIX.NAME.remove.statement"));
|
||||
doQuickFixTest(PyUnusedLocalVariableInspection.class, PyPsiBundle.message("QFIX.NAME.remove.statement"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+15
-15
@@ -21,7 +21,7 @@ import com.jetbrains.python.PyPsiBundle;
|
||||
import com.jetbrains.python.PyQuickFixTestCase;
|
||||
import com.jetbrains.python.allure.Layers;
|
||||
import com.jetbrains.python.allure.Subsystems;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedLocalInspection;
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedLocalVariableInspection;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -31,48 +31,48 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class PyRemoveUnusedLocalQuickFixTest extends PyQuickFixTestCase {
|
||||
// PY-20893
|
||||
public void testExcept() {
|
||||
doQuickFixTest(PyUnusedLocalInspection.class, PyPsiBundle.message("QFIX.NAME.remove.exception.target"));
|
||||
doQuickFixTest(PyUnusedLocalVariableInspection.class, PyPsiBundle.message("QFIX.NAME.remove.exception.target"));
|
||||
}
|
||||
|
||||
// PY-20893
|
||||
public void testExcept2() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON27,
|
||||
() -> doQuickFixTest(PyUnusedLocalInspection.class, PyPsiBundle.message("QFIX.NAME.remove.exception.target")));
|
||||
() -> doQuickFixTest(PyUnusedLocalVariableInspection.class, PyPsiBundle.message("QFIX.NAME.remove.exception.target")));
|
||||
}
|
||||
|
||||
// PY-26418
|
||||
public void testWithOneTarget() {
|
||||
doQuickFixTest(PyUnusedLocalInspection.class, PyPsiBundle.message("QFIX.NAME.remove.with.target"));
|
||||
doQuickFixTest(PyUnusedLocalVariableInspection.class, PyPsiBundle.message("QFIX.NAME.remove.with.target"));
|
||||
}
|
||||
|
||||
// PY-26418
|
||||
public void testWithTwoTargets() {
|
||||
doQuickFixTest(PyUnusedLocalInspection.class, PyPsiBundle.message("INSP.unused.locals.replace.with.wildcard"));
|
||||
doQuickFixTest(PyUnusedLocalVariableInspection.class, PyPsiBundle.message("INSP.unused.locals.replace.with.wildcard"));
|
||||
}
|
||||
|
||||
// PY-26418
|
||||
public void testTwoWithItemsFirstUnused() {
|
||||
doQuickFixTest(PyUnusedLocalInspection.class, PyPsiBundle.message("QFIX.NAME.remove.with.target"));
|
||||
doQuickFixTest(PyUnusedLocalVariableInspection.class, PyPsiBundle.message("QFIX.NAME.remove.with.target"));
|
||||
}
|
||||
|
||||
// PY-26418
|
||||
public void testTwoWithItemsSecondUnused() {
|
||||
doQuickFixTest(PyUnusedLocalInspection.class, PyPsiBundle.message("QFIX.NAME.remove.with.target"));
|
||||
doQuickFixTest(PyUnusedLocalVariableInspection.class, PyPsiBundle.message("QFIX.NAME.remove.with.target"));
|
||||
}
|
||||
|
||||
// PY-17901
|
||||
public void testRemoveAssignmentStatementTarget() {
|
||||
doQuickFixTest(PyUnusedLocalInspection.class, PyPsiBundle.message("QFIX.NAME.remove.assignment.target"));
|
||||
doQuickFixTest(PyUnusedLocalVariableInspection.class, PyPsiBundle.message("QFIX.NAME.remove.assignment.target"));
|
||||
}
|
||||
|
||||
// PY-28782
|
||||
public void testRemoveChainedAssignmentStatementFirstTarget() {
|
||||
doQuickFixTest(PyUnusedLocalInspection.class, PyPsiBundle.message("QFIX.NAME.remove.assignment.target"));
|
||||
doQuickFixTest(PyUnusedLocalVariableInspection.class, PyPsiBundle.message("QFIX.NAME.remove.assignment.target"));
|
||||
}
|
||||
|
||||
// PY-28782
|
||||
public void testRemoveChainedAssignmentStatementSecondTarget() {
|
||||
doQuickFixTest(PyUnusedLocalInspection.class, PyPsiBundle.message("QFIX.NAME.remove.assignment.target"));
|
||||
doQuickFixTest(PyUnusedLocalVariableInspection.class, PyPsiBundle.message("QFIX.NAME.remove.assignment.target"));
|
||||
}
|
||||
|
||||
// PY-28782
|
||||
@@ -87,7 +87,7 @@ public class PyRemoveUnusedLocalQuickFixTest extends PyQuickFixTestCase {
|
||||
|
||||
private void doTestNotIgnoreTupleUnpacking(@NotNull String hint) {
|
||||
final String testFileName = getTestName(true);
|
||||
final PyUnusedLocalInspection inspection = new PyUnusedLocalInspection();
|
||||
final PyUnusedLocalVariableInspection inspection = new PyUnusedLocalVariableInspection();
|
||||
inspection.ignoreTupleUnpacking = false;
|
||||
myFixture.configureByFile(testFileName + ".py");
|
||||
myFixture.enableInspections(inspection);
|
||||
@@ -100,23 +100,23 @@ public class PyRemoveUnusedLocalQuickFixTest extends PyQuickFixTestCase {
|
||||
|
||||
// PY-32037
|
||||
public void testGeneratorIterator() {
|
||||
doQuickFixTest(PyUnusedLocalInspection.class, PyPsiBundle.message("INSP.unused.locals.replace.with.wildcard"));
|
||||
doQuickFixTest(PyUnusedLocalVariableInspection.class, PyPsiBundle.message("INSP.unused.locals.replace.with.wildcard"));
|
||||
}
|
||||
|
||||
// PY-32037
|
||||
public void testComprehensionIterator() {
|
||||
doQuickFixTest(PyUnusedLocalInspection.class, PyPsiBundle.message("INSP.unused.locals.replace.with.wildcard"));
|
||||
doQuickFixTest(PyUnusedLocalVariableInspection.class, PyPsiBundle.message("INSP.unused.locals.replace.with.wildcard"));
|
||||
}
|
||||
|
||||
// PY-85080
|
||||
public void testRemoveUnusedTypeParameterInFunction() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON312,
|
||||
() -> doQuickFixTest(PyUnusedLocalInspection.class, PyPsiBundle.message("QFIX.NAME.remove.type.parameter")));
|
||||
() -> doQuickFixTest(PyUnusedLocalVariableInspection.class, PyPsiBundle.message("QFIX.NAME.remove.type.parameter")));
|
||||
}
|
||||
|
||||
// PY-85080
|
||||
public void testRemoveUnusedTypeParameterInTypeAlias() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON312,
|
||||
() -> doQuickFixTest(PyUnusedLocalInspection.class, PyPsiBundle.message("QFIX.NAME.remove.type.parameter")));
|
||||
() -> doQuickFixTest(PyUnusedLocalVariableInspection.class, PyPsiBundle.message("QFIX.NAME.remove.type.parameter")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package com.jetbrains.python.testing
|
||||
import com.intellij.idea.TestFor
|
||||
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
|
||||
import com.jetbrains.python.fixtures.PyTestCase
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedLocalInspection
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedLocalVariableInspection
|
||||
import com.jetbrains.python.inspections.unusedLocal.PyUnusedParameterInspection
|
||||
import com.jetbrains.python.testing.pyTestParametrized.PyTestParametrizedInspection
|
||||
|
||||
@@ -16,7 +16,7 @@ class PyTestFixtureAndParametrizedTest : PyTestCase() {
|
||||
const val testSubfolder = "/testCompletion"
|
||||
fun testInspectionStatic(fixture: CodeInsightTestFixture) {
|
||||
fixture.configureByFile("test_for_inspection_test.py")
|
||||
fixture.enableInspections(PyUnusedLocalInspection::class.java, PyUnusedParameterInspection::class.java,
|
||||
fixture.enableInspections(PyUnusedLocalVariableInspection::class.java, PyUnusedParameterInspection::class.java,
|
||||
PyTestParametrizedInspection::class.java)
|
||||
fixture.checkHighlighting(true, false, true)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user