Kaydet (Commit) 51d6b2f6 authored tarafından Anthony Sottile's avatar Anthony Sottile Kaydeden (comit) GitHub

Merge pull request #19 from asottile/dont_unhug_tqs

Don't unhug things containing only a triple-quoted-string
...@@ -251,9 +251,14 @@ def _fix_brace(fix_data, add_comma, tokens): ...@@ -251,9 +251,14 @@ def _fix_brace(fix_data, add_comma, tokens):
hug_open = tokens[first_brace + 1].name not in NON_CODING_TOKENS hug_open = tokens[first_brace + 1].name not in NON_CODING_TOKENS
hug_close = tokens[last_brace - 1].name not in NON_CODING_TOKENS hug_close = tokens[last_brace - 1].name not in NON_CODING_TOKENS
if ( if (
# Don't unhug single element things with a multi-line component
# inside.
not fix_data.multi_arg and not fix_data.multi_arg and
hug_open and hug_open and
tokens[last_brace - 1].src in END_BRACES tokens[last_brace - 1].src in END_BRACES or
# Don't unhug when containing a single token (such as a triple
# quoted string).
first_brace + 2 == last_brace
): ):
hug_open = hug_close = False hug_open = hug_close = False
......
...@@ -312,6 +312,10 @@ def test_fixes_defs(src, expected): ...@@ -312,6 +312,10 @@ def test_fixes_defs(src, expected):
'f([\n' 'f([\n'
' 1, 2, 3,\n' ' 1, 2, 3,\n'
'])', '])',
# Single triple-quoted-string argument, don't unhug
'textwrap.dedent("""\n'
' hi\n'
'""")',
), ),
) )
def test_noop_unhugs(src): def test_noop_unhugs(src):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment