mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
PY-21645 Disable some inspections in function type comments
This commit is contained in:
@@ -711,6 +711,10 @@
|
||||
|
||||
<!-- PyQt -->
|
||||
<typeProvider implementation="com.jetbrains.pyqt.PyQtTypeProvider"/>
|
||||
|
||||
<!-- PyFunctionTypeAnnotation -->
|
||||
<visitorFilter language="PyFunctionTypeComment"
|
||||
implementationClass="com.jetbrains.python.codeInsight.functionTypeComments.PyFunctionTypeAnnotationVisitorFilter"/>
|
||||
</extensions>
|
||||
|
||||
<actions>
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.jetbrains.python.codeInsight.functionTypeComments;
|
||||
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.jetbrains.python.inspections.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Mikhail Golubev
|
||||
*/
|
||||
public class PyFunctionTypeAnnotationVisitorFilter implements PythonVisitorFilter {
|
||||
@Override
|
||||
public boolean isSupported(@NotNull Class visitorClass, @NotNull PsiFile file) {
|
||||
return !(visitorClass == PyIncorrectDocstringInspection.class ||
|
||||
visitorClass == PyMissingOrEmptyDocstringInspection.class ||
|
||||
visitorClass == PySingleQuotedDocstringInspection.class ||
|
||||
visitorClass == PyByteLiteralInspection.class ||
|
||||
visitorClass == PyMandatoryEncodingInspection.class ||
|
||||
visitorClass == PyNonAsciiCharInspection.class ||
|
||||
visitorClass == PyInterpreterInspection.class ||
|
||||
visitorClass == PyPep8Inspection.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<weak_warning descr="Missing docstring"></weak_warning><warning descr="No encoding specified for file"></warning>def <weak_warning descr="Missing docstring">f</weak_warning>(x):
|
||||
<warning descr="Byte literal contains characters > 255"><warning descr="Non-ASCII character М in file, but no encoding declared"># type: (b'Моноцикл') -> None</warning></warning>
|
||||
pass
|
||||
|
||||
|
||||
def <weak_warning descr="Missing docstring">g</weak_warning>():
|
||||
# type: <error descr="unexpected tokens">"foo"</error>
|
||||
pass
|
||||
@@ -351,4 +351,17 @@ public class PythonInspectionsTest extends PyTestCase {
|
||||
public void testPyDunderSlotsInspection() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON30, () -> doHighlightingTest(PyDunderSlotsInspection.class));
|
||||
}
|
||||
|
||||
// PY-21645
|
||||
public void testInspectionsDisabledInFunctionTypeComments() {
|
||||
myFixture.enableInspections(PyIncorrectDocstringInspection.class);
|
||||
myFixture.enableInspections(PyMissingOrEmptyDocstringInspection.class);
|
||||
myFixture.enableInspections(PySingleQuotedDocstringInspection.class);
|
||||
myFixture.enableInspections(PyByteLiteralInspection.class);
|
||||
myFixture.enableInspections(PyMandatoryEncodingInspection.class);
|
||||
myFixture.enableInspections(PyNonAsciiCharInspection.class);
|
||||
|
||||
myFixture.configureByFile("inspections/" + getTestName(false) + "/test.py");
|
||||
myFixture.checkHighlighting(true, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user