mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-21789 Inspection about non-ASCII characters in byte strings doesn't check comments
This commit is contained in:
@@ -17,8 +17,6 @@ package com.jetbrains.python.inspections;
|
||||
|
||||
import com.intellij.codeInspection.LocalInspectionToolSession;
|
||||
import com.intellij.codeInspection.ProblemsHolder;
|
||||
import com.intellij.psi.PsiComment;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.jetbrains.python.PyBundle;
|
||||
@@ -60,11 +58,8 @@ public class PyByteLiteralInspection extends PyInspection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitComment(PsiComment node) {
|
||||
checkString(node, node.getText());
|
||||
}
|
||||
|
||||
private void checkString(PsiElement node, String value) {
|
||||
public void visitPyStringLiteralExpression(PyStringLiteralExpression node) {
|
||||
String value = node.getStringValue();
|
||||
PsiFile file = node.getContainingFile(); // can't cache this in the instance, alas
|
||||
if (file == null) return;
|
||||
boolean default_bytes = false;
|
||||
@@ -101,10 +96,5 @@ public class PyByteLiteralInspection extends PyInspection {
|
||||
registerProblem(node, "Byte literal contains characters > 255");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitPyStringLiteralExpression(PyStringLiteralExpression node) {
|
||||
checkString(node, node.getStringValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<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>
|
||||
<warning descr="Non-ASCII character М in file, but no encoding declared"># type: (b'Моноцикл') -> None</warning>
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
# Медведь на моноцикле
|
||||
|
||||
<warning descr="Byte literal contains characters > 255">b"aaa�"</warning>
|
||||
b"24sd"
|
||||
Reference in New Issue
Block a user