mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix PY-20800 'Replace with str.format method call' adds additional :s for repr
Remove explicit conversion :s because it is default for strings
This commit is contained in:
+1
-2
@@ -164,8 +164,7 @@ public class ConvertFormatOperatorToMethodIntention extends BaseIntentionAction
|
||||
out.append(f_width);
|
||||
}
|
||||
if ("i".equals(f_conversion) || "u".equals(f_conversion)) out.append("d");
|
||||
else if ("r".equals(f_conversion)) out.append("s"); // we want our raw string as a string
|
||||
else if (!"s".equals(f_conversion)) out.append(f_conversion);
|
||||
else if (!"s".equals(f_conversion) && !"r".equals(f_conversion)) out.append(f_conversion);
|
||||
|
||||
final int lastIndexOf = out.lastIndexOf(":");
|
||||
if (lastIndexOf == out.length() - 1) {
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ a = "{n:d} bottles of {what} on the {where}" \
|
||||
{n:d} bottles
|
||||
of {what}
|
||||
""" \
|
||||
r'\n/ take {howmuch!r:s} down \n/' \
|
||||
r'\n/ take {howmuch!r} down \n/' \
|
||||
ur"pass it {how:>8}" \
|
||||
"{new_n:#d} {{that is, {percent:+3.2f}% less}} " \
|
||||
"bottles of {what:>6} on the {where}" \
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
print('%r' <caret>% '123')
|
||||
@@ -0,0 +1 @@
|
||||
print('{!r}'.format('123'))
|
||||
+5
@@ -63,4 +63,9 @@ public class PyConvertFormatOperatorToMethodIntentionTest extends PyIntentionTes
|
||||
public void testBytes() {
|
||||
doNegativeTest(PyBundle.message("INTN.replace.with.method"));
|
||||
}
|
||||
|
||||
// PY-20800
|
||||
public void testRepr() {
|
||||
doTest(PyBundle.message("INTN.replace.with.method"), LanguageLevel.PYTHON26);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user