mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
PY-21166 No inspection if unknown format code is used in formatted string
This commit is contained in:
@@ -391,6 +391,7 @@ INSP.too.many.args.for.fmt.string=Too many arguments for format string
|
||||
INSP.too.few.args.for.fmt.string=Too few arguments for format string
|
||||
INSP.incompatible.options=The format options in chunk "{0}" are incompatible
|
||||
INSP.unused.mapping = Mapping key "{0}" is unused
|
||||
INSP.unsupported.format.character=Unsupported format character ''{0}''
|
||||
|
||||
# PyMethodOverridingInspection
|
||||
INSP.NAME.method.over=Method signature does not match signature of overridden method
|
||||
|
||||
@@ -522,10 +522,15 @@ public class PyStringFormatInspection extends PyInspection {
|
||||
}
|
||||
|
||||
final char conversionType = chunk.getConversionType();
|
||||
if (NEW_STYLE_FORMAT_CONVERSIONS.containsKey(conversionType)) {
|
||||
final String[] s = NEW_STYLE_FORMAT_CONVERSIONS.get(conversionType).split(" or ");
|
||||
addTypes(types, Arrays.asList(s));
|
||||
hasTypeOptions = true;
|
||||
if (conversionType != Character.MIN_VALUE) {
|
||||
if (NEW_STYLE_FORMAT_CONVERSIONS.containsKey(conversionType)) {
|
||||
final String[] s = NEW_STYLE_FORMAT_CONVERSIONS.get(conversionType).split(" or ");
|
||||
addTypes(types, Arrays.asList(s));
|
||||
hasTypeOptions = true;
|
||||
}
|
||||
else {
|
||||
registerProblem(myFormatExpression, PyBundle.message("INSP.unsupported.format.character", conversionType));
|
||||
}
|
||||
}
|
||||
|
||||
if (!types.isEmpty()) {
|
||||
|
||||
@@ -451,7 +451,7 @@ public class PyStringFormatParser {
|
||||
chunk.setPrecision(parseWhileCharacterInSet(DIGITS));
|
||||
}
|
||||
|
||||
if (isAtSet(NEW_STYLE_CONVERSION_TYPES)) {
|
||||
if (myPos < end - 1) {
|
||||
chunk.setConversionType(myLiteral.charAt(myPos));
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
print(<warning descr="Unsupported format character 'q'">'{:+q}; {:+f}'</warning>.format(3.14, -3.14))
|
||||
@@ -203,7 +203,12 @@ public class PyStringFormatInspectionTest extends PyTestCase {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//PY-21166
|
||||
public void testUnsupportedFormatSpecifierNewStyleFormatting() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.configureByFile(TEST_DIRECTORY + getTestName(false) + ".py");
|
||||
myFixture.enableInspections(PyStringFormatInspection.class);
|
||||
|
||||
Reference in New Issue
Block a user