Skip to content

Commit

Permalink
Ignore syntax errors from pycaodestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
muffinmad committed Nov 17, 2023
1 parent e6dd190 commit 6f52160
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion anakinls/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from jedi.api.refactoring import Refactoring # type: ignore
from lsprotocol import types
from pycodestyle import BaseReport as CodestyleBaseReport # type: ignore
from pycodestyle import Checker as CodestyleChecker
from pycodestyle import Checker as CodestyleBaseChecker
from pycodestyle import StyleGuide as CodestyleStyleGuide
from pyflakes.api import check as pyflakes_check # type: ignore
from pygls.protocol import LanguageServerProtocol, lsp_method
Expand Down Expand Up @@ -223,6 +223,12 @@ def flake(self, message):
)


class CodestyleChecker(CodestyleBaseChecker):
def report_invalid_syntax(self):
# Syntax errors are provided by Jedi. Just ignore pycodestyle.
pass


class CodestyleReport(CodestyleBaseReport):
def __init__(self, options, result):
super().__init__(options)
Expand Down
5 changes: 3 additions & 2 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self):

@pytest.fixture()
def server():
aserver.scripts.clear()
return Server()


Expand Down Expand Up @@ -139,9 +140,9 @@ def test_diff_to_edits():
assert str(edits[3].range) == '24:0-24:0'


def test_no_pyflakes_syntax_error_diagnostic(server):
@pytest.mark.parametrize('content', ('pass\n\nif\n', 'def foo(def\n'))
def test_only_jedi_syntax_error_diagnostic(server, content):
uri = 'file://test_diagnostic.py'
content = 'pass\n\nif\n'
doc = Document(uri, content)
server.workspace.get_text_document = Mock(return_value=doc)
server.publish_diagnostics = Mock()
Expand Down

0 comments on commit 6f52160

Please sign in to comment.