Skip to content

Commit

Permalink
Ignore syntax errors from pycodestyle (#23)
Browse files Browse the repository at this point in the history
* Ignore syntax errors from pycodestyle

* Drop testing against python 3.7
  • Loading branch information
muffinmad authored Nov 17, 2023
1 parent e6dd190 commit e1edd2a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v3
Expand Down
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 e1edd2a

Please sign in to comment.