mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
PY-33425 fix pep8 warnings were still shown after suppressing with # noinspection PyPep8
GitOrigin-RevId: 738ab906f4026f8f64a3b1f7185ba8a5add9fe40
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d3d7834bee
commit
06d8a78b34
@@ -261,6 +261,9 @@ public final class Pep8ExternalAnnotator extends ExternalAnnotator<Pep8ExternalA
|
||||
Project project = file.getProject();
|
||||
final Document document = PsiDocumentManager.getInstance(project).getDocument(file);
|
||||
|
||||
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(file.getProject()).getCurrentProfile();
|
||||
final PyPep8Inspection inspection = (PyPep8Inspection)profile.getUnwrappedTool(PyPep8Inspection.INSPECTION_SHORT_NAME, file);
|
||||
|
||||
for (Problem problem : annotationResult.problems) {
|
||||
final int line = problem.myLine - 1;
|
||||
final int column = problem.myColumn - 1;
|
||||
@@ -291,6 +294,10 @@ public final class Pep8ExternalAnnotator extends ExternalAnnotator<Pep8ExternalA
|
||||
}
|
||||
|
||||
if (problemElement != null) {
|
||||
if (inspection != null && inspection.isSuppressedFor(problemElement)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TextRange problemRange = problemElement.getTextRange();
|
||||
// Multi-line warnings are shown only in the gutter and it's not the desired behavior from the usability point of view.
|
||||
// So we register it only on that line where pycodestyle.py found the problem originally.
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
package com.jetbrains.env.python
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk
|
||||
import com.intellij.openapi.roots.ModuleRootModificationUtil
|
||||
import com.jetbrains.env.EnvTestTagsRequired
|
||||
import com.jetbrains.env.PyEnvTestCase
|
||||
import com.jetbrains.env.PyExecutionFixtureTestTask
|
||||
@@ -56,6 +55,44 @@ class PyPep8Test : PyEnvTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
// PY-33425
|
||||
@Test
|
||||
fun suppressingWarningsWithSuppressQuickFix() {
|
||||
runPythonTest(
|
||||
Pep8Task("""
|
||||
def <weak_warning descr="PEP 8: E501 line too long (136 > 120 characters)">test_test_test_test_test_test_test_test_test_test_method_with_a_test_name_that_is_way_too_long_to_fit_in_120_char_wide_editor</weak_warning>(self):
|
||||
pass
|
||||
|
||||
|
||||
class TestClass:
|
||||
def <weak_warning descr="PEP 8: E501 line too long (140 > 120 characters)">test_test_test_test_test_test_test_test_test_test_method_with_a_test_name_that_is_way_too_long_to_fit_in_120_char_wide_editor</weak_warning>(self):
|
||||
pass
|
||||
|
||||
|
||||
# noinspection PyPep8
|
||||
def test_test_test_test_test_test_test_test_test_test_method2_with_a_test_name_that_is_way_too_long_to_fit_in_120_char_wide_editor():
|
||||
pass
|
||||
|
||||
|
||||
# noinspection PyPep8
|
||||
class SuppressedClass:
|
||||
def test_test_test_test_test_test_test_test_test_test_method_with_a_test_name_that_is_way_too_long_to_fit_in_120_char_wide_editor(
|
||||
self):
|
||||
pass
|
||||
|
||||
|
||||
# noinspection PyPep8
|
||||
class NestedSuppression:
|
||||
def foo(self):
|
||||
def bar():
|
||||
def test_test_test_test_test_test_test_test_test_test_inner_method_with_a_test_name_that_is_way_too_long_to_fit_in_120_char_wide_editor():
|
||||
pass
|
||||
pass
|
||||
pass
|
||||
""".trimIndent())
|
||||
)
|
||||
}
|
||||
|
||||
private class Pep8Task(private val text: String) : PyExecutionFixtureTestTask(null) {
|
||||
|
||||
override fun runTestOn(sdkHome: String, existingSdk: Sdk?) {
|
||||
|
||||
Reference in New Issue
Block a user