Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output of invalid indents when comments appear inside implicit string continuations #17

Open
jayvdb opened this issue Jun 26, 2017 · 1 comment

Comments

@jayvdb
Copy link

jayvdb commented Jun 26, 2017

A comment inside a string breaks the tools as it unnecessarily appends line continuations to strings

i.e. this chokes

foo('a'
    # foo
    'b')

A real example

-            self.assertEqual('\n' + STR_PROJECT_WIDE + '\n\n'
-                             '**** t [Section: ] ****' + '\n\n'
-                             '!    ! [Severity: NORMAL]\n'
-                             '!    ! msg\n'
-                             # Second results file isn't there, no context is
-                             # printed, only a warning log message which we
-                             # don't catch
-                             '\n**** t [Section: ] ****' + '\n\n'
-                             '!    ! [Severity: NORMAL]\n'
+            assert '\n' + STR_PROJECT_WIDE + '\n\n' \
+                             '**** t [Section: ] ****' + '\n\n' \
+                             '!    ! [Severity: NORMAL]\n' \
+                             '!    ! msg\n' \
+                             # Second results file isn't there, no context is \
+                             # printed, only a warning log message which we \
+                             # don't catch \
+                             '\n**** t [Section: ] ****' + '\n\n' \
+                             '!    ! [Severity: NORMAL]\n' \
                              '!    ! {0}\n'.format(
                                  highlight_text(self.no_color, 'msg',
-                                                style=BackgroundMessageStyle)),
-                             stdout.getvalue())
+                                                style=BackgroundMessageStyle)) == \
+                             stdout.getvalue()

From https://github.com/coala/coala/blob/8a25983/tests/output/ConsoleInteractionTest.py#L623

Result: https://travis-ci.org/jayvdb/coala/jobs/246949584#L9052

(Another bug coming about the other problem in that build log.)

@htgoebel
Copy link
Collaborator

The fixes need to be changed to not use line-continuation if one of the expressions contains a comment. Instead the expressions can be wrapped in (…). Maybe its easier to always wrap the expressions.

We ought to check is other fixes are effected, too.

@htgoebel htgoebel added this to the v0.4 milestone Aug 16, 2017
@htgoebel htgoebel removed this from the v0.4 milestone Jun 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants