Commit Graph
16 Commits
Author SHA1 Message Date
Mikhail Golubev cece70da00 PY-21246 Properly wrap injected expressions in parentheses inside f-strings 2016-11-10 17:13:28 +03:00
Mikhail Golubev af120efee4 Split PyConvertToFStringIntention into several classes 2016-11-10 17:13:28 +03:00
Mikhail Golubev 0bc7a91716 PY-21244 Suppress intention if references for some nested fields are unresolved 2016-11-08 18:20:22 +03:00
Mikhail Golubev df4bbd4a66 PY-21244 Properly enumerate nested fields without explicit name or index
Previously they were enumerated in the opposite order, i.e.
descendant fields had lower indexes than their parents. Existing tests
didn't caught that problem because I misinterpreted the method
UsefulTestCase#assertSameElements(), should have used
UsefulTestCase#assertOrderedEquals() instead.
2016-11-08 18:20:22 +03:00
Mikhail Golubev 9ffbd3bd87 PY-21243 Suppress intention if chunks are resolved into RHS of % as a fallback
As a fallback value PySubstitutionChunkReference resolves into the
right operand of "%" operator whenever it cannot find individual
expressions for multiple positional formatted fields or a field with
a key. I explicitly check and suppress the intention for such cases.
In future it's better to introduce some sort of "strict resolve"
semantic in the PySubstitutionChunkReference so as do these checks
twice.
2016-11-08 18:20:22 +03:00
Mikhail Golubev 39a18a8cfd PY-21245 Handle quotes in lookup items inside multiline string literals better
Namely, allow lookup items that contain quotes in some cases if the
containing string literal is multiline, hence there is still a suitable
type of quotes to wrap injected string literal into.

The orignal error described in the issue has been fixed earlier as
part of other changes for PY-21161.
2016-11-08 18:20:22 +03:00
Mikhail Golubev b71807a0a7 PY-21244 Handle nested replacement fields in "Convert to f-string" intention 2016-10-31 18:12:19 +03:00
Mikhail Golubev b5f9efb612 PY-21161 Don't flip quotes inside inlined expressions if it's not necessary
For instance, when inlining single-quoted string inside triple-quoted
string with the same type of quotes.
2016-10-25 21:30:13 +03:00
Mikhail Golubev a373a4d4ca PY-21161 Add tests on inlining triple-quoted strings 2016-10-25 21:30:13 +03:00
Mikhail Golubev c5f8bf51d5 PY-21161 Check that index fragment of .format() string doesn't contain backslash 2016-10-25 21:30:13 +03:00
Mikhail Golubev 7f476d1302 PY-21161 Check that index inside .format() chunk doesn't contain quotes it will be wrapped into 2016-10-25 21:30:13 +03:00
Mikhail Golubev a88719627f PY-21161 Don't suggest intention for string methods other than "format" 2016-10-25 21:30:13 +03:00
Mikhail Golubev 06286a59a2 PY-21161 Handle not-trivial format specs in printf-style formatting better 2016-10-25 21:30:13 +03:00
Mikhail Golubev 84422a7250 PY-21161 Handle subscriptions inside format string chunks like {0[foo]} 2016-10-25 21:30:13 +03:00
Mikhail Golubev 27d5095a03 PY-21161 Handle simple .format() calls (no nested fragments, no subscriptions) 2016-10-25 21:30:13 +03:00
Mikhail Golubev 2fcfcacdb7 PY-21161 Convert to f-string literal for printf-style formatting 2016-10-25 21:30:13 +03:00