From ee352be05bb0a47308c91fd41d3d35bf0f3aa1f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= Date: Wed, 4 Oct 2023 01:00:26 +0000 Subject: [PATCH] depend on pygls >= 1.1.0 --- server/buildoutls/bench/slapos.py | 2 +- server/buildoutls/buildout.py | 6 ++--- server/buildoutls/server.py | 2 +- server/buildoutls/tests/conftest.py | 6 ++--- .../buildoutls/tests/test_buildout_parser.py | 26 +++++++++---------- server/requirements.txt | 6 ++--- server/setup.py | 2 +- server/test-requirements.txt | 18 ++++++------- 8 files changed, 33 insertions(+), 35 deletions(-) diff --git a/server/buildoutls/bench/slapos.py b/server/buildoutls/bench/slapos.py index ad62e28..f94f872 100644 --- a/server/buildoutls/bench/slapos.py +++ b/server/buildoutls/bench/slapos.py @@ -117,7 +117,7 @@ async def test_open_and_diagnostic( ls = LanguageServer(name='zc.buildout.languageserver', version='dev', loop=asyncio.new_event_loop()) - ls.lsp.workspace = workspace + ls.lsp.workspace = workspace # type: ignore async def open_and_get_diagnostics() -> List[Diagnostic]: diags: List[Diagnostic] = [] diff --git a/server/buildoutls/buildout.py b/server/buildoutls/buildout.py index cac5eee..0aadeba 100644 --- a/server/buildoutls/buildout.py +++ b/server/buildoutls/buildout.py @@ -563,7 +563,7 @@ async def getTemplate( uri_path.relative_to( pathlib.Path(self.uri[len('file://'):]).parent))) - document = ls.workspace.get_document(uri) + document = ls.workspace.get_text_document(uri) if not os.path.exists(document.path): return None @@ -969,7 +969,7 @@ async def parse( logger.warning('Error parsing from uri %s', uri, exc_info=True) fp = io.StringIO('') else: - document = ls.workspace.get_document(uri) + document = ls.workspace.get_text_document(uri) try: fp = io.StringIO(document.source) except IOError: @@ -1312,7 +1312,7 @@ async def open( For buildout, it is a wrapper over _open which uses language server's workspace """ - document = ls.workspace.get_document(uri) + document = ls.workspace.get_text_document(uri) logger.debug("open %s", uri) if not force_open_as_buildout_profile: # First, try to read as a template, because buildout profiles can be templates. diff --git a/server/buildoutls/server.py b/server/buildoutls/server.py index e36165c..9df1564 100644 --- a/server/buildoutls/server.py +++ b/server/buildoutls/server.py @@ -221,7 +221,7 @@ async def lsp_completion( params: CompletionParams, ) -> Optional[List[CompletionItem]]: items: List[CompletionItem] = [] - doc = ls.workspace.get_document(params.text_document.uri) + doc = ls.workspace.get_text_document(params.text_document.uri) def getSectionReferenceCompletionTextEdit( doc: Document, diff --git a/server/buildoutls/tests/conftest.py b/server/buildoutls/tests/conftest.py index d8d024e..0490ef5 100644 --- a/server/buildoutls/tests/conftest.py +++ b/server/buildoutls/tests/conftest.py @@ -58,7 +58,7 @@ def __init__(self): server = FakeServer() - def get_document(uri) -> Document: + def get_text_document(uri) -> Document: parsed_uri = urllib.parse.urlparse(uri) assert parsed_uri.scheme == "file" assert parsed_uri.path[0] == '/' @@ -67,7 +67,7 @@ def get_document(uri) -> Document: document.path = os.path.join(root_path, parsed_uri.path[1:]) return document - server.workspace.get_document = mock.Mock(side_effect=get_document) + server.workspace.get_text_document = mock.Mock(side_effect=get_text_document) def os_path_exists(path: str) -> bool: if path.startswith('/'): @@ -89,7 +89,7 @@ def clearCaches() -> None: server.publish_diagnostics.reset_mock() server.show_message.reset_mock() server.show_message_log.reset_mock() - server.workspace.get_document.reset_mock() + server.workspace.get_text_document.reset_mock() clearCaches() diff --git a/server/buildoutls/tests/test_buildout_parser.py b/server/buildoutls/tests/test_buildout_parser.py index 61cf022..5135c2c 100644 --- a/server/buildoutls/tests/test_buildout_parser.py +++ b/server/buildoutls/tests/test_buildout_parser.py @@ -678,7 +678,7 @@ async def test_open_extends_cache(server: LanguageServer): ) # check the cache is effective, the same file is included twice, # but we load it only once. - assert server.workspace.get_document.call_count == 4 # type: ignore + assert server.workspace.get_text_document.call_count == 4 # type: ignore async def test_open_extends_cache_clear(server: LanguageServer): @@ -693,10 +693,10 @@ async def test_open_extends_cache_clear(server: LanguageServer): assert 'option' in symbol.referenced_section clearCache('file:///extended/extended.cfg') - original_get_document = server.workspace.get_document + original_get_text_document = server.workspace.get_text_document def getModifiedDocument(uri: str): - doc = original_get_document(uri) + doc = original_get_text_document(uri) if uri == 'file:///extended/extended.cfg': doc._source = textwrap.dedent('''\ [extended_option] @@ -706,7 +706,7 @@ def getModifiedDocument(uri: str): with mock.patch.object( server.workspace, - 'get_document', + 'get_text_document', side_effect=getModifiedDocument, ): parsed = await open( @@ -724,9 +724,9 @@ def getModifiedDocument(uri: str): async def test_open_resolved_cache_clear(server: LanguageServer): with mock.patch.object( server.workspace, - 'get_document', - wraps=server.workspace.get_document, - ) as get_document_initial: + 'get_text_document', + wraps=server.workspace.get_text_document, + ) as get_text_document_initial: parsed = await open( ls=server, uri='file:///extended/two_levels.cfg', @@ -737,15 +737,15 @@ async def test_open_resolved_cache_clear(server: LanguageServer): assert symbol.referenced_section is not None assert 'option' in symbol.referenced_section assert mock.call( - 'file:///extended/extended.cfg') in get_document_initial.mock_calls + 'file:///extended/extended.cfg') in get_text_document_initial.mock_calls clearCache('file:///extended/two_levels.cfg') with mock.patch.object( server.workspace, - 'get_document', - wraps=server.workspace.get_document, - ) as get_document_after_clear_cache: + 'get_text_document', + wraps=server.workspace.get_text_document, + ) as get_text_document_after_clear_cache: parsed = await open( ls=server, uri='file:///extended/two_levels.cfg', @@ -756,9 +756,9 @@ async def test_open_resolved_cache_clear(server: LanguageServer): assert symbol.referenced_section is not None assert 'option' in symbol.referenced_section assert mock.call('file:///extended/two_levels.cfg' - ) in get_document_after_clear_cache.mock_calls + ) in get_text_document_after_clear_cache.mock_calls assert mock.call('file:///extended/extended.cfg' - ) not in get_document_after_clear_cache.mock_calls + ) not in get_text_document_after_clear_cache.mock_calls async def test_open_macro(server: LanguageServer): diff --git a/server/requirements.txt b/server/requirements.txt index 047e8eb..58d3b76 100644 --- a/server/requirements.txt +++ b/server/requirements.txt @@ -10,14 +10,14 @@ async-timeout==4.0.3 attrs==23.1.0 cachetools==5.3.1 cattrs==23.1.2 -charset-normalizer==3.2.0 +charset-normalizer==3.3.0 exceptiongroup==1.1.3 frozenlist==1.4.0 idna==3.4 lsprotocol==2023.0.0b1 multidict==6.0.4 -packaging==23.1 -pygls==1.0.2 +packaging==23.2 +pygls==1.1.0 typeguard==3.0.2 typing-extensions==4.8.0 wheel==0.41.2 diff --git a/server/setup.py b/server/setup.py index e2f0da3..0d92463 100644 --- a/server/setup.py +++ b/server/setup.py @@ -33,7 +33,7 @@ 'aiohttp', 'cachetools', 'packaging', - 'pygls >= 1.0', + 'pygls >= 1.1.0', 'typing-extensions', 'zc.buildout', ], diff --git a/server/test-requirements.txt b/server/test-requirements.txt index 1fd5990..30ea267 100644 --- a/server/test-requirements.txt +++ b/server/test-requirements.txt @@ -7,13 +7,13 @@ aiohttp==3.8.5 aioresponses==0.7.4 aiosignal==1.3.1 -astroid==2.15.6 +astroid==3.0.0 async-timeout==4.0.3 attrs==23.1.0 cachetools==5.3.1 cattrs==23.1.2 -charset-normalizer==3.2.0 -coverage[toml]==7.3.1 +charset-normalizer==3.3.0 +coverage[toml]==7.3.2 dill==0.3.7 exceptiongroup==1.1.3 frozenlist==1.4.0 @@ -21,18 +21,17 @@ idna==3.4 importlib-metadata==6.8.0 iniconfig==2.0.0 isort==5.12.0 -lazy-object-proxy==1.9.0 lsprotocol==2023.0.0b1 mccabe==0.7.0 multidict==6.0.4 mypy==1.5.1 mypy-extensions==1.0.0 -packaging==23.1 -platformdirs==3.10.0 +packaging==23.2 +platformdirs==3.11.0 pluggy==1.3.0 py-cpuinfo==9.0.0 -pygls==1.0.2 -pylint==2.17.5 +pygls==1.1.0 +pylint==3.0.0 pytest==7.4.2 pytest-asyncio==0.21.1 pytest-benchmark==4.0.0 @@ -45,8 +44,7 @@ types-setuptools==68.2.0.0 types-toml==0.10.8.7 typing-extensions==4.8.0 wheel==0.41.2 -wrapt==1.15.0 -yapf==0.40.1 +yapf==0.40.2 yarl==1.9.2 # zc-buildout==3.0.1 zipp==3.17.0