PY2 unicode-only type is something that is compatible with unicode (mypy rule) and not compatible with str

This commit is contained in:
Andrey Vlasovskikh
2017-03-02 22:55:15 +03:00
parent 8059457a1b
commit 7d1008addc
@@ -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();