From e9f97affb293e1dd237ecaaa23e0b6c4e818446b Mon Sep 17 00:00:00 2001 From: Valentina Kiryushkina Date: Tue, 13 Sep 2016 18:40:26 +0300 Subject: [PATCH] Fix PY-20754 Supress 'Replace with str.format method call' for bytes --- .../ConvertFormatOperatorToMethodIntention.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/ConvertFormatOperatorToMethodIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/ConvertFormatOperatorToMethodIntention.java index 647703486ab3..f3e2492c39b7 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/ConvertFormatOperatorToMethodIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/ConvertFormatOperatorToMethodIntention.java @@ -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; }