diff options
author | Ian Lee <IanLee1521@gmail.com> | 2015-01-26 22:28:08 -0800 |
---|---|---|
committer | Ian Lee <IanLee1521@gmail.com> | 2015-01-26 22:29:16 -0800 |
commit | f7a9648da6245738b72fcd664a20168d54953ee7 (patch) | |
tree | aec050e3a89395a6a75df9658337f9c9ebbff1e2 | |
parent | 510003502b5e067b927e9a62b69937cd9b0eff6e (diff) | |
download | pep8-f7a9648da6245738b72fcd664a20168d54953ee7.tar.gz |
Allow backslash to end a line if within inline comment; issue #374
-rw-r--r-- | CHANGES.txt | 2 | ||||
-rwxr-xr-x | pep8.py | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 91a2095..96cf062 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -36,6 +36,8 @@ Changes: * Allow spaces around the equals sign in an annotated function. (Issue #357) +* Allow trailing backslash if in an inline comment. (Issue #374) + Bug fixes: * Don't crash if Checker.build_tokens_line() returns None. (Issue #306) @@ -972,10 +972,14 @@ def explicit_line_join(logical_line, tokens): Okay: aaa = [123,\n 123] Okay: aaa = ("bbb "\n "ccc") Okay: aaa = "bbb " \\n "ccc" + Okay: aaa = 123 # \\ """ prev_start = prev_end = parens = 0 + comment = False for token_type, text, start, end, line in tokens: - if start[0] != prev_start and parens and backslash: + if token_type == tokenize.COMMENT: + comment = True + if start[0] != prev_start and parens and backslash and not comment: yield backslash, "E502 the backslash is redundant between brackets" if end[0] != prev_end: if line.rstrip('\r\n').endswith('\\'): |