From 46bc1aaa8482f9ea53373c9edf3d40b48a99b50f Mon Sep 17 00:00:00 2001 From: Levente Batuska Date: Sat, 14 Mar 2026 23:56:20 +0100 Subject: [PATCH] fix: add python 3.14 support, adopt pygls >=2.0.0 api --- .github/CODEOWNERS | 1 - .github/workflows/publish.yml | 30 ------------------ .github/workflows/tests.yml | 54 --------------------------------- .gitignore | 5 +++ cmake_language_server/server.py | 2 +- pdm.lock | 36 ++++++++++++---------- pyproject.toml | 4 +-- tests/conftest.py | 6 ++-- tests/test_server.py | 14 ++++----- tox.ini | 3 +- 10 files changed, 40 insertions(+), 115 deletions(-) delete mode 100644 .github/CODEOWNERS delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/tests.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index b85cf3d..0000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @regen100 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 94fed93..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Publish - -on: - push: - tags: - - v* - -permissions: - contents: write - -jobs: - publish: - name: Publish to PyPI - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up PDM - uses: pdm-project/setup-pdm@v4 - - name: Build - run: | - pdm build - - name: Publish package - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_PASSWORD }} - - name: Release - uses: softprops/action-gh-release@v2 - with: - generate_release_notes: true diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 5d26fcb..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Tests - -on: - pull_request: - push: - branches: - - master - -jobs: - build: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - python: ["3.9", "3.10", "3.11", "3.12", "3.13"] - os: [ubuntu-22.04, windows-2022] - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python }} - - name: Set up PDM - uses: pdm-project/setup-pdm@v4 - with: - python-version: ${{ matrix.python }} - cache: true - - name: Setup VC - uses: ilammy/msvc-dev-cmd@v1 - if: contains(matrix.os, 'windows') - - name: Install CMake - if: contains(matrix.os, 'ubuntu') - run: | - CMAKE_VERSION=3.25.1 - curl -sSL https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz | tar xz - sudo cp -rT cmake-${CMAKE_VERSION}-linux-x86_64 /usr/local - - name: Install dependencies - run: | - cmake --version - python -m pip install --upgrade setuptools pip wheel - python -m pip install tox tox-gh-actions - - name: Test with tox - run: | - tox - env: - os: ${{ matrix.os }} - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} - flags: unittests - name: Python ${{ matrix.python }} on ${{ matrix.os }} - fail_ci_if_error: false diff --git a/.gitignore b/.gitignore index efc8766..c590584 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ cmake_language_server/version.py +.venv/ +pyrightconfig.json + /build/ /dist/ __pycache__/ @@ -11,3 +14,5 @@ coverage.xml .pdm-python __pypackages__/ + +.pdm-build/ diff --git a/cmake_language_server/server.py b/cmake_language_server/server.py index 0d7f48e..fd974c7 100644 --- a/cmake_language_server/server.py +++ b/cmake_language_server/server.py @@ -31,7 +31,7 @@ from lsprotocol.types import ( TextDocumentPositionParams, TextEdit, ) -from pygls.server import LanguageServer +from pygls.lsp.server import LanguageServer from .api import API diff --git a/pdm.lock b/pdm.lock index 2c21df3..3a8d140 100644 --- a/pdm.lock +++ b/pdm.lock @@ -4,17 +4,20 @@ [metadata] groups = ["default", "dev", "lint"] strategy = ["cross_platform"] -lock_version = "4.4.1" -content_hash = "sha256:801e3af66b4127c047d051c3b10a9b5e0b793d27f5eab4fd0b1514cfdda34803" +lock_version = "4.5.0" +content_hash = "sha256:ef24aee91e46f0db41b85228c16cb2703f20aff76eb93225d2a982304959120e" + +[[metadata.targets]] +requires_python = ">=3.10.0,<3.16" [[package]] name = "attrs" -version = "23.2.0" -requires_python = ">=3.7" +version = "25.4.0" +requires_python = ">=3.9" summary = "Classes Without Boilerplate" files = [ - {file = "attrs-23.2.0-py3-none-any.whl", hash = "sha256:99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1"}, - {file = "attrs-23.2.0.tar.gz", hash = "sha256:935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30"}, + {file = "attrs-25.4.0-py3-none-any.whl", hash = "sha256:adcf7e2a1fb3b36ac48d97835bb6d8ade15b8dcce26aba8bf1d14847b57a3373"}, + {file = "attrs-25.4.0.tar.gz", hash = "sha256:16d5969b87f0859ef33a48b35d55ac1be6e42ae49d5e853b597db70c35c57e11"}, ] [[package]] @@ -278,16 +281,16 @@ files = [ [[package]] name = "lsprotocol" -version = "2023.0.1" -requires_python = ">=3.7" -summary = "Python implementation of the Language Server Protocol." +version = "2025.0.0" +requires_python = ">=3.8" +summary = "Python types for Language Server Protocol." dependencies = [ "attrs>=21.3.0", "cattrs!=23.2.1", ] files = [ - {file = "lsprotocol-2023.0.1-py3-none-any.whl", hash = "sha256:c75223c9e4af2f24272b14c6375787438279369236cd568f596d4951052a60f2"}, - {file = "lsprotocol-2023.0.1.tar.gz", hash = "sha256:cc5c15130d2403c18b734304339e51242d3018a05c4f7d0f198ad6e0cd21861d"}, + {file = "lsprotocol-2025.0.0-py3-none-any.whl", hash = "sha256:f9d78f25221f2a60eaa4a96d3b4ffae011b107537facee61d3da3313880995c7"}, + {file = "lsprotocol-2025.0.0.tar.gz", hash = "sha256:e879da2b9301e82cfc3e60d805630487ac2f7ab17492f4f5ba5aaba94fe56c29"}, ] [[package]] @@ -412,16 +415,17 @@ files = [ [[package]] name = "pygls" -version = "1.3.1" -requires_python = ">=3.8" +version = "2.0.1" +requires_python = ">=3.9" summary = "A pythonic generic language server (pronounced like 'pie glass')" dependencies = [ + "attrs>=24.3.0", "cattrs>=23.1.2", - "lsprotocol==2023.0.1", + "lsprotocol==2025.0.0", ] files = [ - {file = "pygls-1.3.1-py3-none-any.whl", hash = "sha256:6e00f11efc56321bdeb6eac04f6d86131f654c7d49124344a9ebb968da3dd91e"}, - {file = "pygls-1.3.1.tar.gz", hash = "sha256:140edceefa0da0e9b3c533547c892a42a7d2fd9217ae848c330c53d266a55018"}, + {file = "pygls-2.0.1-py3-none-any.whl", hash = "sha256:d29748042cea5bedc98285eb3e2c0c60bf3fc73786319519001bf72bbe8f36cc"}, + {file = "pygls-2.0.1.tar.gz", hash = "sha256:2f774a669fbe2ece977d302786f01f9b0c5df7d0204ea0fa371ecb08288d6b86"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index 3c47610..b71d953 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,9 +6,9 @@ authors = [ {name = "Regen"}, ] dependencies = [ - "pygls>=1.1.1", + "pygls>=2.0.0", ] -requires-python = ">=3.8.0,<3.14" +requires-python = ">=3.10.0,<3.16" readme = "README.md" license = {text = "MIT"} keywords = ["cmake", "completion", "vim", "lsp"] diff --git a/tests/conftest.py b/tests/conftest.py index dc7cad7..8a7e40b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,7 +7,7 @@ from typing import Iterable, Tuple import pytest from lsprotocol.types import EXIT, SHUTDOWN -from pygls.server import LanguageServer +from pygls.lsp.server import LanguageServer from cmake_language_server.server import CMakeLanguageServer @@ -54,7 +54,7 @@ def client_server() -> Iterable[Tuple[LanguageServer, CMakeLanguageServer]]: if hasattr(client.loop, "_signal_handlers"): client.loop._signal_handlers.clear() - client.lsp.send_request(SHUTDOWN) # type:ignore[no-untyped-call] - client.lsp.notify(EXIT) + client.protocol.send_request(SHUTDOWN) # type:ignore[no-untyped-call] + client.protocol.notify(EXIT) client_thread.join() server_thread.join() diff --git a/tests/test_server.py b/tests/test_server.py index e6cfe6e..d13d15d 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -27,7 +27,7 @@ from lsprotocol.types import ( TextDocumentIdentifier, TextDocumentItem, ) -from pygls.server import LanguageServer +from pygls.lsp.server import LanguageServer from cmake_language_server.server import CMakeLanguageServer @@ -38,7 +38,7 @@ def _init(client: LanguageServer, root: Path) -> None: retry = 3 while retry > 0: try: - client.lsp.send_request( # type:ignore[no-untyped-call] + client.protocol.send_request( # type:ignore[no-untyped-call] INITIALIZE, InitializeParams( process_id=1234, @@ -56,7 +56,7 @@ def _open(client: LanguageServer, path: Path, text: Optional[str] = None) -> Non if text is None: text = path.read_text() - client.lsp.notify( + client.protocol.notify( TEXT_DOCUMENT_DID_OPEN, DidOpenTextDocumentParams( text_document=TextDocumentItem( @@ -81,7 +81,7 @@ def _test_completion( position=Position(line=0, character=len(content)), context=context, ) - ret = client.lsp.send_request( # type:ignore[no-untyped-call] + ret = client.protocol.send_request( # type:ignore[no-untyped-call] TEXT_DOCUMENT_COMPLETION, params ).result(timeout=CALL_TIMEOUT) assert isinstance(ret, CompletionList) @@ -107,7 +107,7 @@ def test_workspace_did_change_configuration( old_api = server._api - client.lsp.notify( + client.protocol.notify( WORKSPACE_DID_CHANGE_CONFIGURATION, DidChangeConfigurationParams( settings={"initialization_options": {"buildDirectory": "c_build"}} @@ -169,7 +169,7 @@ def test_formatting( _init(client, datadir) path = datadir / "CMakeLists.txt" _open(client, path, "a ( b c ) ") - response = client.lsp.send_request( # type:ignore[no-untyped-call] + response = client.protocol.send_request( # type:ignore[no-untyped-call] TEXT_DOCUMENT_FORMATTING, DocumentFormattingParams( text_document=TextDocumentIdentifier(uri=path.as_uri()), @@ -186,7 +186,7 @@ def test_hover( _init(client, datadir) path = datadir / "CMakeLists.txt" _open(client, path, "project()") - response = client.lsp.send_request( # type:ignore[no-untyped-call] + response = client.protocol.send_request( # type:ignore[no-untyped-call] TEXT_DOCUMENT_HOVER, HoverParams( text_document=TextDocumentIdentifier(uri=path.as_uri()), diff --git a/tox.ini b/tox.ini index 647a57f..94748cf 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -env_list = py{39,310,311,312,313} +env_list = py{39,310,311,312,313,314} isolated_build = True passenv = * setenv = @@ -12,6 +12,7 @@ python = 3.11: py311 3.12: py312 3.13: py313 + 3.14: py314 [testenv] allowlist_externals =