void (@NotNull final PyStringLiteralExpression formatExpression) { final String value = formatExpression.getText(); final List<SubstitutionChunk> chunks = filterSubstitutions(parsePercentFormat(value)); myExpectedArguments = chunks.size(); myUsedMappingKeys.clear(); // if use mapping keys final boolean mapping = chunks.size() > 0 && chunks.get(0).getMappingKey() != null; for (int i = 0; i < chunks.size(); ++i) { PercentSubstitutionChunk chunk = as(chunks.get(i), PercentSubstitutionChunk.class); if (chunk != null) { // Mapping key String mappingKey = Integer.toString(i + 1); if (mapping) { if (chunk.getMappingKey() == null || chunk.isUnclosedMapping()) { registerProblem(formatExpression, PyPsiBundle.message("INSP.too.few.keys")); break; } mappingKey = chunk.getMappingKey(); myUsedMappingKeys.put(mappingKey, false); } // Minimum field width inspectWidth(formatExpression, chunk.getWidth()); // Precision inspectWidth(formatExpression, chunk.getPrecision()); // Format specifier final char conversionType = chunk.getConversionType(); if (conversionType == 'b') { final LanguageLevel languageLevel = LanguageLevel.forElement(formatExpression); if (languageLevel.isOlderThan(LanguageLevel.PYTHON35) || !isBytesLiteral(formatExpression, myTypeEvalContext)) { registerProblem(formatExpression, PyPsiBundle.message("INSP.str.format.unsupported.format.character.b")); return; } } final LanguageLevel languageLevel = LanguageLevel.forElement(formatExpression); if (PERCENT_FORMAT_CONVERSIONS.containsKey(conversionType) && !(languageLevel.isPython2() && conversionType == 'a')) { myFormatSpec.put(mappingKey, PERCENT_FORMAT_CONVERSIONS.get(conversionType)); continue; } registerProblem(formatExpression, PyPsiBundle.message("INSP.no.format.specifier.char"), new PyAddSpecifierToFormatQuickFix()); return; } } }