Skip to content

Commit afd2135

Browse files
committed
update pyls
1 parent 7c67590 commit afd2135

File tree

4 files changed

+34
-17
lines changed

4 files changed

+34
-17
lines changed

mypy_ls/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.3.2"
1+
__version__ = "0.3.3"

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
python-language-server<0.32.0
1+
python-language-server>=0.34.0
22
mypy

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ classifiers =
1818
python_requires = >= 3.6
1919
packages = find:
2020
install_requires =
21-
python-language-server<0.32.0
21+
python-language-server>=0.34.0
2222
mypy
2323

2424

@@ -36,4 +36,4 @@ test =
3636
exclude =
3737
contrib
3838
docs
39-
test
39+
test

test/test_plugin.py

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import pytest
22

3-
from pyls.workspace import Document
3+
from pyls.workspace import Workspace, Document
4+
from pyls.config.config import Config
5+
from pyls import uris
6+
from mock import Mock
47
from mypy_ls import plugin
58

69
DOC_URI = __file__
@@ -15,18 +18,32 @@
1518
'error: "Request" has no attribute "id"')
1619

1720

21+
@pytest.fixture
22+
def workspace(tmpdir):
23+
"""Return a workspace."""
24+
ws = Workspace(uris.from_fs_path(str(tmpdir)), Mock())
25+
ws._config = Config(ws.root_uri, {}, 0, {})
26+
return ws
27+
28+
1829
class FakeConfig(object):
19-
30+
2031
def __init__(self):
2132
self._root_path = "C:"
2233

2334
def plugin_settings(self, plugin, document_path=None):
2435
return {}
2536

2637

27-
def test_plugin():
38+
def test_settings():
2839
config = FakeConfig()
29-
doc = Document(DOC_URI, DOC_TYPE_ERR)
40+
settings = plugin.pyls_settings(config)
41+
assert settings == {"plugins": {"mypy-ls": {}}}
42+
43+
44+
def test_plugin(workspace):
45+
config = FakeConfig()
46+
doc = Document(DOC_URI, workspace, DOC_TYPE_ERR)
3047
workspace = None
3148
plugin.pyls_settings(config)
3249
diags = plugin.pyls_lint(config, workspace, doc, is_saved=False)
@@ -38,33 +55,33 @@ def test_plugin():
3855
assert diag['range']['end'] == {'line': 0, 'character': 1}
3956

4057

41-
def test_parse_full_line():
42-
doc = Document(DOC_URI, DOC_TYPE_ERR)
58+
def test_parse_full_line(workspace):
59+
doc = Document(DOC_URI, workspace)
4360
diag = plugin.parse_line(TEST_LINE, doc)
4461
assert diag['message'] == '"Request" has no attribute "id"'
4562
assert diag['range']['start'] == {'line': 278, 'character': 7}
4663
assert diag['range']['end'] == {'line': 278, 'character': 8}
4764

4865

49-
def test_parse_line_without_col():
50-
doc = Document(DOC_URI, DOC_TYPE_ERR)
66+
def test_parse_line_without_col(workspace):
67+
doc = Document(DOC_URI, workspace)
5168
diag = plugin.parse_line(TEST_LINE_WITHOUT_COL, doc)
5269
assert diag['message'] == '"Request" has no attribute "id"'
5370
assert diag['range']['start'] == {'line': 278, 'character': 0}
5471
assert diag['range']['end'] == {'line': 278, 'character': 1}
5572

5673

57-
def test_parse_line_without_line():
58-
doc = Document(DOC_URI, DOC_TYPE_ERR)
74+
def test_parse_line_without_line(workspace):
75+
doc = Document(DOC_URI, workspace)
5976
diag = plugin.parse_line(TEST_LINE_WITHOUT_LINE, doc)
6077
assert diag['message'] == '"Request" has no attribute "id"'
6178
assert diag['range']['start'] == {'line': 0, 'character': 0}
62-
assert diag['range']['end'] == {'line': 0, 'character': 1}
79+
assert diag['range']['end'] == {'line': 0, 'character': 6}
6380

6481

6582
@pytest.mark.parametrize('word,bounds', [('', (7, 8)), ('my_var', (7, 13))])
66-
def test_parse_line_with_context(monkeypatch, word, bounds):
67-
doc = Document(DOC_URI, 'DOC_TYPE_ERR')
83+
def test_parse_line_with_context(monkeypatch, word, bounds, workspace):
84+
doc = Document(DOC_URI, workspace)
6885
monkeypatch.setattr(Document, 'word_at_position', lambda *args: word)
6986
diag = plugin.parse_line(TEST_LINE, doc)
7087
assert diag['message'] == '"Request" has no attribute "id"'

0 commit comments

Comments
 (0)