From 7d1008addcdfaaabcb392c4d06e3ad38b366451d Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Thu, 2 Mar 2017 22:42:34 +0300 Subject: [PATCH] PY2 unicode-only type is something that is compatible with unicode (mypy rule) and not compatible with str --- .../intentions/ConvertFormatOperatorToMethodIntention.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/ConvertFormatOperatorToMethodIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/ConvertFormatOperatorToMethodIntention.java index 8497b223d73b..67323df5896e 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/ConvertFormatOperatorToMethodIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/ConvertFormatOperatorToMethodIntention.java @@ -285,7 +285,9 @@ public class ConvertFormatOperatorToMethodIntention extends PyBaseIntentionActio final PyType rhsType = context.getType(rhs); String prefix = ""; final LanguageLevel languageLevel = guessLanguageLevel(project); - if (!languageLevel.isPy3K() && PyTypeChecker.match(PyBuiltinCache.getInstance(rhs).getObjectType("unicode"), rhsType, context)) { + final PyBuiltinCache builtinCache = PyBuiltinCache.getInstance(rhs); + if (!languageLevel.isPy3K() && PyTypeChecker.match(builtinCache.getUnicodeType(languageLevel), rhsType, context) && + !PyTypeChecker.match(builtinCache.getBytesType(languageLevel), rhsType, context)) { prefix = "u"; } final PyStringLiteralExpression leftExpression = (PyStringLiteralExpression)element.getLeftExpression();