Fix PY-20754 Supress 'Replace with str.format method call' for bytes

This commit is contained in:
Valentina Kiryushkina
2016-09-28 14:36:08 +03:00
parent 15eb157a58
commit e9f97affb2
@@ -236,9 +236,13 @@ public class ConvertFormatOperatorToMethodIntention extends BaseIntentionAction
if (languageLevel.isOlderThan(LanguageLevel.PYTHON26)) {
return false;
}
if (binaryExpression.getLeftExpression() instanceof PyStringLiteralExpression && binaryExpression.getOperator() == PyTokenTypes.PERC) {
setText(PyBundle.message("INTN.replace.with.method"));
return true;
if (binaryExpression.getLeftExpression() instanceof PyStringLiteralExpression
&& binaryExpression.getOperator() == PyTokenTypes.PERC) {
final PyStringLiteralExpression str = (PyStringLiteralExpression)binaryExpression.getLeftExpression();
if (!(str.getText().length() > 0 && Character.toUpperCase(str.getText().charAt(0)) == 'B')) {
setText(PyBundle.message("INTN.replace.with.method"));
return true;
}
}
return false;
}