PY-21161 Check that index inside .format() chunk doesn't contain quotes it will be wrapped into

This commit is contained in:
Mikhail Golubev
2016-10-25 21:30:13 +03:00
parent a88719627f
commit 7f476d1302
4 changed files with 7 additions and 1 deletions
@@ -366,7 +366,7 @@ public class PyConvertToFStringIntention extends PyBaseIntentionAction {
continue;
}
final char quote = invertQuote(hostStringQuote);
if (indexText.indexOf('\'') >= 0 && indexText.indexOf(quote) >= 0) {
if (indexText.indexOf(hostStringQuote) >= 0 || indexText.indexOf(quote) >= 0) {
return null;
}
escaped.add("[" + quote + indexText + quote + "]");
@@ -0,0 +1 @@
'{foo["]}'.format(foo=undefined)
@@ -96,6 +96,10 @@ public class PyConvertToFStringIntentionTest extends PyIntentionTestCase {
doTest();
}
public void testFormatMethodIndexContainsHostAlternativeQuote() {
doTest();
}
public void testPercentOperatorWidthAndPrecision() {
doTest();
}