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:
@@ -9,6 +9,7 @@ from typing import TYPE_CHECKING, Any, Protocol, TypeVar
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
import sys
|
||||
from collections.abc import Collection
|
||||
from urllib.parse import SplitResult
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
from typing import Self
|
||||
@@ -83,7 +84,7 @@ _PEP610_USER_PASS_ENV_VARS_REGEX = re.compile(
|
||||
def _strip_auth_from_netloc(netloc: str, safe_user_passwords: Collection[str]) -> str:
|
||||
if "@" not in netloc:
|
||||
return netloc
|
||||
user_pass, netloc_no_user_pass = netloc.split("@", 1)
|
||||
user_pass, netloc_no_user_pass = netloc.rsplit("@", 1)
|
||||
if user_pass in safe_user_passwords:
|
||||
return netloc
|
||||
if _PEP610_USER_PASS_ENV_VARS_REGEX.match(user_pass):
|
||||
@@ -109,8 +110,15 @@ def _strip_url(url: str, safe_user_passwords: Collection[str]) -> str:
|
||||
)
|
||||
|
||||
|
||||
def _file_url_has_absolute_path(parsed_url: SplitResult) -> bool:
|
||||
return parsed_url.path.startswith("/")
|
||||
|
||||
|
||||
class DirectUrlValidationError(Exception):
|
||||
"""Raised when when input data is not spec-compliant."""
|
||||
"""Raised when when input data is not spec-compliant.
|
||||
|
||||
.. versionadded:: 26.1
|
||||
"""
|
||||
|
||||
context: str | None = None
|
||||
message: str
|
||||
@@ -146,6 +154,8 @@ class _DirectUrlRequiredKeyError(DirectUrlValidationError):
|
||||
|
||||
@dataclasses.dataclass(frozen=True, init=False)
|
||||
class VcsInfo:
|
||||
"""The version control information of a :class:`DirectUrl`."""
|
||||
|
||||
vcs: str
|
||||
commit_id: str
|
||||
requested_revision: str | None = None
|
||||
@@ -173,6 +183,8 @@ class VcsInfo:
|
||||
|
||||
@dataclasses.dataclass(frozen=True, init=False)
|
||||
class ArchiveInfo:
|
||||
"""The archive information of a :class:`DirectUrl`."""
|
||||
|
||||
hashes: Mapping[str, str] | None = None
|
||||
|
||||
def __init__(
|
||||
@@ -219,6 +231,8 @@ class ArchiveInfo:
|
||||
|
||||
@dataclasses.dataclass(frozen=True, init=False)
|
||||
class DirInfo:
|
||||
"""The local directory information of a :class:`DirectUrl`."""
|
||||
|
||||
editable: bool | None = None
|
||||
|
||||
def __init__(
|
||||
@@ -237,7 +251,10 @@ class DirInfo:
|
||||
|
||||
@dataclasses.dataclass(frozen=True, init=False)
|
||||
class DirectUrl:
|
||||
"""A class representing a direct URL."""
|
||||
"""A class representing a direct URL.
|
||||
|
||||
.. versionadded:: 26.1
|
||||
"""
|
||||
|
||||
url: str
|
||||
archive_info: ArchiveInfo | None = None
|
||||
@@ -277,11 +294,18 @@ class DirectUrl:
|
||||
raise DirectUrlValidationError(
|
||||
"Exactly one of vcs_info, archive_info, dir_info must be present"
|
||||
)
|
||||
if direct_url.dir_info is not None and not direct_url.url.startswith("file://"):
|
||||
raise DirectUrlValidationError(
|
||||
"URL scheme must be file:// when dir_info is present",
|
||||
context="url",
|
||||
)
|
||||
if direct_url.dir_info is not None:
|
||||
parsed_url = urllib.parse.urlsplit(direct_url.url)
|
||||
if parsed_url.scheme != "file":
|
||||
raise DirectUrlValidationError(
|
||||
"URL scheme must be file:// when dir_info is present",
|
||||
context="url",
|
||||
)
|
||||
if not _file_url_has_absolute_path(parsed_url):
|
||||
raise DirectUrlValidationError(
|
||||
"File URL must be absolute when dir_info is present",
|
||||
context="url",
|
||||
)
|
||||
# XXX subdirectory must be relative, can we, should we validate that here?
|
||||
return direct_url
|
||||
|
||||
|
||||
Reference in New Issue
Block a user