Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,6 @@ Batuhan Taskaya (@isidentical) <isidentical@gmail.com>
Jocelyn Boullier (@Kazy) <jocelyn@boullier.bzh>


salpenr (@salapenar-max)

Note: (@user) means a github user name.
5 changes: 4 additions & 1 deletion parso/python/pep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,10 @@ def _visit_part(self, part, spacing, leaf):
should_be_indentation = n.indentation

self._last_indentation_tos = n
if n == node:
# A backslash in the same prefix can introduce a new
# node below the previous indentation stack. In that
# case, stop at the root instead of walking past it.
if n == node or n.parent is None:
break
n = n.parent

Expand Down
12 changes: 12 additions & 0 deletions test/test_pep8.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import parso
import pytest


def issues(code):
Expand Down Expand Up @@ -40,3 +41,14 @@ def test_shebang():
assert not issues('#!\n')
assert not issues('#!/foo\n')
assert not issues('#! python\n')


@pytest.mark.parametrize('newline', ['\n', '\r\n', '\r'])
@pytest.mark.parametrize('backslashes', [1, 2])
@pytest.mark.parametrize('comment', ['#', '# comment'])
def test_comment_after_backslash(newline, backslashes, comment):
prefix = ('\\' + newline) * backslashes
found = issues(prefix + comment)
assert [(issue.code, issue.start_pos) for issue in found] == [
(292, (backslashes + 1, len(comment))),
]
Loading