chore(lsprotocol): migrate to 2025.0.0 and cleanup artifacts

The changes align the project with the 2025.0.0 lsprotocol
release, removing the old backport and updating type hints
in the protocol hooks to use Sequence where appropriate. The
dist-info and packaging metadata for older lsprotocol
versions are replaced with the new 2025.0.0 artifacts.

- Remove exceptiongroup backport used on Python <3.11
- Use Sequence instead of List in LS protocol hooks
- Replace old dist-info with 2025.0.0 metadata
This commit is contained in:
Christoph Brandau
2026-09-03 08:39:12 +02:00
parent a0a0d38fe5
commit 53ebc5d055
101 changed files with 13838 additions and 7624 deletions
+29 -8
View File
@@ -16,7 +16,10 @@
# See the License for the specific language governing permissions and #
# limitations under the License. #
############################################################################
from __future__ import annotations
import traceback
from typing import Any
from typing import Set
from typing import Type
from lsprotocol.types import ResponseError
@@ -25,14 +28,23 @@ from lsprotocol.types import ResponseError
class JsonRpcException(Exception):
"""A class used as a base class for json rpc exceptions."""
def __init__(self, message=None, code=None, data=None):
message = message or getattr(self.__class__, "MESSAGE")
CODE = -32603
MESSAGE = ""
def __init__(
self,
message: str | None = None,
code: int | None = None,
data: Any | None = None,
):
message = message or self.MESSAGE
super().__init__(message)
self.message = message
self.code = code or getattr(self.__class__, "CODE")
self.message: str = message
self.code: int = code or self.CODE
self.data = data
def __eq__(self, other):
def __eq__(self, other: Any):
return (
isinstance(other, self.__class__)
and self.code == other.code
@@ -43,7 +55,7 @@ class JsonRpcException(Exception):
return hash((self.code, self.message))
@staticmethod
def from_error(error):
def from_error(error: ResponseError):
for exc_class in _EXCEPTIONS:
if exc_class.supports_code(error.code):
return exc_class(
@@ -53,7 +65,16 @@ class JsonRpcException(Exception):
return JsonRpcException(code=error.code, message=error.message, data=error.data)
@classmethod
def supports_code(cls, code):
def of(cls, exc: Any):
"""Default ``of`` implementation that raises a ``JsonRpcException`` derived from
the given exception
"""
return cls(
message=f"{cls.MESSAGE}: {exc}",
)
@classmethod
def supports_code(cls, code: int):
# Defaults to UnknownErrorCode
return getattr(cls, "CODE", -32001) == code
@@ -91,7 +112,7 @@ class JsonRpcMethodNotFound(JsonRpcException):
MESSAGE = "Method Not Found"
@classmethod
def of(cls, method):
def of(cls, method: str):
return cls(message=cls.MESSAGE + ": " + method)