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

Replace line endings for pycodestyle #25

Merged
merged 1 commit into from
Jan 19, 2024
Merged
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
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