Skip to content

Commit

Permalink
Replace line endings for pycodestyle (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
muffinmad authored Jan 19, 2024
1 parent 200ca26 commit 63a7b7c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion anakinls/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,9 @@ def _validate(ls: LanguageServer, uri: str, script: Script = None):
codestyleopts = get_pycodestyle_options(ls, uri)
CodestyleChecker(
script.path,
script._code.splitlines(True),
script._code.replace('\r\n', '\n')
.replace('\r', '\n')
.splitlines(True),
codestyleopts,
CodestyleReport(codestyleopts, result),
).check_all()
Expand Down
11 changes: 11 additions & 0 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,14 @@ def test_only_jedi_syntax_error_diagnostic(server, content):
diagnostics = server.publish_diagnostics.call_args[0][1]
assert len(diagnostics) == 1
assert diagnostics[0].source == 'jedi'


def test_pycodestyle_lineending(server):
uri = 'file://test_pycodestyle.py'
doc = Document(uri, 'while True:\r\n break\r\n')
server.workspace.get_text_document = Mock(return_value=doc)
server.publish_diagnostics = Mock()
aserver._validate(server, uri)
assert server.publish_diagnostics.called
diagnostics = server.publish_diagnostics.call_args[0][1]
assert len(diagnostics) == 0

0 comments on commit 63a7b7c

Please sign in to comment.