String (@NotNull NewStyleSubstitutionChunk chunk) { final HashSet<String> supportedTypes = new HashSet<>(); boolean hasTypeOptions = false; final String mappingKey = chunk.getMappingKey() != null ? chunk.getMappingKey() : String.valueOf(chunk.getPosition()); // inspect options available only for numeric types if (chunk.hasSignOption() || chunk.useAlternateForm() || chunk.hasZeroPadding() || chunk.hasThousandsSeparator()) { specifyTypes(supportedTypes, NUMERIC_TYPES); hasTypeOptions = true; } if (chunk.getPrecision() != null) { // TODO: actually availableTypes doesn't reject int, because int is compatible with float and complex final List<String> availableTypes = Arrays.asList("str", "float", "complex"); specifyTypes(supportedTypes, availableTypes); hasTypeOptions = true; } final char conversionType = chunk.getConversionType(); if (conversionType != Character.MIN_VALUE) { if (NEW_STYLE_FORMAT_CONVERSIONS.containsKey(conversionType)) { final String[] s = NEW_STYLE_FORMAT_CONVERSIONS.get(conversionType).split(" or "); specifyTypes(supportedTypes, Arrays.asList(s)); hasTypeOptions = true; } else { registerProblem(myFormatExpression, PyPsiBundle.message("INSP.unsupported.format.character", conversionType)); } } if (!supportedTypes.isEmpty()) { myFormatSpec.put(mappingKey, StringUtil.join(supportedTypes, " or ")); } else if (hasTypeOptions) { registerProblem(myFormatExpression, PyPsiBundle.message("INSP.incompatible.options", mappingKey)); } return mappingKey; }