Skip to content

Commit

Permalink
Issue wemake-services#1111 - Forbid to use \r in line breaks: some mi…
Browse files Browse the repository at this point in the history
…nor processing [step2]
  • Loading branch information
jigi-33 committed Feb 22, 2020
1 parent 3e380a5 commit 23a4c21
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Expand Up @@ -18,7 +18,9 @@

wrong_newline_single = 'print(1)\rprint(2)'
wrong_newline_sequenced = 'print(1)\r\nprint(2)'
wrong_newline_in_multiline = """print(1)\rprint(2)."""
wrong_newline_in_multiline = """print(1)\rprint(2)\r
print(3).
"""


@pytest.mark.parametrize('code', [
Expand Down
4 changes: 3 additions & 1 deletion wemake_python_styleguide/visitors/tokenize/syntax.py
Expand Up @@ -61,7 +61,9 @@ def _check_line_starts_with_dot(self, token: tokenize.TokenInfo) -> None:
if line.startswith('.') and not line.startswith('...'):
self.add_violation(LineStartsWithDotViolation(token))

def _check_line_comprise_carriage_return(self, token: tokenize.TokenInfo) -> None:
def _check_line_comprise_carriage_return(
self, token: tokenize.TokenInfo
) -> None:
line = token.line.find('\r')
if line != -1 and line == (len(token.line) - 2):
self.add_violation(LineCompriseCarriageReturnViolation(token))

0 comments on commit 23a4c21

Please sign in to comment.