diff --git a/pyproject.toml b/pyproject.toml index 0b0f9f9..d3ba68a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -241,6 +241,10 @@ ignore = [ "SIM105", # forbids empty/general except clause "SIM113", # wants to enforce use of enumerate "E712", # forbids equality comparison with True/False + "UP007", # forbids some uses of Union + "TID252", # forbids relative imports + "B904", # forces use of raise from other_exception + "RUF012", # forbids mutable attributes as ClassVar ] unfixable = [ "F841", diff --git a/src/serena/agent.py b/src/serena/agent.py index 4952aa2..97bf63e 100644 --- a/src/serena/agent.py +++ b/src/serena/agent.py @@ -34,9 +34,6 @@ from sensai.util.logging import LOG_DEFAULT_FORMAT, FallbackHandler from sensai.util.string import ToStringMixin, dict_string from multilspy import SyncLanguageServer -from solidlsp.multilspy_config import Language, MultilspyConfig -from solidlsp.multilspy_logger import MultilspyLogger -from solidlsp.multilspy_types import SymbolKind from serena import serena_version from serena.config import SerenaAgentContext, SerenaAgentMode from serena.constants import ( @@ -57,6 +54,9 @@ from serena.util.inspection import determine_programming_language_composition, i from serena.util.shell import execute_shell_command from serena.util.thread import ExecutionResult, execute_with_timeout from solidlsp.ls import SolidLanguageServer +from solidlsp.multilspy_config import Language, MultilspyConfig +from solidlsp.multilspy_logger import MultilspyLogger +from solidlsp.multilspy_types import SymbolKind if TYPE_CHECKING: from serena.gui_log_viewer import GuiLogViewerHandler diff --git a/src/serena/util/inspection.py b/src/serena/util/inspection.py index 1e5abd5..4847fd1 100644 --- a/src/serena/util/inspection.py +++ b/src/serena/util/inspection.py @@ -3,8 +3,8 @@ import os from collections.abc import Generator from typing import TypeVar -from solidlsp.multilspy_config import Language from serena.util.file_system import find_all_non_ignored_files +from solidlsp.multilspy_config import Language T = TypeVar("T") diff --git a/src/solidlsp/language_servers/clangd_language_server/clangd_language_server.py b/src/solidlsp/language_servers/clangd_language_server/clangd_language_server.py index c3d3497..a61ba13 100644 --- a/src/solidlsp/language_servers/clangd_language_server/clangd_language_server.py +++ b/src/solidlsp/language_servers/clangd_language_server/clangd_language_server.py @@ -9,12 +9,12 @@ import pathlib import stat import threading +from solidlsp.ls import SolidLanguageServer from solidlsp.lsp_protocol_handler.lsp_types import InitializeParams from solidlsp.lsp_protocol_handler.server import ProcessLaunchInfo from solidlsp.multilspy_config import MultilspyConfig from solidlsp.multilspy_logger import MultilspyLogger from solidlsp.multilspy_utils import FileUtils, PlatformUtils -from solidlsp.ls import SolidLanguageServer class ClangdLanguageServer(SolidLanguageServer): diff --git a/src/solidlsp/language_servers/dart_language_server/dart_language_server.py b/src/solidlsp/language_servers/dart_language_server/dart_language_server.py index 710f40a..bf40699 100644 --- a/src/solidlsp/language_servers/dart_language_server/dart_language_server.py +++ b/src/solidlsp/language_servers/dart_language_server/dart_language_server.py @@ -4,10 +4,10 @@ import os import pathlib import stat +from solidlsp.ls import SolidLanguageServer from solidlsp.lsp_protocol_handler.server import ProcessLaunchInfo from solidlsp.multilspy_logger import MultilspyLogger from solidlsp.multilspy_utils import FileUtils, PlatformUtils -from solidlsp.ls import SolidLanguageServer class DartLanguageServer(SolidLanguageServer): diff --git a/src/solidlsp/language_servers/eclipse_jdtls/eclipse_jdtls.py b/src/solidlsp/language_servers/eclipse_jdtls/eclipse_jdtls.py index eb0bafc..bd63594 100644 --- a/src/solidlsp/language_servers/eclipse_jdtls/eclipse_jdtls.py +++ b/src/solidlsp/language_servers/eclipse_jdtls/eclipse_jdtls.py @@ -15,13 +15,13 @@ from pathlib import PurePath from overrides import override +from solidlsp.ls import SolidLanguageServer from solidlsp.lsp_protocol_handler.lsp_types import InitializeParams from solidlsp.lsp_protocol_handler.server import ProcessLaunchInfo from solidlsp.multilspy_config import MultilspyConfig from solidlsp.multilspy_logger import MultilspyLogger from solidlsp.multilspy_settings import MultilspySettings from solidlsp.multilspy_utils import FileUtils, PlatformUtils -from solidlsp.ls import SolidLanguageServer @dataclasses.dataclass diff --git a/src/solidlsp/language_servers/gopls/gopls.py b/src/solidlsp/language_servers/gopls/gopls.py index 04e423a..cd7f6e0 100644 --- a/src/solidlsp/language_servers/gopls/gopls.py +++ b/src/solidlsp/language_servers/gopls/gopls.py @@ -7,11 +7,11 @@ import threading from overrides import override +from solidlsp.ls import SolidLanguageServer from solidlsp.lsp_protocol_handler.lsp_types import InitializeParams from solidlsp.lsp_protocol_handler.server import ProcessLaunchInfo from solidlsp.multilspy_config import MultilspyConfig from solidlsp.multilspy_logger import MultilspyLogger -from solidlsp.ls import SolidLanguageServer class Gopls(SolidLanguageServer): diff --git a/src/solidlsp/language_servers/intelephense/intelephense.py b/src/solidlsp/language_servers/intelephense/intelephense.py index d78e483..7e7e8db 100644 --- a/src/solidlsp/language_servers/intelephense/intelephense.py +++ b/src/solidlsp/language_servers/intelephense/intelephense.py @@ -12,12 +12,12 @@ from time import sleep from overrides import override +from solidlsp.ls import SolidLanguageServer from solidlsp.lsp_protocol_handler.lsp_types import DefinitionParams, InitializeParams from solidlsp.lsp_protocol_handler.server import ProcessLaunchInfo from solidlsp.multilspy_config import MultilspyConfig from solidlsp.multilspy_logger import MultilspyLogger from solidlsp.multilspy_utils import PlatformId, PlatformUtils -from solidlsp.ls import SolidLanguageServer class Intelephense(SolidLanguageServer): diff --git a/src/solidlsp/language_servers/jedi_language_server/jedi_server.py b/src/solidlsp/language_servers/jedi_language_server/jedi_server.py index e935954..9ec7554 100644 --- a/src/solidlsp/language_servers/jedi_language_server/jedi_server.py +++ b/src/solidlsp/language_servers/jedi_language_server/jedi_server.py @@ -9,11 +9,11 @@ import pathlib from overrides import override +from solidlsp.ls import SolidLanguageServer from solidlsp.lsp_protocol_handler.lsp_types import InitializeParams from solidlsp.lsp_protocol_handler.server import ProcessLaunchInfo from solidlsp.multilspy_config import MultilspyConfig from solidlsp.multilspy_logger import MultilspyLogger -from solidlsp.ls import SolidLanguageServer class JediServer(SolidLanguageServer): diff --git a/src/solidlsp/language_servers/kotlin_language_server/kotlin_language_server.py b/src/solidlsp/language_servers/kotlin_language_server/kotlin_language_server.py index bab71d1..cf4022c 100644 --- a/src/solidlsp/language_servers/kotlin_language_server/kotlin_language_server.py +++ b/src/solidlsp/language_servers/kotlin_language_server/kotlin_language_server.py @@ -9,12 +9,12 @@ import os import pathlib import stat +from solidlsp.ls import SolidLanguageServer from solidlsp.lsp_protocol_handler.lsp_types import InitializeParams from solidlsp.lsp_protocol_handler.server import ProcessLaunchInfo from solidlsp.multilspy_config import MultilspyConfig from solidlsp.multilspy_logger import MultilspyLogger from solidlsp.multilspy_utils import FileUtils, PlatformUtils -from solidlsp.ls import SolidLanguageServer @dataclasses.dataclass diff --git a/src/solidlsp/language_servers/omnisharp/omnisharp.py b/src/solidlsp/language_servers/omnisharp/omnisharp.py index f558033..b8b33ea 100644 --- a/src/solidlsp/language_servers/omnisharp/omnisharp.py +++ b/src/solidlsp/language_servers/omnisharp/omnisharp.py @@ -12,13 +12,13 @@ from collections.abc import Iterable from overrides import override +from solidlsp.ls import SolidLanguageServer from solidlsp.lsp_protocol_handler.lsp_types import InitializeParams from solidlsp.lsp_protocol_handler.server import ProcessLaunchInfo from solidlsp.multilspy_config import MultilspyConfig from solidlsp.multilspy_exceptions import MultilspyException from solidlsp.multilspy_logger import MultilspyLogger from solidlsp.multilspy_utils import DotnetVersion, FileUtils, PlatformId, PlatformUtils -from solidlsp.ls import SolidLanguageServer def breadth_first_file_scan(root) -> Iterable[str]: diff --git a/src/solidlsp/language_servers/pyright_language_server/pyright_server.py b/src/solidlsp/language_servers/pyright_language_server/pyright_server.py index 7081109..b7ddd07 100644 --- a/src/solidlsp/language_servers/pyright_language_server/pyright_server.py +++ b/src/solidlsp/language_servers/pyright_language_server/pyright_server.py @@ -10,11 +10,11 @@ import threading from overrides import override +from solidlsp.ls import SolidLanguageServer from solidlsp.lsp_protocol_handler.lsp_types import InitializeParams from solidlsp.lsp_protocol_handler.server import ProcessLaunchInfo from solidlsp.multilspy_config import MultilspyConfig from solidlsp.multilspy_logger import MultilspyLogger -from solidlsp.ls import SolidLanguageServer class PyrightServer(SolidLanguageServer): diff --git a/src/solidlsp/language_servers/rust_analyzer/rust_analyzer.py b/src/solidlsp/language_servers/rust_analyzer/rust_analyzer.py index a5a1423..d88cc59 100644 --- a/src/solidlsp/language_servers/rust_analyzer/rust_analyzer.py +++ b/src/solidlsp/language_servers/rust_analyzer/rust_analyzer.py @@ -11,12 +11,12 @@ import threading from overrides import override +from solidlsp.ls import SolidLanguageServer from solidlsp.lsp_protocol_handler.lsp_types import InitializeParams from solidlsp.lsp_protocol_handler.server import ProcessLaunchInfo from solidlsp.multilspy_config import MultilspyConfig from solidlsp.multilspy_logger import MultilspyLogger from solidlsp.multilspy_utils import FileUtils, PlatformUtils -from solidlsp.ls import SolidLanguageServer class RustAnalyzer(SolidLanguageServer): diff --git a/src/solidlsp/language_servers/solargraph/solargraph.py b/src/solidlsp/language_servers/solargraph/solargraph.py index c3ea619..f733e30 100644 --- a/src/solidlsp/language_servers/solargraph/solargraph.py +++ b/src/solidlsp/language_servers/solargraph/solargraph.py @@ -12,11 +12,11 @@ import subprocess import threading from typing import override +from solidlsp.ls import SolidLanguageServer from solidlsp.lsp_protocol_handler.lsp_types import InitializeParams from solidlsp.lsp_protocol_handler.server import ProcessLaunchInfo from solidlsp.multilspy_config import MultilspyConfig from solidlsp.multilspy_logger import MultilspyLogger -from solidlsp.ls import SolidLanguageServer class Solargraph(SolidLanguageServer): diff --git a/src/solidlsp/language_servers/typescript_language_server/typescript_language_server.py b/src/solidlsp/language_servers/typescript_language_server/typescript_language_server.py index 1d6c3f7..3fe2d86 100644 --- a/src/solidlsp/language_servers/typescript_language_server/typescript_language_server.py +++ b/src/solidlsp/language_servers/typescript_language_server/typescript_language_server.py @@ -13,12 +13,12 @@ from time import sleep from overrides import override +from solidlsp.ls import SolidLanguageServer from solidlsp.lsp_protocol_handler.lsp_types import InitializeParams from solidlsp.lsp_protocol_handler.server import ProcessLaunchInfo from solidlsp.multilspy_config import MultilspyConfig from solidlsp.multilspy_logger import MultilspyLogger from solidlsp.multilspy_utils import PlatformId, PlatformUtils -from solidlsp.ls import SolidLanguageServer # Platform-specific imports if os.name != "nt": # Unix-like systems diff --git a/src/solidlsp/ls.py b/src/solidlsp/ls.py index 2ff2edf..cc792db 100644 --- a/src/solidlsp/ls.py +++ b/src/solidlsp/ls.py @@ -16,9 +16,12 @@ from typing import Self, cast import pathspec import tqdm -from solidlsp import multilspy_types from multilspy.language_server import GenericDocumentSymbol, LSPFileBuffer, ReferenceInSymbol -from solidlsp.lsp_protocol_handler import lsp_types, lsp_types as LSPTypes +from serena.text_utils import MatchedConsecutiveLines, search_files +from solidlsp import multilspy_types +from solidlsp.ls_handler import SolidLanguageServerHandler +from solidlsp.lsp_protocol_handler import lsp_types +from solidlsp.lsp_protocol_handler import lsp_types as LSPTypes from solidlsp.lsp_protocol_handler.lsp_constants import LSPConstants from solidlsp.lsp_protocol_handler.lsp_types import Definition, DefinitionParams, LocationLink, SymbolKind from solidlsp.lsp_protocol_handler.server import ( @@ -30,8 +33,6 @@ from solidlsp.multilspy_config import Language, MultilspyConfig from solidlsp.multilspy_exceptions import MultilspyException from solidlsp.multilspy_logger import MultilspyLogger from solidlsp.multilspy_utils import FileUtils, PathUtils, TextUtils -from serena.text_utils import MatchedConsecutiveLines, search_files -from solidlsp.ls_handler import SolidLanguageServerHandler class SolidLanguageServer(ABC): @@ -174,8 +175,7 @@ class SolidLanguageServer(ABC): # load cache first to prevent any racing conditions due to asyncio stuff self._document_symbols_cache: dict[ - str, tuple[str, tuple[list[multilspy_types.UnifiedSymbolInformation], list[ - multilspy_types.UnifiedSymbolInformation]]] + str, tuple[str, tuple[list[multilspy_types.UnifiedSymbolInformation], list[multilspy_types.UnifiedSymbolInformation]]] ] = {} """Maps file paths to a tuple of (file_content_hash, result_of_request_document_symbols)""" self._cache_lock = threading.Lock() @@ -543,8 +543,7 @@ class SolidLanguageServer(ABC): return ret # Some LS cause problems with this, so the call is isolated from the rest to allow overriding in subclasses - def _send_references_request(self, relative_file_path: str, line: int, column: int) -> list[ - lsp_types.Location] | None: + def _send_references_request(self, relative_file_path: str, line: int, column: int) -> list[lsp_types.Location] | None: return self.server.send.references( { "textDocument": {"uri": PathUtils.path_to_uri(os.path.join(self.repository_root_path, relative_file_path))}, @@ -840,8 +839,7 @@ class SolidLanguageServer(ABC): if LSPConstants.CHILDREN in root_symbol: # TODO: l_tree should be a list of TreeRepr. Define the following function to return TreeRepr as well - def visit_tree_nodes_and_build_tree_repr(node: GenericDocumentSymbol) -> list[ - multilspy_types.UnifiedSymbolInformation]: + def visit_tree_nodes_and_build_tree_repr(node: GenericDocumentSymbol) -> list[multilspy_types.UnifiedSymbolInformation]: node = cast(multilspy_types.UnifiedSymbolInformation, node) l: list[multilspy_types.UnifiedSymbolInformation] = [] turn_item_into_symbol_with_children(node) diff --git a/src/solidlsp/ls_handler.py b/src/solidlsp/ls_handler.py index a091043..e4c8b68 100644 --- a/src/solidlsp/ls_handler.py +++ b/src/solidlsp/ls_handler.py @@ -28,8 +28,8 @@ from solidlsp.lsp_protocol_handler.server import ( make_request, make_response, ) -from solidlsp.multilspy_exceptions import MultilspyException from solidlsp.lsp_request import SolidLspRequest +from solidlsp.multilspy_exceptions import MultilspyException log = logging.getLogger(__name__) diff --git a/src/solidlsp/lsp_protocol_handler/lsp_constants.py b/src/solidlsp/lsp_protocol_handler/lsp_constants.py index 4ca5c3d..329c003 100644 --- a/src/solidlsp/lsp_protocol_handler/lsp_constants.py +++ b/src/solidlsp/lsp_protocol_handler/lsp_constants.py @@ -2,6 +2,7 @@ This module contains constants used in the LSP protocol. """ + class LSPConstants: """ This class contains constants used in the LSP protocol. diff --git a/src/solidlsp/lsp_protocol_handler/lsp_requests.py b/src/solidlsp/lsp_protocol_handler/lsp_requests.py index 206f252..383e456 100644 --- a/src/solidlsp/lsp_protocol_handler/lsp_requests.py +++ b/src/solidlsp/lsp_protocol_handler/lsp_requests.py @@ -29,7 +29,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -from typing import List, Union +from typing import Union + from solidlsp.lsp_protocol_handler import lsp_types @@ -39,96 +40,94 @@ class LspRequest: async def implementation( self, params: lsp_types.ImplementationParams - ) -> Union["lsp_types.Definition", List["lsp_types.LocationLink"], None]: + ) -> Union["lsp_types.Definition", list["lsp_types.LocationLink"], None]: """A request to resolve the implementation locations of a symbol at a given text document position. The request's parameter is of type [TextDocumentPositionParams] (#TextDocumentPositionParams) the response is of type {@link Definition} or a - Thenable that resolves to such.""" + Thenable that resolves to such. + """ return await self.send_request("textDocument/implementation", params) async def type_definition( self, params: lsp_types.TypeDefinitionParams - ) -> Union["lsp_types.Definition", List["lsp_types.LocationLink"], None]: + ) -> Union["lsp_types.Definition", list["lsp_types.LocationLink"], None]: """A request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type [TextDocumentPositionParams] (#TextDocumentPositionParams) the response is of type {@link Definition} or a - Thenable that resolves to such.""" + Thenable that resolves to such. + """ return await self.send_request("textDocument/typeDefinition", params) - async def document_color( - self, params: lsp_types.DocumentColorParams - ) -> List["lsp_types.ColorInformation"]: + async def document_color(self, params: lsp_types.DocumentColorParams) -> list["lsp_types.ColorInformation"]: """A request to list all color symbols found in a given text document. The request's parameter is of type {@link DocumentColorParams} the response is of type {@link ColorInformation ColorInformation[]} or a Thenable - that resolves to such.""" + that resolves to such. + """ return await self.send_request("textDocument/documentColor", params) - async def color_presentation( - self, params: lsp_types.ColorPresentationParams - ) -> List["lsp_types.ColorPresentation"]: + async def color_presentation(self, params: lsp_types.ColorPresentationParams) -> list["lsp_types.ColorPresentation"]: """A request to list all presentation for a color. The request's parameter is of type {@link ColorPresentationParams} the response is of type {@link ColorInformation ColorInformation[]} or a Thenable - that resolves to such.""" + that resolves to such. + """ return await self.send_request("textDocument/colorPresentation", params) - async def folding_range( - self, params: lsp_types.FoldingRangeParams - ) -> Union[List["lsp_types.FoldingRange"], None]: + async def folding_range(self, params: lsp_types.FoldingRangeParams) -> list["lsp_types.FoldingRange"] | None: """A request to provide folding ranges in a document. The request's parameter is of type {@link FoldingRangeParams}, the response is of type {@link FoldingRangeList} or a Thenable - that resolves to such.""" + that resolves to such. + """ return await self.send_request("textDocument/foldingRange", params) async def declaration( self, params: lsp_types.DeclarationParams - ) -> Union["lsp_types.Declaration", List["lsp_types.LocationLink"], None]: + ) -> Union["lsp_types.Declaration", list["lsp_types.LocationLink"], None]: """A request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type [TextDocumentPositionParams] (#TextDocumentPositionParams) the response is of type {@link Declaration} or a typed array of {@link DeclarationLink} or a Thenable that resolves - to such.""" + to such. + """ return await self.send_request("textDocument/declaration", params) - async def selection_range( - self, params: lsp_types.SelectionRangeParams - ) -> Union[List["lsp_types.SelectionRange"], None]: + async def selection_range(self, params: lsp_types.SelectionRangeParams) -> list["lsp_types.SelectionRange"] | None: """A request to provide selection ranges in a document. The request's parameter is of type {@link SelectionRangeParams}, the response is of type {@link SelectionRange SelectionRange[]} or a Thenable - that resolves to such.""" + that resolves to such. + """ return await self.send_request("textDocument/selectionRange", params) - async def prepare_call_hierarchy( - self, params: lsp_types.CallHierarchyPrepareParams - ) -> Union[List["lsp_types.CallHierarchyItem"], None]: + async def prepare_call_hierarchy(self, params: lsp_types.CallHierarchyPrepareParams) -> list["lsp_types.CallHierarchyItem"] | None: """A request to result a `CallHierarchyItem` in a document at a given position. Can be used as an input to an incoming or outgoing call hierarchy. - @since 3.16.0""" + @since 3.16.0 + """ return await self.send_request("textDocument/prepareCallHierarchy", params) async def incoming_calls( self, params: lsp_types.CallHierarchyIncomingCallsParams - ) -> Union[List["lsp_types.CallHierarchyIncomingCall"], None]: + ) -> list["lsp_types.CallHierarchyIncomingCall"] | None: """A request to resolve the incoming calls for a given `CallHierarchyItem`. - @since 3.16.0""" + @since 3.16.0 + """ return await self.send_request("callHierarchy/incomingCalls", params) async def outgoing_calls( self, params: lsp_types.CallHierarchyOutgoingCallsParams - ) -> Union[List["lsp_types.CallHierarchyOutgoingCall"], None]: + ) -> list["lsp_types.CallHierarchyOutgoingCall"] | None: """A request to resolve the outgoing calls for a given `CallHierarchyItem`. - @since 3.16.0""" + @since 3.16.0 + """ return await self.send_request("callHierarchy/outgoingCalls", params) - async def semantic_tokens_full( - self, params: lsp_types.SemanticTokensParams - ) -> Union["lsp_types.SemanticTokens", None]: + async def semantic_tokens_full(self, params: lsp_types.SemanticTokensParams) -> Union["lsp_types.SemanticTokens", None]: """@since 3.16.0""" return await self.send_request("textDocument/semanticTokens/full", params) @@ -138,157 +137,143 @@ class LspRequest: """@since 3.16.0""" return await self.send_request("textDocument/semanticTokens/full/delta", params) - async def semantic_tokens_range( - self, params: lsp_types.SemanticTokensRangeParams - ) -> Union["lsp_types.SemanticTokens", None]: + async def semantic_tokens_range(self, params: lsp_types.SemanticTokensRangeParams) -> Union["lsp_types.SemanticTokens", None]: """@since 3.16.0""" return await self.send_request("textDocument/semanticTokens/range", params) - async def linked_editing_range( - self, params: lsp_types.LinkedEditingRangeParams - ) -> Union["lsp_types.LinkedEditingRanges", None]: + async def linked_editing_range(self, params: lsp_types.LinkedEditingRangeParams) -> Union["lsp_types.LinkedEditingRanges", None]: """A request to provide ranges that can be edited together. - @since 3.16.0""" + @since 3.16.0 + """ return await self.send_request("textDocument/linkedEditingRange", params) - async def will_create_files( - self, params: lsp_types.CreateFilesParams - ) -> Union["lsp_types.WorkspaceEdit", None]: + async def will_create_files(self, params: lsp_types.CreateFilesParams) -> Union["lsp_types.WorkspaceEdit", None]: """The will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. - @since 3.16.0""" + @since 3.16.0 + """ return await self.send_request("workspace/willCreateFiles", params) - async def will_rename_files( - self, params: lsp_types.RenameFilesParams - ) -> Union["lsp_types.WorkspaceEdit", None]: + async def will_rename_files(self, params: lsp_types.RenameFilesParams) -> Union["lsp_types.WorkspaceEdit", None]: """The will rename files request is sent from the client to the server before files are actually renamed as long as the rename is triggered from within the client. - @since 3.16.0""" + @since 3.16.0 + """ return await self.send_request("workspace/willRenameFiles", params) - async def will_delete_files( - self, params: lsp_types.DeleteFilesParams - ) -> Union["lsp_types.WorkspaceEdit", None]: + async def will_delete_files(self, params: lsp_types.DeleteFilesParams) -> Union["lsp_types.WorkspaceEdit", None]: """The did delete files notification is sent from the client to the server when files were deleted from within the client. - @since 3.16.0""" + @since 3.16.0 + """ return await self.send_request("workspace/willDeleteFiles", params) - async def moniker( - self, params: lsp_types.MonikerParams - ) -> Union[List["lsp_types.Moniker"], None]: + async def moniker(self, params: lsp_types.MonikerParams) -> list["lsp_types.Moniker"] | None: """A request to get the moniker of a symbol at a given text document position. The request parameter is of type {@link TextDocumentPositionParams}. - The response is of type {@link Moniker Moniker[]} or `null`.""" + The response is of type {@link Moniker Moniker[]} or `null`. + """ return await self.send_request("textDocument/moniker", params) - async def prepare_type_hierarchy( - self, params: lsp_types.TypeHierarchyPrepareParams - ) -> Union[List["lsp_types.TypeHierarchyItem"], None]: + async def prepare_type_hierarchy(self, params: lsp_types.TypeHierarchyPrepareParams) -> list["lsp_types.TypeHierarchyItem"] | None: """A request to result a `TypeHierarchyItem` in a document at a given position. Can be used as an input to a subtypes or supertypes type hierarchy. - @since 3.17.0""" + @since 3.17.0 + """ return await self.send_request("textDocument/prepareTypeHierarchy", params) async def type_hierarchy_supertypes( self, params: lsp_types.TypeHierarchySupertypesParams - ) -> Union[List["lsp_types.TypeHierarchyItem"], None]: + ) -> list["lsp_types.TypeHierarchyItem"] | None: """A request to resolve the supertypes for a given `TypeHierarchyItem`. - @since 3.17.0""" + @since 3.17.0 + """ return await self.send_request("typeHierarchy/supertypes", params) - async def type_hierarchy_subtypes( - self, params: lsp_types.TypeHierarchySubtypesParams - ) -> Union[List["lsp_types.TypeHierarchyItem"], None]: + async def type_hierarchy_subtypes(self, params: lsp_types.TypeHierarchySubtypesParams) -> list["lsp_types.TypeHierarchyItem"] | None: """A request to resolve the subtypes for a given `TypeHierarchyItem`. - @since 3.17.0""" + @since 3.17.0 + """ return await self.send_request("typeHierarchy/subtypes", params) - async def inline_value( - self, params: lsp_types.InlineValueParams - ) -> Union[List["lsp_types.InlineValue"], None]: + async def inline_value(self, params: lsp_types.InlineValueParams) -> list["lsp_types.InlineValue"] | None: """A request to provide inline values in a document. The request's parameter is of type {@link InlineValueParams}, the response is of type {@link InlineValue InlineValue[]} or a Thenable that resolves to such. - @since 3.17.0""" + @since 3.17.0 + """ return await self.send_request("textDocument/inlineValue", params) - async def inlay_hint( - self, params: lsp_types.InlayHintParams - ) -> Union[List["lsp_types.InlayHint"], None]: + async def inlay_hint(self, params: lsp_types.InlayHintParams) -> list["lsp_types.InlayHint"] | None: """A request to provide inlay hints in a document. The request's parameter is of type {@link InlayHintsParams}, the response is of type {@link InlayHint InlayHint[]} or a Thenable that resolves to such. - @since 3.17.0""" + @since 3.17.0 + """ return await self.send_request("textDocument/inlayHint", params) - async def resolve_inlay_hint( - self, params: lsp_types.InlayHint - ) -> "lsp_types.InlayHint": + async def resolve_inlay_hint(self, params: lsp_types.InlayHint) -> "lsp_types.InlayHint": """A request to resolve additional properties for an inlay hint. The request's parameter is of type {@link InlayHint}, the response is of type {@link InlayHint} or a Thenable that resolves to such. - @since 3.17.0""" + @since 3.17.0 + """ return await self.send_request("inlayHint/resolve", params) - async def text_document_diagnostic( - self, params: lsp_types.DocumentDiagnosticParams - ) -> "lsp_types.DocumentDiagnosticReport": + async def text_document_diagnostic(self, params: lsp_types.DocumentDiagnosticParams) -> "lsp_types.DocumentDiagnosticReport": """The document diagnostic request definition. - @since 3.17.0""" + @since 3.17.0 + """ return await self.send_request("textDocument/diagnostic", params) - async def workspace_diagnostic( - self, params: lsp_types.WorkspaceDiagnosticParams - ) -> "lsp_types.WorkspaceDiagnosticReport": + async def workspace_diagnostic(self, params: lsp_types.WorkspaceDiagnosticParams) -> "lsp_types.WorkspaceDiagnosticReport": """The workspace diagnostic request definition. - @since 3.17.0""" + @since 3.17.0 + """ return await self.send_request("workspace/diagnostic", params) - async def initialize( - self, params: lsp_types.InitializeParams - ) -> "lsp_types.InitializeResult": + async def initialize(self, params: lsp_types.InitializeParams) -> "lsp_types.InitializeResult": """The initialize request is sent from the client to the server. It is sent once as the request after starting up the server. The requests parameter is of type {@link InitializeParams} the response if of type {@link InitializeResult} of a Thenable that - resolves to such.""" + resolves to such. + """ return await self.send_request("initialize", params) async def shutdown(self) -> None: """A shutdown request is sent from the client to the server. It is sent once when the client decides to shutdown the server. The only notification that is sent after a shutdown request - is the exit event.""" + is the exit event. + """ return await self.send_request("shutdown") - async def will_save_wait_until( - self, params: lsp_types.WillSaveTextDocumentParams - ) -> Union[List["lsp_types.TextEdit"], None]: + async def will_save_wait_until(self, params: lsp_types.WillSaveTextDocumentParams) -> list["lsp_types.TextEdit"] | None: """A document will save request is sent from the client to the server before the document is actually saved. The request can return an array of TextEdits which will be applied to the text document before it is saved. Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. This is done to keep the save fast and - reliable.""" + reliable. + """ return await self.send_request("textDocument/willSaveWaitUntil", params) async def completion( self, params: lsp_types.CompletionParams - ) -> Union[List["lsp_types.CompletionItem"], "lsp_types.CompletionList", None]: + ) -> Union[list["lsp_types.CompletionItem"], "lsp_types.CompletionList", None]: """Request to request completion at a given text document position. The request's parameter is of type {@link TextDocumentPosition} the response is of type {@link CompletionItem CompletionItem[]} or {@link CompletionList} @@ -301,85 +286,72 @@ class LspRequest: """ return await self.send_request("textDocument/completion", params) - async def resolve_completion_item( - self, params: lsp_types.CompletionItem - ) -> "lsp_types.CompletionItem": + async def resolve_completion_item(self, params: lsp_types.CompletionItem) -> "lsp_types.CompletionItem": """Request to resolve additional information for a given completion item.The request's parameter is of type {@link CompletionItem} the response - is of type {@link CompletionItem} or a Thenable that resolves to such.""" + is of type {@link CompletionItem} or a Thenable that resolves to such. + """ return await self.send_request("completionItem/resolve", params) - async def hover( - self, params: lsp_types.HoverParams - ) -> Union["lsp_types.Hover", None]: + async def hover(self, params: lsp_types.HoverParams) -> Union["lsp_types.Hover", None]: """Request to request hover information at a given text document position. The request's parameter is of type {@link TextDocumentPosition} the response is of - type {@link Hover} or a Thenable that resolves to such.""" + type {@link Hover} or a Thenable that resolves to such. + """ return await self.send_request("textDocument/hover", params) - async def signature_help( - self, params: lsp_types.SignatureHelpParams - ) -> Union["lsp_types.SignatureHelp", None]: + async def signature_help(self, params: lsp_types.SignatureHelpParams) -> Union["lsp_types.SignatureHelp", None]: return await self.send_request("textDocument/signatureHelp", params) - async def definition( - self, params: lsp_types.DefinitionParams - ) -> Union["lsp_types.Definition", List["lsp_types.LocationLink"], None]: + async def definition(self, params: lsp_types.DefinitionParams) -> Union["lsp_types.Definition", list["lsp_types.LocationLink"], None]: """A request to resolve the definition location of a symbol at a given text document position. The request's parameter is of type [TextDocumentPosition] (#TextDocumentPosition) the response is of either type {@link Definition} or a typed array of {@link DefinitionLink} or a Thenable that resolves - to such.""" + to such. + """ return await self.send_request("textDocument/definition", params) - async def references( - self, params: lsp_types.ReferenceParams - ) -> Union[List["lsp_types.Location"], None]: + async def references(self, params: lsp_types.ReferenceParams) -> list["lsp_types.Location"] | None: """A request to resolve project-wide references for the symbol denoted by the given text document position. The request's parameter is of type {@link ReferenceParams} the response is of type - {@link Location Location[]} or a Thenable that resolves to such.""" + {@link Location Location[]} or a Thenable that resolves to such. + """ return await self.send_request("textDocument/references", params) - async def document_highlight( - self, params: lsp_types.DocumentHighlightParams - ) -> Union[List["lsp_types.DocumentHighlight"], None]: + async def document_highlight(self, params: lsp_types.DocumentHighlightParams) -> list["lsp_types.DocumentHighlight"] | None: """Request to resolve a {@link DocumentHighlight} for a given text document position. The request's parameter is of type [TextDocumentPosition] (#TextDocumentPosition) the request response is of type [DocumentHighlight[]] - (#DocumentHighlight) or a Thenable that resolves to such.""" + (#DocumentHighlight) or a Thenable that resolves to such. + """ return await self.send_request("textDocument/documentHighlight", params) async def document_symbol( self, params: lsp_types.DocumentSymbolParams - ) -> Union[ - List["lsp_types.SymbolInformation"], List["lsp_types.DocumentSymbol"], None - ]: + ) -> list["lsp_types.SymbolInformation"] | list["lsp_types.DocumentSymbol"] | None: """A request to list all symbols found in a given text document. The request's parameter is of type {@link TextDocumentIdentifier} the response is of type {@link SymbolInformation SymbolInformation[]} or a Thenable - that resolves to such.""" + that resolves to such. + """ return await self.send_request("textDocument/documentSymbol", params) - async def code_action( - self, params: lsp_types.CodeActionParams - ) -> Union[List[Union["lsp_types.Command", "lsp_types.CodeAction"]], None]: + async def code_action(self, params: lsp_types.CodeActionParams) -> list[Union["lsp_types.Command", "lsp_types.CodeAction"]] | None: """A request to provide commands for the given text document and range.""" return await self.send_request("textDocument/codeAction", params) - async def resolve_code_action( - self, params: lsp_types.CodeAction - ) -> "lsp_types.CodeAction": + async def resolve_code_action(self, params: lsp_types.CodeAction) -> "lsp_types.CodeAction": """Request to resolve additional information for a given code action.The request's parameter is of type {@link CodeAction} the response - is of type {@link CodeAction} or a Thenable that resolves to such.""" + is of type {@link CodeAction} or a Thenable that resolves to such. + """ return await self.send_request("codeAction/resolve", params) async def workspace_symbol( self, params: lsp_types.WorkspaceSymbolParams - ) -> Union[ - List["lsp_types.SymbolInformation"], List["lsp_types.WorkspaceSymbol"], None - ]: + ) -> list["lsp_types.SymbolInformation"] | list["lsp_types.WorkspaceSymbol"] | None: """A request to list project-wide symbols matching the query string given by the {@link WorkspaceSymbolParams}. The response is of type {@link SymbolInformation SymbolInformation[]} or a Thenable that @@ -391,78 +363,60 @@ class LspRequest: """ return await self.send_request("workspace/symbol", params) - async def resolve_workspace_symbol( - self, params: lsp_types.WorkspaceSymbol - ) -> "lsp_types.WorkspaceSymbol": + async def resolve_workspace_symbol(self, params: lsp_types.WorkspaceSymbol) -> "lsp_types.WorkspaceSymbol": """A request to resolve the range inside the workspace symbol's location. - @since 3.17.0""" + @since 3.17.0 + """ return await self.send_request("workspaceSymbol/resolve", params) - async def code_lens( - self, params: lsp_types.CodeLensParams - ) -> Union[List["lsp_types.CodeLens"], None]: + async def code_lens(self, params: lsp_types.CodeLensParams) -> list["lsp_types.CodeLens"] | None: """A request to provide code lens for the given text document.""" return await self.send_request("textDocument/codeLens", params) - async def resolve_code_lens( - self, params: lsp_types.CodeLens - ) -> "lsp_types.CodeLens": + async def resolve_code_lens(self, params: lsp_types.CodeLens) -> "lsp_types.CodeLens": """A request to resolve a command for a given code lens.""" return await self.send_request("codeLens/resolve", params) - async def document_link( - self, params: lsp_types.DocumentLinkParams - ) -> Union[List["lsp_types.DocumentLink"], None]: + async def document_link(self, params: lsp_types.DocumentLinkParams) -> list["lsp_types.DocumentLink"] | None: """A request to provide document links""" return await self.send_request("textDocument/documentLink", params) - async def resolve_document_link( - self, params: lsp_types.DocumentLink - ) -> "lsp_types.DocumentLink": + async def resolve_document_link(self, params: lsp_types.DocumentLink) -> "lsp_types.DocumentLink": """Request to resolve additional information for a given document link. The request's parameter is of type {@link DocumentLink} the response - is of type {@link DocumentLink} or a Thenable that resolves to such.""" + is of type {@link DocumentLink} or a Thenable that resolves to such. + """ return await self.send_request("documentLink/resolve", params) - async def formatting( - self, params: lsp_types.DocumentFormattingParams - ) -> Union[List["lsp_types.TextEdit"], None]: + async def formatting(self, params: lsp_types.DocumentFormattingParams) -> list["lsp_types.TextEdit"] | None: """A request to to format a whole document.""" return await self.send_request("textDocument/formatting", params) - async def range_formatting( - self, params: lsp_types.DocumentRangeFormattingParams - ) -> Union[List["lsp_types.TextEdit"], None]: + async def range_formatting(self, params: lsp_types.DocumentRangeFormattingParams) -> list["lsp_types.TextEdit"] | None: """A request to to format a range in a document.""" return await self.send_request("textDocument/rangeFormatting", params) - async def on_type_formatting( - self, params: lsp_types.DocumentOnTypeFormattingParams - ) -> Union[List["lsp_types.TextEdit"], None]: + async def on_type_formatting(self, params: lsp_types.DocumentOnTypeFormattingParams) -> list["lsp_types.TextEdit"] | None: """A request to format a document on type.""" return await self.send_request("textDocument/onTypeFormatting", params) - async def rename( - self, params: lsp_types.RenameParams - ) -> Union["lsp_types.WorkspaceEdit", None]: + async def rename(self, params: lsp_types.RenameParams) -> Union["lsp_types.WorkspaceEdit", None]: """A request to rename a symbol.""" return await self.send_request("textDocument/rename", params) - async def prepare_rename( - self, params: lsp_types.PrepareRenameParams - ) -> Union["lsp_types.PrepareRenameResult", None]: + async def prepare_rename(self, params: lsp_types.PrepareRenameParams) -> Union["lsp_types.PrepareRenameResult", None]: """A request to test and perform the setup necessary for a rename. - @since 3.16 - support for default behavior""" + @since 3.16 - support for default behavior + """ return await self.send_request("textDocument/prepareRename", params) - async def execute_command( - self, params: lsp_types.ExecuteCommandParams - ) -> Union["lsp_types.LSPAny", None]: + async def execute_command(self, params: lsp_types.ExecuteCommandParams) -> Union["lsp_types.LSPAny", None]: """A request send from the client to the server to execute a command. The request might return - a workspace edit which the client will apply to the workspace.""" + a workspace edit which the client will apply to the workspace. + """ return await self.send_request("workspace/executeCommand", params) @@ -470,92 +424,87 @@ class LspNotification: def __init__(self, send_notification): self.send_notification = send_notification - def did_change_workspace_folders( - self, params: lsp_types.DidChangeWorkspaceFoldersParams - ) -> None: + def did_change_workspace_folders(self, params: lsp_types.DidChangeWorkspaceFoldersParams) -> None: """The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace - folder configuration changes.""" + folder configuration changes. + """ return self.send_notification("workspace/didChangeWorkspaceFolders", params) - def cancel_work_done_progress( - self, params: lsp_types.WorkDoneProgressCancelParams - ) -> None: + def cancel_work_done_progress(self, params: lsp_types.WorkDoneProgressCancelParams) -> None: """The `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a progress - initiated on the server side.""" + initiated on the server side. + """ return self.send_notification("window/workDoneProgress/cancel", params) def did_create_files(self, params: lsp_types.CreateFilesParams) -> None: """The did create files notification is sent from the client to the server when files were created from within the client. - @since 3.16.0""" + @since 3.16.0 + """ return self.send_notification("workspace/didCreateFiles", params) def did_rename_files(self, params: lsp_types.RenameFilesParams) -> None: """The did rename files notification is sent from the client to the server when files were renamed from within the client. - @since 3.16.0""" + @since 3.16.0 + """ return self.send_notification("workspace/didRenameFiles", params) def did_delete_files(self, params: lsp_types.DeleteFilesParams) -> None: """The will delete files request is sent from the client to the server before files are actually deleted as long as the deletion is triggered from within the client. - @since 3.16.0""" + @since 3.16.0 + """ return self.send_notification("workspace/didDeleteFiles", params) - def did_open_notebook_document( - self, params: lsp_types.DidOpenNotebookDocumentParams - ) -> None: + def did_open_notebook_document(self, params: lsp_types.DidOpenNotebookDocumentParams) -> None: """A notification sent when a notebook opens. - @since 3.17.0""" + @since 3.17.0 + """ return self.send_notification("notebookDocument/didOpen", params) - def did_change_notebook_document( - self, params: lsp_types.DidChangeNotebookDocumentParams - ) -> None: + def did_change_notebook_document(self, params: lsp_types.DidChangeNotebookDocumentParams) -> None: return self.send_notification("notebookDocument/didChange", params) - def did_save_notebook_document( - self, params: lsp_types.DidSaveNotebookDocumentParams - ) -> None: + def did_save_notebook_document(self, params: lsp_types.DidSaveNotebookDocumentParams) -> None: """A notification sent when a notebook document is saved. - @since 3.17.0""" + @since 3.17.0 + """ return self.send_notification("notebookDocument/didSave", params) - def did_close_notebook_document( - self, params: lsp_types.DidCloseNotebookDocumentParams - ) -> None: + def did_close_notebook_document(self, params: lsp_types.DidCloseNotebookDocumentParams) -> None: """A notification sent when a notebook closes. - @since 3.17.0""" + @since 3.17.0 + """ return self.send_notification("notebookDocument/didClose", params) def initialized(self, params: lsp_types.InitializedParams) -> None: """The initialized notification is sent from the client to the server after the client is fully initialized and the server - is allowed to send requests from the server to the client.""" + is allowed to send requests from the server to the client. + """ return self.send_notification("initialized", params) def exit(self) -> None: """The exit event is sent from the client to the server to - ask the server to exit its process.""" + ask the server to exit its process. + """ return self.send_notification("exit") - def workspace_did_change_configuration( - self, params: lsp_types.DidChangeConfigurationParams - ) -> None: + def workspace_did_change_configuration(self, params: lsp_types.DidChangeConfigurationParams) -> None: """The configuration change notification is sent from the client to the server when the client's configuration has changed. The notification contains - the changed configuration as defined by the language client.""" + the changed configuration as defined by the language client. + """ return self.send_notification("workspace/didChangeConfiguration", params) - def did_open_text_document( - self, params: lsp_types.DidOpenTextDocumentParams - ) -> None: + def did_open_text_document(self, params: lsp_types.DidOpenTextDocumentParams) -> None: """The document open notification is sent from the client to the server to signal newly opened text documents. The document's truth is now managed by the client and the server must not try to read the document's truth using the document's @@ -563,47 +512,43 @@ class LspNotification: mean that its content is presented in an editor. An open notification must not be sent more than once without a corresponding close notification send before. This means open and close notification must be balanced and the max open count - is one.""" + is one. + """ return self.send_notification("textDocument/didOpen", params) - def did_change_text_document( - self, params: lsp_types.DidChangeTextDocumentParams - ) -> None: + def did_change_text_document(self, params: lsp_types.DidChangeTextDocumentParams) -> None: """The document change notification is sent from the client to the server to signal - changes to a text document.""" + changes to a text document. + """ return self.send_notification("textDocument/didChange", params) - def did_close_text_document( - self, params: lsp_types.DidCloseTextDocumentParams - ) -> None: + def did_close_text_document(self, params: lsp_types.DidCloseTextDocumentParams) -> None: """The document close notification is sent from the client to the server when the document got closed in the client. The document's truth now exists where the document's uri points to (e.g. if the document's uri is a file uri the truth now exists on disk). As with the open notification the close notification is about managing the document's content. Receiving a close notification doesn't mean that the document was open in an editor before. A close - notification requires a previous open notification to be sent.""" + notification requires a previous open notification to be sent. + """ return self.send_notification("textDocument/didClose", params) - def did_save_text_document( - self, params: lsp_types.DidSaveTextDocumentParams - ) -> None: + def did_save_text_document(self, params: lsp_types.DidSaveTextDocumentParams) -> None: """The document save notification is sent from the client to the server when - the document got saved in the client.""" + the document got saved in the client. + """ return self.send_notification("textDocument/didSave", params) - def will_save_text_document( - self, params: lsp_types.WillSaveTextDocumentParams - ) -> None: + def will_save_text_document(self, params: lsp_types.WillSaveTextDocumentParams) -> None: """A document will save notification is sent from the client to the server before - the document is actually saved.""" + the document is actually saved. + """ return self.send_notification("textDocument/willSave", params) - def did_change_watched_files( - self, params: lsp_types.DidChangeWatchedFilesParams - ) -> None: + def did_change_watched_files(self, params: lsp_types.DidChangeWatchedFilesParams) -> None: """The watched files notification is sent from the client to the server when - the client detects changes to file watched by the language client.""" + the client detects changes to file watched by the language client. + """ return self.send_notification("workspace/didChangeWatchedFiles", params) def set_trace(self, params: lsp_types.SetTraceParams) -> None: diff --git a/src/solidlsp/lsp_protocol_handler/lsp_types.py b/src/solidlsp/lsp_protocol_handler/lsp_types.py index 6d6a754..5488c35 100644 --- a/src/solidlsp/lsp_protocol_handler/lsp_types.py +++ b/src/solidlsp/lsp_protocol_handler/lsp_types.py @@ -30,8 +30,9 @@ SOFTWARE. """ from enum import Enum, IntEnum, IntFlag -from typing import Dict, List, Literal, Union -from typing_extensions import NotRequired, TypedDict +from typing import Literal, NotRequired, Union + +from typing_extensions import TypedDict URI = str DocumentUri = str @@ -44,7 +45,8 @@ class SemanticTokenTypes(Enum): an clients can specify additional token types via the corresponding client capabilities. - @since 3.16.0""" + @since 3.16.0 + """ Namespace = "namespace" Type = "type" @@ -79,7 +81,8 @@ class SemanticTokenModifiers(Enum): an clients can specify additional token types via the corresponding client capabilities. - @since 3.16.0""" + @since 3.16.0 + """ Declaration = "declaration" Definition = "definition" @@ -96,7 +99,8 @@ class SemanticTokenModifiers(Enum): class DocumentDiagnosticReportKind(Enum): """The document diagnostic report kinds. - @since 3.17.0""" + @since 3.17.0 + """ Full = "full" """ A diagnostic report with a full @@ -191,8 +195,8 @@ class SymbolKind(IntEnum): Event = 24 Operator = 25 TypeParameter = 26 - - @classmethod + + @classmethod def from_int(cls, value: int) -> "SymbolKind": for symbol_kind in cls: if symbol_kind.value == value: @@ -203,7 +207,8 @@ class SymbolKind(IntEnum): class SymbolTag(IntEnum): """Symbol tags are extra annotations that tweak the rendering of a symbol. - @since 3.16""" + @since 3.16 + """ Deprecated = 1 """ Render a symbol as obsolete, usually using a strike-out. """ @@ -212,7 +217,8 @@ class SymbolTag(IntEnum): class UniquenessLevel(Enum): """Moniker uniqueness level to define scope of the moniker. - @since 3.16.0""" + @since 3.16.0 + """ Document = "document" """ The moniker is only unique inside a document """ @@ -229,7 +235,8 @@ class UniquenessLevel(Enum): class MonikerKind(Enum): """The moniker kind. - @since 3.16.0""" + @since 3.16.0 + """ Import = "import" """ The moniker represent a symbol that is imported into a project """ @@ -243,7 +250,8 @@ class MonikerKind(Enum): class InlayHintKind(IntEnum): """Inlay hint kinds. - @since 3.17.0""" + @since 3.17.0 + """ Type = 1 """ An inlay hint that for a type annotation. """ @@ -266,7 +274,8 @@ class MessageType(IntEnum): class TextDocumentSyncKind(IntEnum): """Defines how the host (editor) should sync - document changes to the language server.""" + document changes to the language server. + """ None_ = 0 """ Documents should not be synced at all. """ @@ -325,7 +334,8 @@ class CompletionItemTag(IntEnum): """Completion item tags are extra annotations that tweak the rendering of a completion item. - @since 3.15.0""" + @since 3.15.0 + """ Deprecated = 1 """ Render a completion as obsolete, usually using a strike-out. """ @@ -333,7 +343,8 @@ class CompletionItemTag(IntEnum): class InsertTextFormat(IntEnum): """Defines whether the insert text in a completion item should be interpreted as - plain text or a snippet.""" + plain text or a snippet. + """ PlainText = 1 """ The primary text to be inserted is treated as a plain string. """ @@ -352,7 +363,8 @@ class InsertTextMode(IntEnum): """How whitespace and indentation is handled during completion item insertion. - @since 3.16.0""" + @since 3.16.0 + """ AsIs = 1 """ The insertion or replace strings is taken as it is. If the @@ -449,7 +461,8 @@ class MarkupKind(Enum): result literals like `Hover`, `ParameterInfo` or `CompletionItem`. Please note that `MarkupKinds` must not start with a `$`. This kinds - are reserved for internal usage.""" + are reserved for internal usage. + """ PlainText = "plaintext" """ Plain text is supported as a content format """ @@ -460,7 +473,8 @@ class MarkupKind(Enum): class PositionEncodingKind(Enum): """A set of predefined position encoding kinds. - @since 3.17.0""" + @since 3.17.0 + """ UTF8 = "utf-8" """ Character offsets count UTF-8 code units. """ @@ -513,7 +527,8 @@ class DiagnosticSeverity(IntEnum): class DiagnosticTag(IntEnum): """The diagnostic tags. - @since 3.15.0""" + @since 3.15.0 + """ Unnecessary = 1 """ Unused or unnecessary code. @@ -542,7 +557,8 @@ class CompletionTriggerKind(IntEnum): class SignatureHelpTriggerKind(IntEnum): """How a signature help was triggered. - @since 3.15.0""" + @since 3.15.0 + """ Invoked = 1 """ Signature help was invoked manually by the user or by a command. """ @@ -555,7 +571,8 @@ class SignatureHelpTriggerKind(IntEnum): class CodeActionTriggerKind(IntEnum): """The reason why code actions were requested. - @since 3.17.0""" + @since 3.17.0 + """ Invoked = 1 """ Code actions were explicitly requested by the user or by an extension. """ @@ -570,7 +587,8 @@ class FileOperationPatternKind(Enum): """A pattern kind describing if a glob pattern matches a file a folder or both. - @since 3.16.0""" + @since 3.16.0 + """ File = "file" """ The pattern matches a file only. """ @@ -581,7 +599,8 @@ class FileOperationPatternKind(Enum): class NotebookCellKind(IntEnum): """A notebook cell kind. - @since 3.17.0""" + @since 3.17.0 + """ Markup = 1 """ A markup-cell is formatted source that is used for display. """ @@ -624,7 +643,7 @@ class TokenFormat(Enum): Relative = "relative" -Definition = Union["Location", List["Location"]] +Definition = Union["Location", list["Location"]] """ The definition of a symbol represented as one or many {@link Location locations}. For most programming languages there is only one location at which a symbol is defined. @@ -638,7 +657,7 @@ DefinitionLink = "LocationLink" Provides additional metadata over normal {@link Location location} definitions, including the range of the defining symbol """ -LSPArray = List["LSPAny"] +LSPArray = list["LSPAny"] """ LSP arrays. @since 3.17.0 """ @@ -650,7 +669,7 @@ convenience it is allowed and assumed that all these properties are optional as well. @since 3.17.0 """ -Declaration = Union["Location", List["Location"]] +Declaration = Union["Location", list["Location"]] """ The declaration of a symbol representation as one or many {@link Location locations}. """ DeclarationLink = "LocationLink" @@ -662,9 +681,7 @@ the declaring symbol. Servers should prefer returning `DeclarationLink` over `Declaration` if supported by the client. """ -InlineValue = Union[ - "InlineValueText", "InlineValueVariableLookup", "InlineValueEvaluatableExpression" -] +InlineValue = Union["InlineValueText", "InlineValueVariableLookup", "InlineValueEvaluatableExpression"] """ Inline value information can be provided by different means: - directly as a text value (class InlineValueText). - as a name to use for a variable lookup (class InlineValueVariableLookup) @@ -673,9 +690,7 @@ The InlineValue types combines all inline value types into one type. @since 3.17.0 """ -DocumentDiagnosticReport = Union[ - "RelatedFullDocumentDiagnosticReport", "RelatedUnchangedDocumentDiagnosticReport" -] +DocumentDiagnosticReport = Union["RelatedFullDocumentDiagnosticReport", "RelatedUnchangedDocumentDiagnosticReport"] """ The result of a document diagnostic pull request. A report can either be a full report containing all diagnostics for the requested document or an unchanged report indicating that nothing @@ -684,14 +699,12 @@ pull request. @since 3.17.0 """ -PrepareRenameResult = Union[ - "Range", "__PrepareRenameResult_Type_1", "__PrepareRenameResult_Type_2" -] +PrepareRenameResult = Union["Range", "__PrepareRenameResult_Type_1", "__PrepareRenameResult_Type_2"] -DocumentSelector = List["DocumentFilter"] +DocumentSelector = list["DocumentFilter"] """ A document selector is the combination of one or many document filters. -@sample `let sel:DocumentSelector = [{ language: 'typescript' }, { language: 'json', pattern: '**∕tsconfig.json' }]`; +@sample `let sel:DocumentSelector = [{ language: 'typescript' }, { language: 'json', pattern: '**/tsconfig.json' }]`; The use of a string as a document filter is deprecated @since 3.16.0. """ @@ -708,9 +721,7 @@ WorkspaceDocumentDiagnosticReport = Union[ @since 3.17.0 """ -TextDocumentContentChangeEvent = Union[ - "__TextDocumentContentChangeEvent_Type_1", "__TextDocumentContentChangeEvent_Type_2" -] +TextDocumentContentChangeEvent = Union["__TextDocumentContentChangeEvent_Type_1", "__TextDocumentContentChangeEvent_Type_2"] """ An event describing a change to a text document. If only a text is provided it is considered to be the full content of the document. """ @@ -734,7 +745,7 @@ a notebook cell document. @since 3.17.0 - proposed support for NotebookCellTextDocumentFilter. """ -LSPObject = Dict[str, "LSPAny"] +LSPObject = dict[str, "LSPAny"] """ LSP object definition. @since 3.17.0 """ @@ -756,7 +767,7 @@ Glob patterns can have the following syntax: - `*` to match one or more characters in a path segment - `?` to match on one character in a path segment - `**` to match any number of path segments, including none -- `{}` to group sub patterns into an OR expression. (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files) +- `{}` to group sub patterns into an OR expression. (e.g. `**\u200b/*.{ts,js}` matches all TypeScript and JavaScript files) - `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …) - `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`) @@ -781,7 +792,7 @@ Pattern = str - `*` to match one or more characters in a path segment - `?` to match on one character in a path segment - `**` to match any number of path segments, including none -- `{}` to group conditions (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files) +- `{}` to group conditions (e.g. `**\u200b/*.{ts,js}` matches all TypeScript and JavaScript files) - `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …) - `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`) @@ -802,7 +813,8 @@ class ImplementationParams(TypedDict): class Location(TypedDict): """Represents a location inside a resource, such as a line - inside a text file.""" + inside a text file. + """ uri: "DocumentUri" range: "Range" @@ -858,7 +870,7 @@ class DidChangeWorkspaceFoldersParams(TypedDict): class ConfigurationParams(TypedDict): """The parameters of a configuration request.""" - items: List["ConfigurationItem"] + items: list["ConfigurationItem"] class DocumentColorParams(TypedDict): @@ -916,7 +928,7 @@ class ColorPresentation(TypedDict): """ An {@link TextEdit edit} which is applied to a document when selecting this presentation for the color. When `falsy` the {@link ColorPresentation.label label} is used. """ - additionalTextEdits: NotRequired[List["TextEdit"]] + additionalTextEdits: NotRequired[list["TextEdit"]] """ An optional array of additional {@link TextEdit text edits} that are applied when selecting this color presentation. Edits must not overlap with the main {@link ColorPresentation.textEdit edit} nor with themselves. """ @@ -1007,7 +1019,7 @@ class SelectionRangeParams(TypedDict): textDocument: "TextDocumentIdentifier" """ The text document. """ - positions: List["Position"] + positions: list["Position"] """ The positions inside the text document. """ workDoneToken: NotRequired["ProgressToken"] """ An optional token that a server can use to report work done progress. """ @@ -1018,7 +1030,8 @@ class SelectionRangeParams(TypedDict): class SelectionRange(TypedDict): """A selection range represents a part of a selection hierarchy. A selection range - may have a parent selection range that contains it.""" + may have a parent selection range that contains it. + """ range: "Range" """ The {@link Range range} of this selection range. """ @@ -1048,7 +1061,8 @@ class WorkDoneProgressCancelParams(TypedDict): class CallHierarchyPrepareParams(TypedDict): """The parameter of a `textDocument/prepareCallHierarchy` request. - @since 3.16.0""" + @since 3.16.0 + """ textDocument: "TextDocumentIdentifier" """ The text document. """ @@ -1062,13 +1076,14 @@ class CallHierarchyItem(TypedDict): """Represents programming constructs like functions or constructors in the context of call hierarchy. - @since 3.16.0""" + @since 3.16.0 + """ name: str """ The name of this item. """ kind: "SymbolKind" """ The kind of this item. """ - tags: NotRequired[List["SymbolTag"]] + tags: NotRequired[list["SymbolTag"]] """ Tags for this item. """ detail: NotRequired[str] """ More detail for this item, e.g. the signature of a function. """ @@ -1087,7 +1102,8 @@ class CallHierarchyItem(TypedDict): class CallHierarchyRegistrationOptions(TypedDict): """Call hierarchy options used during static or dynamic registration. - @since 3.16.0""" + @since 3.16.0 + """ documentSelector: Union["DocumentSelector", None] """ A document selector to identify the scope of the registration. If set to null @@ -1100,7 +1116,8 @@ class CallHierarchyRegistrationOptions(TypedDict): class CallHierarchyIncomingCallsParams(TypedDict): """The parameter of a `callHierarchy/incomingCalls` request. - @since 3.16.0""" + @since 3.16.0 + """ item: "CallHierarchyItem" workDoneToken: NotRequired["ProgressToken"] @@ -1117,7 +1134,7 @@ CallHierarchyIncomingCall = TypedDict( "from": "CallHierarchyItem", # The ranges at which the calls appear. This is relative to the caller # denoted by {@link CallHierarchyIncomingCall.from `this.from`}. - "fromRanges": List["Range"], + "fromRanges": list["Range"], }, ) """ Represents an incoming call, e.g. a caller of a method or constructor. @@ -1128,7 +1145,8 @@ CallHierarchyIncomingCall = TypedDict( class CallHierarchyOutgoingCallsParams(TypedDict): """The parameter of a `callHierarchy/outgoingCalls` request. - @since 3.16.0""" + @since 3.16.0 + """ item: "CallHierarchyItem" workDoneToken: NotRequired["ProgressToken"] @@ -1141,11 +1159,12 @@ class CallHierarchyOutgoingCallsParams(TypedDict): class CallHierarchyOutgoingCall(TypedDict): """Represents an outgoing call, e.g. calling a getter from a method or a method from a constructor etc. - @since 3.16.0""" + @since 3.16.0 + """ to: "CallHierarchyItem" """ The item that is called. """ - fromRanges: List["Range"] + fromRanges: list["Range"] """ The range at which this item is called. This is the range relative to the caller, e.g the item passed to {@link CallHierarchyItemProvider.provideCallHierarchyOutgoingCalls `provideCallHierarchyOutgoingCalls`} and not {@link CallHierarchyOutgoingCall.to `this.to`}. """ @@ -1171,14 +1190,14 @@ class SemanticTokens(TypedDict): the client will include the result id in the next semantic token request. A server can then instead of computing all semantic tokens again simply send a delta. """ - data: List[Uint] + data: list[Uint] """ The actual tokens. """ class SemanticTokensPartialResult(TypedDict): """@since 3.16.0""" - data: List[Uint] + data: list[Uint] class SemanticTokensRegistrationOptions(TypedDict): @@ -1189,7 +1208,7 @@ class SemanticTokensRegistrationOptions(TypedDict): the document selector provided on the client side will be used. """ legend: "SemanticTokensLegend" """ The legend used by the server """ - range: NotRequired[Union[bool, dict]] + range: NotRequired[bool | dict] """ Server supports providing semantic tokens for a specific range of a document. """ full: NotRequired[Union[bool, "__SemanticTokensOptions_full_Type_1"]] @@ -1218,14 +1237,14 @@ class SemanticTokensDelta(TypedDict): """@since 3.16.0""" resultId: NotRequired[str] - edits: List["SemanticTokensEdit"] + edits: list["SemanticTokensEdit"] """ The semantic token edits to transform a previous result into a new result. """ class SemanticTokensDeltaPartialResult(TypedDict): """@since 3.16.0""" - edits: List["SemanticTokensEdit"] + edits: list["SemanticTokensEdit"] class SemanticTokensRangeParams(TypedDict): @@ -1245,7 +1264,8 @@ class SemanticTokensRangeParams(TypedDict): class ShowDocumentParams(TypedDict): """Params to show a document. - @since 3.16.0""" + @since 3.16.0 + """ uri: "URI" """ The document uri to show. """ @@ -1268,7 +1288,8 @@ class ShowDocumentParams(TypedDict): class ShowDocumentResult(TypedDict): """The result of a showDocument request. - @since 3.16.0""" + @since 3.16.0 + """ success: bool """ A boolean indicating if the show was successful. """ @@ -1286,9 +1307,10 @@ class LinkedEditingRangeParams(TypedDict): class LinkedEditingRanges(TypedDict): """The result of a linked editing range request. - @since 3.16.0""" + @since 3.16.0 + """ - ranges: List["Range"] + ranges: list["Range"] """ A list of ranges that can be edited together. The ranges must have identical length and contain identical text content. The ranges cannot overlap. """ wordPattern: NotRequired[str] @@ -1310,9 +1332,10 @@ class CreateFilesParams(TypedDict): """The parameters sent in notifications/requests for user-initiated creation of files. - @since 3.16.0""" + @since 3.16.0 + """ - files: List["FileCreate"] + files: list["FileCreate"] """ An array of all files/folders created in this operation. """ @@ -1328,13 +1351,12 @@ class WorkspaceEdit(TypedDict): An invalid sequence (e.g. (1) delete file a.txt and (2) insert text into file a.txt) will cause failure of the operation. How the client recovers from the failure is described by - the client capability: `workspace.workspaceEdit.failureHandling`""" + the client capability: `workspace.workspaceEdit.failureHandling` + """ - changes: NotRequired[Dict["DocumentUri", List["TextEdit"]]] + changes: NotRequired[dict["DocumentUri", list["TextEdit"]]] """ Holds changes to existing resources. """ - documentChanges: NotRequired[ - List[Union["TextDocumentEdit", "CreateFile", "RenameFile", "DeleteFile"]] - ] + documentChanges: NotRequired[list[Union["TextDocumentEdit", "CreateFile", "RenameFile", "DeleteFile"]]] """ Depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes are either an array of `TextDocumentEdit`s to express changes to n different text documents where each text document edit addresses a specific version of a text document. Or it can contain @@ -1345,9 +1367,7 @@ class WorkspaceEdit(TypedDict): If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then only plain `TextEdit`s using the `changes` property are supported. """ - changeAnnotations: NotRequired[ - Dict["ChangeAnnotationIdentifier", "ChangeAnnotation"] - ] + changeAnnotations: NotRequired[dict["ChangeAnnotationIdentifier", "ChangeAnnotation"]] """ A map of change annotations that can be referenced in `AnnotatedTextEdit`s or create, rename and delete file / folder operations. @@ -1359,9 +1379,10 @@ class WorkspaceEdit(TypedDict): class FileOperationRegistrationOptions(TypedDict): """The options to register for file operations. - @since 3.16.0""" + @since 3.16.0 + """ - filters: List["FileOperationFilter"] + filters: list["FileOperationFilter"] """ The actual filters. """ @@ -1369,9 +1390,10 @@ class RenameFilesParams(TypedDict): """The parameters sent in notifications/requests for user-initiated renames of files. - @since 3.16.0""" + @since 3.16.0 + """ - files: List["FileRename"] + files: list["FileRename"] """ An array of all files/folders renamed in this operation. When a folder is renamed, only the folder will be included, and not its children. """ @@ -1380,9 +1402,10 @@ class DeleteFilesParams(TypedDict): """The parameters sent in notifications/requests for user-initiated deletes of files. - @since 3.16.0""" + @since 3.16.0 + """ - files: List["FileDelete"] + files: list["FileDelete"] """ An array of all files/folders deleted in this operation. """ @@ -1401,7 +1424,8 @@ class MonikerParams(TypedDict): class Moniker(TypedDict): """Moniker definition to match LSIF 0.5 moniker definition. - @since 3.16.0""" + @since 3.16.0 + """ scheme: str """ The scheme of the moniker. For example tsc or .Net """ @@ -1423,7 +1447,8 @@ class MonikerRegistrationOptions(TypedDict): class TypeHierarchyPrepareParams(TypedDict): """The parameter of a `textDocument/prepareTypeHierarchy` request. - @since 3.17.0""" + @since 3.17.0 + """ textDocument: "TextDocumentIdentifier" """ The text document. """ @@ -1440,7 +1465,7 @@ class TypeHierarchyItem(TypedDict): """ The name of this item. """ kind: "SymbolKind" """ The kind of this item. """ - tags: NotRequired[List["SymbolTag"]] + tags: NotRequired[list["SymbolTag"]] """ Tags for this item. """ detail: NotRequired[str] """ More detail for this item, e.g. the signature of a function. """ @@ -1463,7 +1488,8 @@ class TypeHierarchyItem(TypedDict): class TypeHierarchyRegistrationOptions(TypedDict): """Type hierarchy options used during static or dynamic registration. - @since 3.17.0""" + @since 3.17.0 + """ documentSelector: Union["DocumentSelector", None] """ A document selector to identify the scope of the registration. If set to null @@ -1476,7 +1502,8 @@ class TypeHierarchyRegistrationOptions(TypedDict): class TypeHierarchySupertypesParams(TypedDict): """The parameter of a `typeHierarchy/supertypes` request. - @since 3.17.0""" + @since 3.17.0 + """ item: "TypeHierarchyItem" workDoneToken: NotRequired["ProgressToken"] @@ -1489,7 +1516,8 @@ class TypeHierarchySupertypesParams(TypedDict): class TypeHierarchySubtypesParams(TypedDict): """The parameter of a `typeHierarchy/subtypes` request. - @since 3.17.0""" + @since 3.17.0 + """ item: "TypeHierarchyItem" workDoneToken: NotRequired["ProgressToken"] @@ -1502,7 +1530,8 @@ class TypeHierarchySubtypesParams(TypedDict): class InlineValueParams(TypedDict): """A parameter literal used in inline value requests. - @since 3.17.0""" + @since 3.17.0 + """ textDocument: "TextDocumentIdentifier" """ The text document. """ @@ -1518,7 +1547,8 @@ class InlineValueParams(TypedDict): class InlineValueRegistrationOptions(TypedDict): """Inline value options used during static or dynamic registration. - @since 3.17.0""" + @since 3.17.0 + """ documentSelector: Union["DocumentSelector", None] """ A document selector to identify the scope of the registration. If set to null @@ -1531,7 +1561,8 @@ class InlineValueRegistrationOptions(TypedDict): class InlayHintParams(TypedDict): """A parameter literal used in inlay hint requests. - @since 3.17.0""" + @since 3.17.0 + """ textDocument: "TextDocumentIdentifier" """ The text document. """ @@ -1544,11 +1575,12 @@ class InlayHintParams(TypedDict): class InlayHint(TypedDict): """Inlay hint information. - @since 3.17.0""" + @since 3.17.0 + """ position: "Position" """ The position of this hint. """ - label: Union[str, List["InlayHintLabelPart"]] + label: str | list["InlayHintLabelPart"] """ The label of this hint. A human readable string or an array of InlayHintLabelPart label parts. @@ -1556,7 +1588,7 @@ class InlayHint(TypedDict): kind: NotRequired["InlayHintKind"] """ The kind of this hint. Can be omitted in which case the client should fall back to a reasonable default. """ - textEdits: NotRequired[List["TextEdit"]] + textEdits: NotRequired[list["TextEdit"]] """ Optional text edits that are performed when accepting this inlay hint. *Note* that edits are expected to change the document so that the inlay @@ -1584,7 +1616,8 @@ class InlayHint(TypedDict): class InlayHintRegistrationOptions(TypedDict): """Inlay hint options used during static or dynamic registration. - @since 3.17.0""" + @since 3.17.0 + """ resolveProvider: NotRequired[bool] """ The server provides support to resolve additional @@ -1600,7 +1633,8 @@ class InlayHintRegistrationOptions(TypedDict): class DocumentDiagnosticParams(TypedDict): """Parameters of the document diagnostic request. - @since 3.17.0""" + @since 3.17.0 + """ textDocument: "TextDocumentIdentifier" """ The text document. """ @@ -1618,9 +1652,10 @@ class DocumentDiagnosticParams(TypedDict): class DocumentDiagnosticReportPartialResult(TypedDict): """A partial result for a document diagnostic report. - @since 3.17.0""" + @since 3.17.0 + """ - relatedDocuments: Dict[ + relatedDocuments: dict[ "DocumentUri", Union["FullDocumentDiagnosticReport", "UnchangedDocumentDiagnosticReport"], ] @@ -1629,7 +1664,8 @@ class DocumentDiagnosticReportPartialResult(TypedDict): class DiagnosticServerCancellationData(TypedDict): """Cancellation data returned from a diagnostic request. - @since 3.17.0""" + @since 3.17.0 + """ retriggerRequest: bool @@ -1637,7 +1673,8 @@ class DiagnosticServerCancellationData(TypedDict): class DiagnosticRegistrationOptions(TypedDict): """Diagnostic registration options. - @since 3.17.0""" + @since 3.17.0 + """ documentSelector: Union["DocumentSelector", None] """ A document selector to identify the scope of the registration. If set to null @@ -1660,11 +1697,12 @@ class DiagnosticRegistrationOptions(TypedDict): class WorkspaceDiagnosticParams(TypedDict): """Parameters of the workspace diagnostic request. - @since 3.17.0""" + @since 3.17.0 + """ identifier: NotRequired[str] """ The additional identifier provided during registration. """ - previousResultIds: List["PreviousResultId"] + previousResultIds: list["PreviousResultId"] """ The currently known diagnostic reports with their previous result ids. """ workDoneToken: NotRequired["ProgressToken"] @@ -1677,27 +1715,30 @@ class WorkspaceDiagnosticParams(TypedDict): class WorkspaceDiagnosticReport(TypedDict): """A workspace diagnostic report. - @since 3.17.0""" + @since 3.17.0 + """ - items: List["WorkspaceDocumentDiagnosticReport"] + items: list["WorkspaceDocumentDiagnosticReport"] class WorkspaceDiagnosticReportPartialResult(TypedDict): """A partial result for a workspace diagnostic report. - @since 3.17.0""" + @since 3.17.0 + """ - items: List["WorkspaceDocumentDiagnosticReport"] + items: list["WorkspaceDocumentDiagnosticReport"] class DidOpenNotebookDocumentParams(TypedDict): """The params sent in an open notebook document notification. - @since 3.17.0""" + @since 3.17.0 + """ notebookDocument: "NotebookDocument" """ The notebook document that got opened. """ - cellTextDocuments: List["TextDocumentItem"] + cellTextDocuments: list["TextDocumentItem"] """ The text documents that represent the content of a notebook cell. """ @@ -1705,7 +1746,8 @@ class DidOpenNotebookDocumentParams(TypedDict): class DidChangeNotebookDocumentParams(TypedDict): """The params sent in a change notebook document notification. - @since 3.17.0""" + @since 3.17.0 + """ notebookDocument: "VersionedNotebookDocumentIdentifier" """ The notebook document that did change. The version number points @@ -1731,7 +1773,8 @@ class DidChangeNotebookDocumentParams(TypedDict): class DidSaveNotebookDocumentParams(TypedDict): """The params sent in a save notebook document notification. - @since 3.17.0""" + @since 3.17.0 + """ notebookDocument: "NotebookDocumentIdentifier" """ The notebook document that got saved. """ @@ -1740,25 +1783,26 @@ class DidSaveNotebookDocumentParams(TypedDict): class DidCloseNotebookDocumentParams(TypedDict): """The params sent in a close notebook document notification. - @since 3.17.0""" + @since 3.17.0 + """ notebookDocument: "NotebookDocumentIdentifier" """ The notebook document that got closed. """ - cellTextDocuments: List["TextDocumentIdentifier"] + cellTextDocuments: list["TextDocumentIdentifier"] """ The text documents that represent the content of a notebook cell that got closed. """ class RegistrationParams(TypedDict): - registrations: List["Registration"] + registrations: list["Registration"] class UnregistrationParams(TypedDict): - unregisterations: List["Unregistration"] + unregisterations: list["Unregistration"] class InitializeParams(TypedDict): - processId: Union[int, None] + processId: int | None """ The process Id of the parent process that started the server. @@ -1777,7 +1821,7 @@ class InitializeParams(TypedDict): (See https://en.wikipedia.org/wiki/IETF_language_tag) @since 3.16.0 """ - rootPath: NotRequired[Union[str, None]] + rootPath: NotRequired[str | None] """ The rootPath of the workspace. Is null if no folder is open. @@ -1794,7 +1838,7 @@ class InitializeParams(TypedDict): """ User provided initialization options. """ trace: NotRequired["TraceValues"] """ The initial trace setting. If omitted trace is disabled ('off'). """ - workspaceFolders: NotRequired[Union[List["WorkspaceFolder"], None]] + workspaceFolders: NotRequired[list["WorkspaceFolder"] | None] """ The workspace folders configured in the client when the server starts. This property is only available if the client supports workspace folders. @@ -1817,7 +1861,8 @@ class InitializeResult(TypedDict): class InitializeError(TypedDict): """The data type of the ResponseError if the - initialize request fails.""" + initialize request fails. + """ retry: bool """ Indicates whether the client execute the following retry logic: @@ -1838,7 +1883,7 @@ class DidChangeConfigurationParams(TypedDict): class DidChangeConfigurationRegistrationOptions(TypedDict): - section: NotRequired[Union[str, List[str]]] + section: NotRequired[str | list[str]] class ShowMessageParams(TypedDict): @@ -1855,7 +1900,7 @@ class ShowMessageRequestParams(TypedDict): """ The message type. See {@link MessageType} """ message: str """ The actual message. """ - actions: NotRequired[List["MessageActionItem"]] + actions: NotRequired[list["MessageActionItem"]] """ The message action items to present. """ @@ -1887,7 +1932,7 @@ class DidChangeTextDocumentParams(TypedDict): """ The document that did change. The version number points to the version after all provided content changes have been applied. """ - contentChanges: List["TextDocumentContentChangeEvent"] + contentChanges: list["TextDocumentContentChangeEvent"] """ The actual content changes. The content changes describe single state changes to the document. So if there are two content changes c1 (at array index 0) and c2 (at array index 1) for a document in state S then c1 moves the document from @@ -1961,14 +2006,14 @@ class TextEdit(TypedDict): class DidChangeWatchedFilesParams(TypedDict): """The watched files change notification's parameters.""" - changes: List["FileEvent"] + changes: list["FileEvent"] """ The actual file events. """ class DidChangeWatchedFilesRegistrationOptions(TypedDict): """Describe options to be used when registered for text document change events.""" - watchers: List["FileSystemWatcher"] + watchers: list["FileSystemWatcher"] """ The watchers to register. """ @@ -1981,7 +2026,7 @@ class PublishDiagnosticsParams(TypedDict): """ Optional the version number of the document the diagnostics are published for. @since 3.15.0 """ - diagnostics: List["Diagnostic"] + diagnostics: list["Diagnostic"] """ An array of diagnostic information items. """ @@ -2004,7 +2049,8 @@ class CompletionParams(TypedDict): class CompletionItem(TypedDict): """A completion item represents a text snippet that is - proposed to complete text that is being typed.""" + proposed to complete text that is being typed. + """ label: str """ The label of this completion item. @@ -2021,7 +2067,7 @@ class CompletionItem(TypedDict): kind: NotRequired["CompletionItemKind"] """ The kind of this completion item. Based of the kind an icon is chosen by the editor. """ - tags: NotRequired[List["CompletionItemTag"]] + tags: NotRequired[list["CompletionItemTag"]] """ Tags for this completion item. @since 3.15.0 """ @@ -2104,7 +2150,7 @@ class CompletionItem(TypedDict): property is used as a text. @since 3.17.0 """ - additionalTextEdits: NotRequired[List["TextEdit"]] + additionalTextEdits: NotRequired[list["TextEdit"]] """ An optional array of additional {@link TextEdit text edits} that are applied when selecting this completion. Edits must not overlap (including the same insert position) with the main {@link CompletionItem.textEdit edit} nor with themselves. @@ -2112,7 +2158,7 @@ class CompletionItem(TypedDict): Additional text edits should be used to change text unrelated to the current cursor position (for example adding an import statement at the top of the file if the completion item will insert an unqualified type). """ - commitCharacters: NotRequired[List[str]] + commitCharacters: NotRequired[list[str]] """ An optional set of characters that when pressed while this completion is active will accept it first and then type that character. *Note* that all commit characters should have `length=1` and that superfluous characters will be ignored. """ @@ -2127,7 +2173,8 @@ class CompletionItem(TypedDict): class CompletionList(TypedDict): """Represents a collection of {@link CompletionItem completion items} to be presented - in the editor.""" + in the editor. + """ isIncomplete: bool """ This list it not complete. Further typing results in recomputing this list. @@ -2148,7 +2195,7 @@ class CompletionList(TypedDict): capability. @since 3.17.0 """ - items: List["CompletionItem"] + items: list["CompletionItem"] """ The completion items. """ @@ -2158,7 +2205,7 @@ class CompletionRegistrationOptions(TypedDict): documentSelector: Union["DocumentSelector", None] """ A document selector to identify the scope of the registration. If set to null the document selector provided on the client side will be used. """ - triggerCharacters: NotRequired[List[str]] + triggerCharacters: NotRequired[list[str]] """ Most tools trigger completion request automatically without explicitly requesting it using a keyboard shortcut (e.g. Ctrl+Space). Typically they do so when the user starts to type an identifier. For example if the user types `c` in a JavaScript file @@ -2167,7 +2214,7 @@ class CompletionRegistrationOptions(TypedDict): If code complete should automatically be trigger on characters not being valid inside an identifier (for example `.` in JavaScript) list them in `triggerCharacters`. """ - allCommitCharacters: NotRequired[List[str]] + allCommitCharacters: NotRequired[list[str]] """ The list of all possible characters that commit a completion. This field can be used if clients don't support individual commit characters per completion item. See `ClientCapabilities.textDocument.completion.completionItem.commitCharactersSupport` @@ -2200,7 +2247,7 @@ class HoverParams(TypedDict): class Hover(TypedDict): """The result of a hover request.""" - contents: Union["MarkupContent", "MarkedString", List["MarkedString"]] + contents: Union["MarkupContent", "MarkedString", list["MarkedString"]] """ The hover's content """ range: NotRequired["Range"] """ An optional range inside the text document that is used to @@ -2234,9 +2281,10 @@ class SignatureHelpParams(TypedDict): class SignatureHelp(TypedDict): """Signature help represents the signature of something callable. There can be multiple signature but only one - active and only one active parameter.""" + active and only one active parameter. + """ - signatures: List["SignatureInformation"] + signatures: list["SignatureInformation"] """ One or more signatures. """ activeSignature: NotRequired[Uint] """ The active signature. If omitted or the value lies outside the @@ -2264,9 +2312,9 @@ class SignatureHelpRegistrationOptions(TypedDict): documentSelector: Union["DocumentSelector", None] """ A document selector to identify the scope of the registration. If set to null the document selector provided on the client side will be used. """ - triggerCharacters: NotRequired[List[str]] + triggerCharacters: NotRequired[list[str]] """ List of characters that trigger signature help automatically. """ - retriggerCharacters: NotRequired[List[str]] + retriggerCharacters: NotRequired[list[str]] """ List of characters that re-trigger signature help. These trigger characters are only active when signature help is already showing. All trigger characters @@ -2337,7 +2385,8 @@ class DocumentHighlightParams(TypedDict): class DocumentHighlight(TypedDict): """A document highlight is a range inside a text document which deserves special attention. Usually a document highlight is visualized by changing - the background color of its range.""" + the background color of its range. + """ range: "Range" """ The range this highlight applies to. """ @@ -2367,7 +2416,8 @@ class DocumentSymbolParams(TypedDict): class SymbolInformation(TypedDict): """Represents information about programming constructs like variables, classes, - interfaces etc.""" + interfaces etc. + """ deprecated: NotRequired[bool] """ Indicates if this symbol is deprecated. @@ -2387,7 +2437,7 @@ class SymbolInformation(TypedDict): """ The name of this symbol. """ kind: "SymbolKind" """ The kind of this symbol. """ - tags: NotRequired[List["SymbolTag"]] + tags: NotRequired[list["SymbolTag"]] """ Tags for this symbol. @since 3.16.0 """ @@ -2402,7 +2452,8 @@ class DocumentSymbol(TypedDict): """Represents programming constructs like variables, classes, interfaces etc. that appear in a document. Document symbols can be hierarchical and they have two ranges: one that encloses its definition and one that points to - its most interesting range, e.g. the range of an identifier.""" + its most interesting range, e.g. the range of an identifier. + """ name: str """ The name of this symbol. Will be displayed in the user interface and therefore must not be @@ -2411,7 +2462,7 @@ class DocumentSymbol(TypedDict): """ More detail for this symbol, e.g the signature of a function. """ kind: "SymbolKind" """ The kind of this symbol. """ - tags: NotRequired[List["SymbolTag"]] + tags: NotRequired[list["SymbolTag"]] """ Tags for this document symbol. @since 3.16.0 """ @@ -2461,13 +2512,14 @@ class Command(TypedDict): """Represents a reference to a command. Provides a title which will be used to represent a command in the UI and, optionally, an array of arguments which will be passed to the command handler - function when invoked.""" + function when invoked. + """ title: str """ Title of the command, like `save`. """ command: str """ The identifier of the actual command handler. """ - arguments: NotRequired[List["LSPAny"]] + arguments: NotRequired[list["LSPAny"]] """ Arguments that the command handler should be invoked with. """ @@ -2485,7 +2537,7 @@ class CodeAction(TypedDict): """ The kind of the code action. Used to filter code actions. """ - diagnostics: NotRequired[List["Diagnostic"]] + diagnostics: NotRequired[list["Diagnostic"]] """ The diagnostics that this code action resolves. """ isPreferred: NotRequired[bool] """ Marks this as a preferred action. Preferred actions are used by the `auto fix` command and can be targeted @@ -2530,7 +2582,7 @@ class CodeActionRegistrationOptions(TypedDict): documentSelector: Union["DocumentSelector", None] """ A document selector to identify the scope of the registration. If set to null the document selector provided on the client side will be used. """ - codeActionKinds: NotRequired[List["CodeActionKind"]] + codeActionKinds: NotRequired[list["CodeActionKind"]] """ CodeActionKinds that this server may return. The list of kinds may be generic, such as `CodeActionKind.Refactor`, or the server @@ -2560,7 +2612,8 @@ class WorkspaceSymbol(TypedDict): See also SymbolInformation. - @since 3.17.0""" + @since 3.17.0 + """ location: Union["Location", "__WorkspaceSymbol_location_Type_1"] """ The location of the symbol. Whether a server is allowed to @@ -2575,7 +2628,7 @@ class WorkspaceSymbol(TypedDict): """ The name of this symbol. """ kind: "SymbolKind" """ The kind of this symbol. """ - tags: NotRequired[List["SymbolTag"]] + tags: NotRequired[list["SymbolTag"]] """ Tags for this symbol. @since 3.16.0 """ @@ -2613,7 +2666,8 @@ class CodeLens(TypedDict): source text, like the number of references, a way to run tests, etc. A code lens is _unresolved_ when no command is associated to it. For performance - reasons the creation of a code lens and resolving should be done in two stages.""" + reasons the creation of a code lens and resolving should be done in two stages. + """ range: "Range" """ The range in which this code lens is valid. Should only span a single line. """ @@ -2649,7 +2703,8 @@ class DocumentLinkParams(TypedDict): class DocumentLink(TypedDict): """A document link is a range in a text document that links to an internal or external resource, like another - text document or a web site.""" + text document or a web site. + """ range: "Range" """ The range this link applies to. """ @@ -2744,7 +2799,7 @@ class DocumentOnTypeFormattingRegistrationOptions(TypedDict): the document selector provided on the client side will be used. """ firstTriggerCharacter: str """ A character on which formatting should be triggered, like `{`. """ - moreTriggerCharacter: NotRequired[List[str]] + moreTriggerCharacter: NotRequired[list[str]] """ More trigger characters. """ @@ -2789,7 +2844,7 @@ class ExecuteCommandParams(TypedDict): command: str """ The identifier of the actual command handler. """ - arguments: NotRequired[List["LSPAny"]] + arguments: NotRequired[list["LSPAny"]] """ Arguments that the command should be invoked with. """ workDoneToken: NotRequired["ProgressToken"] """ An optional token that a server can use to report work done progress. """ @@ -2798,7 +2853,7 @@ class ExecuteCommandParams(TypedDict): class ExecuteCommandRegistrationOptions(TypedDict): """Registration options for a {@link ExecuteCommandRequest}.""" - commands: List[str] + commands: list[str] """ The commands to be executed on the server """ @@ -2816,7 +2871,8 @@ class ApplyWorkspaceEditParams(TypedDict): class ApplyWorkspaceEditResult(TypedDict): """The result returned from the apply workspace edit request. - @since 3.17 renamed from ApplyWorkspaceEditResponse""" + @since 3.17 renamed from ApplyWorkspaceEditResponse + """ applied: bool """ Indicates whether the edit was applied or not. """ @@ -2895,7 +2951,7 @@ class LogTraceParams(TypedDict): class CancelParams(TypedDict): - id: Union[int, str] + id: int | str """ The request id to cancel. """ @@ -2908,7 +2964,8 @@ class ProgressParams(TypedDict): class TextDocumentPositionParams(TypedDict): """A parameter literal used in requests to pass a text document and a position inside that - document.""" + document. + """ textDocument: "TextDocumentIdentifier" """ The text document. """ @@ -2929,7 +2986,8 @@ class PartialResultParams(TypedDict): class LocationLink(TypedDict): """Represents the connection of two locations. Provides additional metadata over normal {@link Location locations}, - including an origin range.""" + including an origin range. + """ originSelectionRange: NotRequired["Range"] """ Span of the origin of this link. @@ -2958,7 +3016,8 @@ class Range(TypedDict): start: { line: 5, character: 23 } end : { line 6, character : 0 } } - ```""" + ``` + """ start: "Position" """ The range's start position. """ @@ -2972,7 +3031,8 @@ class ImplementationOptions(TypedDict): class StaticRegistrationOptions(TypedDict): """Static registration options to be returned in the initialize - request.""" + request. + """ id: NotRequired[str] """ The id used to register the request. The id can be used to deregister @@ -2986,9 +3046,9 @@ class TypeDefinitionOptions(TypedDict): class WorkspaceFoldersChangeEvent(TypedDict): """The workspace folder change event.""" - added: List["WorkspaceFolder"] + added: list["WorkspaceFolder"] """ The array of added workspace folders """ - removed: List["WorkspaceFolder"] + removed: list["WorkspaceFolder"] """ The array of the removed workspace folders """ @@ -3032,7 +3092,7 @@ class DeclarationOptions(TypedDict): class Position(TypedDict): - """Position in a text document expressed as zero-based line and character + r"""Position in a text document expressed as zero-based line and character offset. Prior to 3.17 the offsets were always based on a UTF-16 string representation. So a string of the form `a𐐀b` the character offset of the character `a` is 0, the character offset of `𐐀` is 1 and the character @@ -3058,7 +3118,8 @@ class Position(TypedDict): Positions are line end character agnostic. So you can not specify a position that denotes `\r|\n` or `\n|` where `|` represents the character offset. - @since 3.17.0 - support for negotiated position encoding.""" + @since 3.17.0 - support for negotiated position encoding. + """ line: Uint """ Line position in a document (zero-based). @@ -3082,7 +3143,8 @@ class SelectionRangeOptions(TypedDict): class CallHierarchyOptions(TypedDict): """Call hierarchy options used during static registration. - @since 3.16.0""" + @since 3.16.0 + """ workDoneProgress: NotRequired[bool] @@ -3092,7 +3154,7 @@ class SemanticTokensOptions(TypedDict): legend: "SemanticTokensLegend" """ The legend used by the server """ - range: NotRequired[Union[bool, dict]] + range: NotRequired[bool | dict] """ Server supports providing semantic tokens for a specific range of a document. """ full: NotRequired[Union[bool, "__SemanticTokensOptions_full_Type_2"]] @@ -3107,7 +3169,7 @@ class SemanticTokensEdit(TypedDict): """ The start offset of the edit. """ deleteCount: Uint """ The count of elements to remove. """ - data: NotRequired[List[Uint]] + data: NotRequired[list[Uint]] """ The elements to insert. """ @@ -3118,7 +3180,8 @@ class LinkedEditingRangeOptions(TypedDict): class FileCreate(TypedDict): """Represents information on a file/folder create. - @since 3.16.0""" + @since 3.16.0 + """ uri: str """ A file:// URI for the location of the file/folder being created. """ @@ -3128,11 +3191,12 @@ class TextDocumentEdit(TypedDict): """Describes textual changes on a text document. A TextDocumentEdit describes all changes on a document version Si and after they are applied move the document to version Si+1. So the creator of a TextDocumentEdit doesn't need to sort the array of edits or do any - kind of ordering. However the edits must be non overlapping.""" + kind of ordering. However the edits must be non overlapping. + """ textDocument: "OptionalVersionedTextDocumentIdentifier" """ The text document to change. """ - edits: List[Union["TextEdit", "AnnotatedTextEdit"]] + edits: list[Union["TextEdit", "AnnotatedTextEdit"]] """ The edits to be applied. @since 3.16.0 - support for AnnotatedTextEdit. This is guarded using a @@ -3189,7 +3253,8 @@ class DeleteFile(TypedDict): class ChangeAnnotation(TypedDict): """Additional information that describes document changes. - @since 3.16.0""" + @since 3.16.0 + """ label: str """ A human-readable string describing the actual change. The string @@ -3206,7 +3271,8 @@ class FileOperationFilter(TypedDict): """A filter to describe in which file operation requests or notifications the server is interested in receiving. - @since 3.16.0""" + @since 3.16.0 + """ scheme: NotRequired[str] """ A Uri scheme like `file` or `untitled`. """ @@ -3217,7 +3283,8 @@ class FileOperationFilter(TypedDict): class FileRename(TypedDict): """Represents information on a file/folder rename. - @since 3.16.0""" + @since 3.16.0 + """ oldUri: str """ A file:// URI for the original location of the file/folder being renamed. """ @@ -3228,7 +3295,8 @@ class FileRename(TypedDict): class FileDelete(TypedDict): """Represents information on a file/folder delete. - @since 3.16.0""" + @since 3.16.0 + """ uri: str """ A file:// URI for the location of the file/folder being deleted. """ @@ -3241,7 +3309,8 @@ class MonikerOptions(TypedDict): class TypeHierarchyOptions(TypedDict): """Type hierarchy options used during static registration. - @since 3.17.0""" + @since 3.17.0 + """ workDoneProgress: NotRequired[bool] @@ -3259,7 +3328,8 @@ class InlineValueContext(TypedDict): class InlineValueText(TypedDict): """Provide inline value as text. - @since 3.17.0""" + @since 3.17.0 + """ range: "Range" """ The document range for which the inline value applies. """ @@ -3272,7 +3342,8 @@ class InlineValueVariableLookup(TypedDict): If only a range is specified, the variable name will be extracted from the underlying document. An optional variable name can be used to override the extracted name. - @since 3.17.0""" + @since 3.17.0 + """ range: "Range" """ The document range for which the inline value applies. @@ -3288,7 +3359,8 @@ class InlineValueEvaluatableExpression(TypedDict): If only a range is specified, the expression will be extracted from the underlying document. An optional expression can be used to override the extracted expression. - @since 3.17.0""" + @since 3.17.0 + """ range: "Range" """ The document range for which the inline value applies. @@ -3300,7 +3372,8 @@ class InlineValueEvaluatableExpression(TypedDict): class InlineValueOptions(TypedDict): """Inline value options used during static registration. - @since 3.17.0""" + @since 3.17.0 + """ workDoneProgress: NotRequired[bool] @@ -3309,7 +3382,8 @@ class InlayHintLabelPart(TypedDict): """An inlay hint label part allows for interactive and composite labels of inlay hints. - @since 3.17.0""" + @since 3.17.0 + """ value: str """ The value of this label part. """ @@ -3337,7 +3411,7 @@ class InlayHintLabelPart(TypedDict): class MarkupContent(TypedDict): - """A `MarkupContent` literal represents a string value which content is interpreted base on its + r"""A `MarkupContent` literal represents a string value which content is interpreted base on its kind flag. Currently the protocol supports `plaintext` and `markdown` as markup kinds. If the kind is `markdown` then the value can contain fenced code blocks like in GitHub issues. @@ -3358,7 +3432,8 @@ class MarkupContent(TypedDict): ``` *Please Note* that clients might sanitize the return markdown. A client could decide to - remove HTML from the markdown to avoid script execution.""" + remove HTML from the markdown to avoid script execution. + """ kind: "MarkupKind" """ The type of the Markup """ @@ -3369,7 +3444,8 @@ class MarkupContent(TypedDict): class InlayHintOptions(TypedDict): """Inlay hint options used during static registration. - @since 3.17.0""" + @since 3.17.0 + """ resolveProvider: NotRequired[bool] """ The server provides support to resolve additional @@ -3380,10 +3456,11 @@ class InlayHintOptions(TypedDict): class RelatedFullDocumentDiagnosticReport(TypedDict): """A full diagnostic report with a set of related documents. - @since 3.17.0""" + @since 3.17.0 + """ relatedDocuments: NotRequired[ - Dict[ + dict[ "DocumentUri", Union["FullDocumentDiagnosticReport", "UnchangedDocumentDiagnosticReport"], ] @@ -3401,17 +3478,18 @@ class RelatedFullDocumentDiagnosticReport(TypedDict): """ An optional result id. If provided it will be sent on the next diagnostic request for the same document. """ - items: List["Diagnostic"] + items: list["Diagnostic"] """ The actual items. """ class RelatedUnchangedDocumentDiagnosticReport(TypedDict): """An unchanged diagnostic report with a set of related documents. - @since 3.17.0""" + @since 3.17.0 + """ relatedDocuments: NotRequired[ - Dict[ + dict[ "DocumentUri", Union["FullDocumentDiagnosticReport", "UnchangedDocumentDiagnosticReport"], ] @@ -3436,7 +3514,8 @@ class RelatedUnchangedDocumentDiagnosticReport(TypedDict): class FullDocumentDiagnosticReport(TypedDict): """A diagnostic report with a full set of problems. - @since 3.17.0""" + @since 3.17.0 + """ kind: Literal["full"] """ A full document diagnostic report. """ @@ -3444,7 +3523,7 @@ class FullDocumentDiagnosticReport(TypedDict): """ An optional result id. If provided it will be sent on the next diagnostic request for the same document. """ - items: List["Diagnostic"] + items: list["Diagnostic"] """ The actual items. """ @@ -3452,7 +3531,8 @@ class UnchangedDocumentDiagnosticReport(TypedDict): """A diagnostic report indicating that the last returned report is still accurate. - @since 3.17.0""" + @since 3.17.0 + """ kind: Literal["unchanged"] """ A document diagnostic report indicating @@ -3467,7 +3547,8 @@ class UnchangedDocumentDiagnosticReport(TypedDict): class DiagnosticOptions(TypedDict): """Diagnostic options. - @since 3.17.0""" + @since 3.17.0 + """ identifier: NotRequired[str] """ An optional identifier under which the diagnostics are @@ -3485,7 +3566,8 @@ class DiagnosticOptions(TypedDict): class PreviousResultId(TypedDict): """A previous result id in a workspace pull request. - @since 3.17.0""" + @since 3.17.0 + """ uri: "DocumentUri" """ The URI for which the client knowns a @@ -3497,7 +3579,8 @@ class PreviousResultId(TypedDict): class NotebookDocument(TypedDict): """A notebook document. - @since 3.17.0""" + @since 3.17.0 + """ uri: "URI" """ The notebook document's uri. """ @@ -3511,13 +3594,14 @@ class NotebookDocument(TypedDict): document. Note: should always be an object literal (e.g. LSPObject) """ - cells: List["NotebookCell"] + cells: list["NotebookCell"] """ The cells of a notebook. """ class TextDocumentItem(TypedDict): """An item to transfer a text document from the client to the - server.""" + server. + """ uri: "DocumentUri" """ The text document's uri. """ @@ -3533,7 +3617,8 @@ class TextDocumentItem(TypedDict): class VersionedNotebookDocumentIdentifier(TypedDict): """A versioned notebook document identifier. - @since 3.17.0""" + @since 3.17.0 + """ version: int """ The version number of this notebook document. """ @@ -3544,7 +3629,8 @@ class VersionedNotebookDocumentIdentifier(TypedDict): class NotebookDocumentChangeEvent(TypedDict): """A change event for a notebook document. - @since 3.17.0""" + @since 3.17.0 + """ metadata: NotRequired["LSPObject"] """ The changed meta data if any. @@ -3557,7 +3643,8 @@ class NotebookDocumentChangeEvent(TypedDict): class NotebookDocumentIdentifier(TypedDict): """A literal to identify a notebook document in the client. - @since 3.17.0""" + @since 3.17.0 + """ uri: "URI" """ The notebook document's uri. """ @@ -3586,7 +3673,7 @@ class Unregistration(TypedDict): class WorkspaceFoldersInitializeParams(TypedDict): - workspaceFolders: NotRequired[Union[List["WorkspaceFolder"], None]] + workspaceFolders: NotRequired[list["WorkspaceFolder"] | None] """ The workspace folders configured in the client when the server starts. This property is only available if the client supports workspace folders. @@ -3598,7 +3685,8 @@ class WorkspaceFoldersInitializeParams(TypedDict): class ServerCapabilities(TypedDict): """Defines the capabilities provided by a language - server.""" + server. + """ positionEncoding: NotRequired["PositionEncodingKind"] """ The position encoding the server picked from the encodings offered @@ -3610,15 +3698,11 @@ class ServerCapabilities(TypedDict): If omitted it defaults to 'utf-16'. @since 3.17.0 """ - textDocumentSync: NotRequired[ - Union["TextDocumentSyncOptions", "TextDocumentSyncKind"] - ] + textDocumentSync: NotRequired[Union["TextDocumentSyncOptions", "TextDocumentSyncKind"]] """ Defines how text documents are synced. Is either a detailed structure defining each notification or for backwards compatibility the TextDocumentSyncKind number. """ - notebookDocumentSync: NotRequired[ - Union["NotebookDocumentSyncOptions", "NotebookDocumentSyncRegistrationOptions"] - ] + notebookDocumentSync: NotRequired[Union["NotebookDocumentSyncOptions", "NotebookDocumentSyncRegistrationOptions"]] """ Defines how notebook documents are synced. @since 3.17.0 """ @@ -3628,19 +3712,13 @@ class ServerCapabilities(TypedDict): """ The server provides hover support. """ signatureHelpProvider: NotRequired["SignatureHelpOptions"] """ The server provides signature help support. """ - declarationProvider: NotRequired[ - Union[bool, "DeclarationOptions", "DeclarationRegistrationOptions"] - ] + declarationProvider: NotRequired[Union[bool, "DeclarationOptions", "DeclarationRegistrationOptions"]] """ The server provides Goto Declaration support. """ definitionProvider: NotRequired[Union[bool, "DefinitionOptions"]] """ The server provides goto definition support. """ - typeDefinitionProvider: NotRequired[ - Union[bool, "TypeDefinitionOptions", "TypeDefinitionRegistrationOptions"] - ] + typeDefinitionProvider: NotRequired[Union[bool, "TypeDefinitionOptions", "TypeDefinitionRegistrationOptions"]] """ The server provides Goto Type Definition support. """ - implementationProvider: NotRequired[ - Union[bool, "ImplementationOptions", "ImplementationRegistrationOptions"] - ] + implementationProvider: NotRequired[Union[bool, "ImplementationOptions", "ImplementationRegistrationOptions"]] """ The server provides Goto Implementation support. """ referencesProvider: NotRequired[Union[bool, "ReferenceOptions"]] """ The server provides find references support. """ @@ -3656,17 +3734,13 @@ class ServerCapabilities(TypedDict): """ The server provides code lens. """ documentLinkProvider: NotRequired["DocumentLinkOptions"] """ The server provides document link support. """ - colorProvider: NotRequired[ - Union[bool, "DocumentColorOptions", "DocumentColorRegistrationOptions"] - ] + colorProvider: NotRequired[Union[bool, "DocumentColorOptions", "DocumentColorRegistrationOptions"]] """ The server provides color provider support. """ workspaceSymbolProvider: NotRequired[Union[bool, "WorkspaceSymbolOptions"]] """ The server provides workspace symbol support. """ documentFormattingProvider: NotRequired[Union[bool, "DocumentFormattingOptions"]] """ The server provides document formatting. """ - documentRangeFormattingProvider: NotRequired[ - Union[bool, "DocumentRangeFormattingOptions"] - ] + documentRangeFormattingProvider: NotRequired[Union[bool, "DocumentRangeFormattingOptions"]] """ The server provides document range formatting. """ documentOnTypeFormattingProvider: NotRequired["DocumentOnTypeFormattingOptions"] """ The server provides document formatting on typing. """ @@ -3674,63 +3748,41 @@ class ServerCapabilities(TypedDict): """ The server provides rename support. RenameOptions may only be specified if the client states that it supports `prepareSupport` in its initial `initialize` request. """ - foldingRangeProvider: NotRequired[ - Union[bool, "FoldingRangeOptions", "FoldingRangeRegistrationOptions"] - ] + foldingRangeProvider: NotRequired[Union[bool, "FoldingRangeOptions", "FoldingRangeRegistrationOptions"]] """ The server provides folding provider support. """ - selectionRangeProvider: NotRequired[ - Union[bool, "SelectionRangeOptions", "SelectionRangeRegistrationOptions"] - ] + selectionRangeProvider: NotRequired[Union[bool, "SelectionRangeOptions", "SelectionRangeRegistrationOptions"]] """ The server provides selection range support. """ executeCommandProvider: NotRequired["ExecuteCommandOptions"] """ The server provides execute command support. """ - callHierarchyProvider: NotRequired[ - Union[bool, "CallHierarchyOptions", "CallHierarchyRegistrationOptions"] - ] + callHierarchyProvider: NotRequired[Union[bool, "CallHierarchyOptions", "CallHierarchyRegistrationOptions"]] """ The server provides call hierarchy support. @since 3.16.0 """ - linkedEditingRangeProvider: NotRequired[ - Union[ - bool, "LinkedEditingRangeOptions", "LinkedEditingRangeRegistrationOptions" - ] - ] + linkedEditingRangeProvider: NotRequired[Union[bool, "LinkedEditingRangeOptions", "LinkedEditingRangeRegistrationOptions"]] """ The server provides linked editing range support. @since 3.16.0 """ - semanticTokensProvider: NotRequired[ - Union["SemanticTokensOptions", "SemanticTokensRegistrationOptions"] - ] + semanticTokensProvider: NotRequired[Union["SemanticTokensOptions", "SemanticTokensRegistrationOptions"]] """ The server provides semantic tokens support. @since 3.16.0 """ - monikerProvider: NotRequired[ - Union[bool, "MonikerOptions", "MonikerRegistrationOptions"] - ] + monikerProvider: NotRequired[Union[bool, "MonikerOptions", "MonikerRegistrationOptions"]] """ The server provides moniker support. @since 3.16.0 """ - typeHierarchyProvider: NotRequired[ - Union[bool, "TypeHierarchyOptions", "TypeHierarchyRegistrationOptions"] - ] + typeHierarchyProvider: NotRequired[Union[bool, "TypeHierarchyOptions", "TypeHierarchyRegistrationOptions"]] """ The server provides type hierarchy support. @since 3.17.0 """ - inlineValueProvider: NotRequired[ - Union[bool, "InlineValueOptions", "InlineValueRegistrationOptions"] - ] + inlineValueProvider: NotRequired[Union[bool, "InlineValueOptions", "InlineValueRegistrationOptions"]] """ The server provides inline values. @since 3.17.0 """ - inlayHintProvider: NotRequired[ - Union[bool, "InlayHintOptions", "InlayHintRegistrationOptions"] - ] + inlayHintProvider: NotRequired[Union[bool, "InlayHintOptions", "InlayHintRegistrationOptions"]] """ The server provides inlay hints. @since 3.17.0 """ - diagnosticProvider: NotRequired[ - Union["DiagnosticOptions", "DiagnosticRegistrationOptions"] - ] + diagnosticProvider: NotRequired[Union["DiagnosticOptions", "DiagnosticRegistrationOptions"]] """ The server has support for pull model diagnostics. @since 3.17.0 """ @@ -3778,14 +3830,15 @@ class FileSystemWatcher(TypedDict): class Diagnostic(TypedDict): """Represents a diagnostic, such as a compiler error or warning. Diagnostic objects - are only valid in the scope of a resource.""" + are only valid in the scope of a resource. + """ range: "Range" """ The range at which the message applies """ severity: NotRequired["DiagnosticSeverity"] """ The diagnostic's severity. Can be omitted. If omitted it is up to the client to interpret diagnostics as error, warning, info or hint. """ - code: NotRequired[Union[int, str]] + code: NotRequired[int | str] """ The diagnostic's code, which usually appear in the user interface. """ codeDescription: NotRequired["CodeDescription"] """ An optional property to describe the error code. @@ -3798,11 +3851,11 @@ class Diagnostic(TypedDict): appears in the user interface. """ message: str """ The diagnostic's message. It usually appears in the user interface """ - tags: NotRequired[List["DiagnosticTag"]] + tags: NotRequired[list["DiagnosticTag"]] """ Additional metadata about the diagnostic. @since 3.15.0 """ - relatedInformation: NotRequired[List["DiagnosticRelatedInformation"]] + relatedInformation: NotRequired[list["DiagnosticRelatedInformation"]] """ An array of related diagnostic information, e.g. when symbol-names within a scope collide all definitions can be marked via this property. """ data: NotRequired["LSPAny"] @@ -3825,7 +3878,8 @@ class CompletionContext(TypedDict): class CompletionItemLabelDetails(TypedDict): """Additional details for a completion item label. - @since 3.17.0""" + @since 3.17.0 + """ detail: NotRequired[str] """ An optional string which is rendered less prominently directly after {@link CompletionItem.label label}, @@ -3838,7 +3892,8 @@ class CompletionItemLabelDetails(TypedDict): class InsertReplaceEdit(TypedDict): """A special text edit to provide an insert and a replace operation. - @since 3.16.0""" + @since 3.16.0 + """ newText: str """ The string to be inserted. """ @@ -3851,7 +3906,7 @@ class InsertReplaceEdit(TypedDict): class CompletionOptions(TypedDict): """Completion options.""" - triggerCharacters: NotRequired[List[str]] + triggerCharacters: NotRequired[list[str]] """ Most tools trigger completion request automatically without explicitly requesting it using a keyboard shortcut (e.g. Ctrl+Space). Typically they do so when the user starts to type an identifier. For example if the user types `c` in a JavaScript file @@ -3860,7 +3915,7 @@ class CompletionOptions(TypedDict): If code complete should automatically be trigger on characters not being valid inside an identifier (for example `.` in JavaScript) list them in `triggerCharacters`. """ - allCommitCharacters: NotRequired[List[str]] + allCommitCharacters: NotRequired[list[str]] """ The list of all possible characters that commit a completion. This field can be used if clients don't support individual commit characters per completion item. See `ClientCapabilities.textDocument.completion.completionItem.commitCharactersSupport` @@ -3889,7 +3944,8 @@ class HoverOptions(TypedDict): class SignatureHelpContext(TypedDict): """Additional information about the context in which a signature help request was triggered. - @since 3.15.0""" + @since 3.15.0 + """ triggerKind: "SignatureHelpTriggerKind" """ Action that caused signature help to be triggered. """ @@ -3912,7 +3968,8 @@ class SignatureHelpContext(TypedDict): class SignatureInformation(TypedDict): """Represents the signature of something callable. A signature can have a label, like a function-name, a doc-comment, and - a set of parameters.""" + a set of parameters. + """ label: str """ The label of this signature. Will be shown in @@ -3920,7 +3977,7 @@ class SignatureInformation(TypedDict): documentation: NotRequired[Union[str, "MarkupContent"]] """ The human-readable doc-comment of this signature. Will be shown in the UI but can be omitted. """ - parameters: NotRequired[List["ParameterInformation"]] + parameters: NotRequired[list["ParameterInformation"]] """ The parameters of this signature. """ activeParameter: NotRequired[Uint] """ The index of the active parameter. @@ -3933,9 +3990,9 @@ class SignatureInformation(TypedDict): class SignatureHelpOptions(TypedDict): """Server Capabilities for a {@link SignatureHelpRequest}.""" - triggerCharacters: NotRequired[List[str]] + triggerCharacters: NotRequired[list[str]] """ List of characters that trigger signature help automatically. """ - retriggerCharacters: NotRequired[List[str]] + retriggerCharacters: NotRequired[list[str]] """ List of characters that re-trigger signature help. These trigger characters are only active when signature help is already showing. All trigger characters @@ -3953,7 +4010,8 @@ class DefinitionOptions(TypedDict): class ReferenceContext(TypedDict): """Value-object that contains additional information when - requesting references.""" + requesting references. + """ includeDeclaration: bool """ Include the declaration of the current symbol. """ @@ -3978,7 +4036,7 @@ class BaseSymbolInformation(TypedDict): """ The name of this symbol. """ kind: "SymbolKind" """ The kind of this symbol. """ - tags: NotRequired[List["SymbolTag"]] + tags: NotRequired[list["SymbolTag"]] """ Tags for this symbol. @since 3.16.0 """ @@ -4002,15 +4060,16 @@ class DocumentSymbolOptions(TypedDict): class CodeActionContext(TypedDict): """Contains additional diagnostic information about the context in which - a {@link CodeActionProvider.provideCodeActions code action} is run.""" + a {@link CodeActionProvider.provideCodeActions code action} is run. + """ - diagnostics: List["Diagnostic"] + diagnostics: list["Diagnostic"] """ An array of diagnostics known on the client side overlapping the range provided to the `textDocument/codeAction` request. They are provided so that the server knows which errors are currently presented to the user for the given range. There is no guarantee that these accurately reflect the error state of the resource. The primary parameter to compute code actions is the provided range. """ - only: NotRequired[List["CodeActionKind"]] + only: NotRequired[list["CodeActionKind"]] """ Requested kind of actions to return. Actions not of this kind are filtered out by the client before being shown. So servers @@ -4024,7 +4083,7 @@ class CodeActionContext(TypedDict): class CodeActionOptions(TypedDict): """Provider options for a {@link CodeActionRequest}.""" - codeActionKinds: NotRequired[List["CodeActionKind"]] + codeActionKinds: NotRequired[list["CodeActionKind"]] """ CodeActionKinds that this server may return. The list of kinds may be generic, such as `CodeActionKind.Refactor`, or the server @@ -4102,7 +4161,7 @@ class DocumentOnTypeFormattingOptions(TypedDict): firstTriggerCharacter: str """ A character on which formatting should be triggered, like `{`. """ - moreTriggerCharacter: NotRequired[List[str]] + moreTriggerCharacter: NotRequired[list[str]] """ More trigger characters. """ @@ -4119,7 +4178,7 @@ class RenameOptions(TypedDict): class ExecuteCommandOptions(TypedDict): """The server capabilities of a {@link ExecuteCommandRequest}.""" - commands: List[str] + commands: list[str] """ The commands to be executed on the server """ workDoneProgress: NotRequired[bool] @@ -4127,16 +4186,16 @@ class ExecuteCommandOptions(TypedDict): class SemanticTokensLegend(TypedDict): """@since 3.16.0""" - tokenTypes: List[str] + tokenTypes: list[str] """ The token types a server uses. """ - tokenModifiers: List[str] + tokenModifiers: list[str] """ The token modifiers a server uses. """ class OptionalVersionedTextDocumentIdentifier(TypedDict): """A text document identifier to optionally denote a specific version of a text document.""" - version: Union[int, None] + version: int | None """ The version number of this document. If a versioned text document identifier is sent from the server to the client and the file is not open in the editor (the server has not received an open notification before) the server can send @@ -4149,7 +4208,8 @@ class OptionalVersionedTextDocumentIdentifier(TypedDict): class AnnotatedTextEdit(TypedDict): """A special text edit with an additional change annotation. - @since 3.16.0.""" + @since 3.16.0. + """ annotationId: "ChangeAnnotationIdentifier" """ The actual identifier of the change annotation """ @@ -4203,14 +4263,15 @@ class FileOperationPattern(TypedDict): """A pattern to describe in which file operation requests or notifications the server is interested in receiving. - @since 3.16.0""" + @since 3.16.0 + """ glob: str """ The glob pattern to match. Glob patterns can have the following syntax: - `*` to match one or more characters in a path segment - `?` to match on one character in a path segment - `**` to match any number of path segments, including none - - `{}` to group sub patterns into an OR expression. (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files) + - `{}` to group sub patterns into an OR expression. (e.g. `**\u200b/*.{ts,js}` matches all TypeScript and JavaScript files) - `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …) - `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`) """ matches: NotRequired["FileOperationPatternKind"] @@ -4224,11 +4285,12 @@ class FileOperationPattern(TypedDict): class WorkspaceFullDocumentDiagnosticReport(TypedDict): """A full document diagnostic report for a workspace diagnostic result. - @since 3.17.0""" + @since 3.17.0 + """ uri: "DocumentUri" """ The URI for which diagnostic information is reported. """ - version: Union[int, None] + version: int | None """ The version number for which the diagnostics are reported. If the document is not marked as open `null` can be provided. """ kind: Literal["full"] @@ -4237,18 +4299,19 @@ class WorkspaceFullDocumentDiagnosticReport(TypedDict): """ An optional result id. If provided it will be sent on the next diagnostic request for the same document. """ - items: List["Diagnostic"] + items: list["Diagnostic"] """ The actual items. """ class WorkspaceUnchangedDocumentDiagnosticReport(TypedDict): """An unchanged document diagnostic report for a workspace diagnostic result. - @since 3.17.0""" + @since 3.17.0 + """ uri: "DocumentUri" """ The URI for which diagnostic information is reported. """ - version: Union[int, None] + version: int | None """ The version number for which the diagnostics are reported. If the document is not marked as open `null` can be provided. """ kind: Literal["unchanged"] @@ -4268,7 +4331,8 @@ class NotebookCell(TypedDict): cells and can therefore be used to uniquely identify a notebook cell or the cell's text document. - @since 3.17.0""" + @since 3.17.0 + """ kind: "NotebookCellKind" """ The cell's kind """ @@ -4288,13 +4352,14 @@ class NotebookCellArrayChange(TypedDict): """A change describing how to move a `NotebookCell` array from state S to S'. - @since 3.17.0""" + @since 3.17.0 + """ start: Uint """ The start oftest of the cell that changed. """ deleteCount: Uint """ The deleted cells """ - cells: NotRequired[List["NotebookCell"]] + cells: NotRequired[list["NotebookCell"]] """ The new cells, if any """ @@ -4350,9 +4415,10 @@ class NotebookDocumentSyncOptions(TypedDict): document that contain at least one matching cell will be synced. - @since 3.17.0""" + @since 3.17.0 + """ - notebookSelector: List[ + notebookSelector: list[ Union[ "__NotebookDocumentSyncOptions_notebookSelector_Type_1", "__NotebookDocumentSyncOptions_notebookSelector_Type_2", @@ -4367,9 +4433,10 @@ class NotebookDocumentSyncOptions(TypedDict): class NotebookDocumentSyncRegistrationOptions(TypedDict): """Registration options specific to a notebook. - @since 3.17.0""" + @since 3.17.0 + """ - notebookSelector: List[ + notebookSelector: list[ Union[ "__NotebookDocumentSyncOptions_notebookSelector_Type_3", "__NotebookDocumentSyncOptions_notebookSelector_Type_4", @@ -4387,7 +4454,7 @@ class NotebookDocumentSyncRegistrationOptions(TypedDict): class WorkspaceFoldersServerCapabilities(TypedDict): supported: NotRequired[bool] """ The server has support for workspace folders """ - changeNotifications: NotRequired[Union[str, bool]] + changeNotifications: NotRequired[str | bool] """ Whether the server wants to receive workspace folder change notifications. @@ -4400,7 +4467,8 @@ class WorkspaceFoldersServerCapabilities(TypedDict): class FileOperationOptions(TypedDict): """Options for notifications/requests for user operations on files. - @since 3.16.0""" + @since 3.16.0 + """ didCreate: NotRequired["FileOperationRegistrationOptions"] """ The server is interested in receiving didCreateFiles notifications. """ @@ -4419,7 +4487,8 @@ class FileOperationOptions(TypedDict): class CodeDescription(TypedDict): """Structure to capture a description for an error code. - @since 3.16.0""" + @since 3.16.0 + """ href: "URI" """ An URI to open with more information about the diagnostic error. """ @@ -4428,7 +4497,8 @@ class CodeDescription(TypedDict): class DiagnosticRelatedInformation(TypedDict): """Represents a related message and source code location for a diagnostic. This should be used to point to code locations that cause or related to a diagnostics, e.g when duplicating - a symbol in a scope.""" + a symbol in a scope. + """ location: "Location" """ The location of this related diagnostic information. """ @@ -4438,9 +4508,10 @@ class DiagnosticRelatedInformation(TypedDict): class ParameterInformation(TypedDict): """Represents a parameter of a callable-signature. A parameter can - have a label and a doc-comment.""" + have a label and a doc-comment. + """ - label: Union[str, List[Union[Uint, Uint]]] + label: str | list[Uint | Uint] """ The label of this parameter information. Either a string or an inclusive start and exclusive end offsets within its containing @@ -4458,7 +4529,8 @@ class NotebookCellTextDocumentFilter(TypedDict): """A notebook cell text document filter denotes a cell text document by different properties. - @since 3.17.0""" + @since 3.17.0 + """ notebook: Union[str, "NotebookDocumentFilter"] """ A filter that matches against the notebook @@ -4475,7 +4547,8 @@ class NotebookCellTextDocumentFilter(TypedDict): class FileOperationPatternOptions(TypedDict): """Matching options for the file operation pattern. - @since 3.16.0""" + @since 3.16.0 + """ ignoreCase: NotRequired[bool] """ The pattern should be matched ignoring casing. """ @@ -4644,7 +4717,8 @@ class TextDocumentClientCapabilities(TypedDict): class NotebookDocumentClientCapabilities(TypedDict): """Capabilities specific to the notebook document support. - @since 3.17.0""" + @since 3.17.0 + """ synchronization: "NotebookDocumentSyncClientCapabilities" """ Capabilities specific to notebook document synchronization @@ -4676,11 +4750,10 @@ class WindowClientCapabilities(TypedDict): class GeneralClientCapabilities(TypedDict): """General client capabilities. - @since 3.16.0""" + @since 3.16.0 + """ - staleRequestSupport: NotRequired[ - "__GeneralClientCapabilities_staleRequestSupport_Type_1" - ] + staleRequestSupport: NotRequired["__GeneralClientCapabilities_staleRequestSupport_Type_1"] """ Client capability that signals how the client handles stale requests (e.g. a request for which the client will not process the response @@ -4695,7 +4768,7 @@ class GeneralClientCapabilities(TypedDict): """ Client capabilities specific to the client's markdown parser. @since 3.16.0 """ - positionEncodings: NotRequired[List["PositionEncodingKind"]] + positionEncodings: NotRequired[list["PositionEncodingKind"]] """ The position encodings supported by the client. Client and server have to agree on the same position encoding to ensure that offsets (e.g. character position in a line) are interpreted the same on both @@ -4721,7 +4794,8 @@ class RelativePattern(TypedDict): relatively to a base URI. The common value for a `baseUri` is a workspace folder root, but it can be another absolute URI as well. - @since 3.17.0""" + @since 3.17.0 + """ baseUri: Union["WorkspaceFolder", "URI"] """ A workspace folder or a base URI to which this pattern will be matched @@ -4733,7 +4807,7 @@ class RelativePattern(TypedDict): class WorkspaceEditClientCapabilities(TypedDict): documentChanges: NotRequired[bool] """ The client supports versioned document changes in `WorkspaceEdit`s """ - resourceOperations: NotRequired[List["ResourceOperationKind"]] + resourceOperations: NotRequired[list["ResourceOperationKind"]] """ The resource operations the client supports. Clients should at least support 'create', 'rename' and 'delete' files and folders. @@ -4751,9 +4825,7 @@ class WorkspaceEditClientCapabilities(TypedDict): character. @since 3.16.0 """ - changeAnnotationSupport: NotRequired[ - "__WorkspaceEditClientCapabilities_changeAnnotationSupport_Type_1" - ] + changeAnnotationSupport: NotRequired["__WorkspaceEditClientCapabilities_changeAnnotationSupport_Type_1"] """ Whether the client in general supports change annotations on text edits, create file, rename file and delete file changes. @@ -4789,9 +4861,7 @@ class WorkspaceSymbolClientCapabilities(TypedDict): Clients supporting tags have to handle unknown tags gracefully. @since 3.16.0 """ - resolveSupport: NotRequired[ - "__WorkspaceSymbolClientCapabilities_resolveSupport_Type_1" - ] + resolveSupport: NotRequired["__WorkspaceSymbolClientCapabilities_resolveSupport_Type_1"] """ The client support partial workspace symbols. The client will send the request `workspaceSymbol/resolve` to the server to resolve additional properties. @@ -4838,7 +4908,8 @@ class FileOperationClientCapabilities(TypedDict): These events do not come from the file system, they come from user operations like renaming a file in the UI. - @since 3.16.0""" + @since 3.16.0 + """ dynamicRegistration: NotRequired[bool] """ Whether the client supports dynamic registration for file requests/notifications. """ @@ -4859,7 +4930,8 @@ class FileOperationClientCapabilities(TypedDict): class InlineValueWorkspaceClientCapabilities(TypedDict): """Client workspace capabilities specific to inline values. - @since 3.17.0""" + @since 3.17.0 + """ refreshSupport: NotRequired[bool] """ Whether the client implementation supports a refresh request sent from the @@ -4874,7 +4946,8 @@ class InlineValueWorkspaceClientCapabilities(TypedDict): class InlayHintWorkspaceClientCapabilities(TypedDict): """Client workspace capabilities specific to inlay hints. - @since 3.17.0""" + @since 3.17.0 + """ refreshSupport: NotRequired[bool] """ Whether the client implementation supports a refresh request sent from @@ -4889,7 +4962,8 @@ class InlayHintWorkspaceClientCapabilities(TypedDict): class DiagnosticWorkspaceClientCapabilities(TypedDict): """Workspace client capabilities specific to diagnostic pull requests. - @since 3.17.0""" + @since 3.17.0 + """ refreshSupport: NotRequired[bool] """ Whether the client implementation supports a refresh request sent from @@ -4922,9 +4996,7 @@ class CompletionClientCapabilities(TypedDict): completionItem: NotRequired["__CompletionClientCapabilities_completionItem_Type_1"] """ The client supports the following `CompletionItem` specific capabilities. """ - completionItemKind: NotRequired[ - "__CompletionClientCapabilities_completionItemKind_Type_1" - ] + completionItemKind: NotRequired["__CompletionClientCapabilities_completionItemKind_Type_1"] insertTextMode: NotRequired["InsertTextMode"] """ Defines how the client handles whitespace and indentation when accepting a completion item that uses multi line @@ -4944,7 +5016,7 @@ class CompletionClientCapabilities(TypedDict): class HoverClientCapabilities(TypedDict): dynamicRegistration: NotRequired[bool] """ Whether hover supports dynamic registration. """ - contentFormat: NotRequired[List["MarkupKind"]] + contentFormat: NotRequired[list["MarkupKind"]] """ Client supports the following content formats for the content property. The order describes the preferred format of the client. """ @@ -4954,9 +5026,7 @@ class SignatureHelpClientCapabilities(TypedDict): dynamicRegistration: NotRequired[bool] """ Whether signature help supports dynamic registration. """ - signatureInformation: NotRequired[ - "__SignatureHelpClientCapabilities_signatureInformation_Type_1" - ] + signatureInformation: NotRequired["__SignatureHelpClientCapabilities_signatureInformation_Type_1"] """ The client supports the following `SignatureInformation` specific properties. """ contextSupport: NotRequired[bool] @@ -5058,9 +5128,7 @@ class CodeActionClientCapabilities(TypedDict): dynamicRegistration: NotRequired[bool] """ Whether code action supports dynamic registration. """ - codeActionLiteralSupport: NotRequired[ - "__CodeActionClientCapabilities_codeActionLiteralSupport_Type_1" - ] + codeActionLiteralSupport: NotRequired["__CodeActionClientCapabilities_codeActionLiteralSupport_Type_1"] """ The client support code action literals of type `CodeAction` as a valid response of the `textDocument/codeAction` request. If the property is not set the request can only return `Command` literals. @@ -5180,9 +5248,7 @@ class FoldingRangeClientCapabilities(TypedDict): """ If set, the client signals that it only supports folding complete lines. If set, client will ignore specified `startCharacter` and `endCharacter` properties in a FoldingRange. """ - foldingRangeKind: NotRequired[ - "__FoldingRangeClientCapabilities_foldingRangeKind_Type_1" - ] + foldingRangeKind: NotRequired["__FoldingRangeClientCapabilities_foldingRangeKind_Type_1"] """ Specific options for the folding range kind. @since 3.17.0 """ @@ -5251,11 +5317,11 @@ class SemanticTokensClientCapabilities(TypedDict): `request.range` are both set to true but the server only provides a range provider the client might not render a minimap correctly or might even decide to not show any semantic tokens at all. """ - tokenTypes: List[str] + tokenTypes: list[str] """ The token types that the client supports. """ - tokenModifiers: List[str] + tokenModifiers: list[str] """ The token modifiers that the client supports. """ - formats: List["TokenFormat"] + formats: list["TokenFormat"] """ The token formats the clients supports. """ overlappingTokenSupport: NotRequired[bool] """ Whether the client supports tokens that can overlap each other. """ @@ -5284,7 +5350,8 @@ class SemanticTokensClientCapabilities(TypedDict): class LinkedEditingRangeClientCapabilities(TypedDict): """Client capabilities for the linked editing range request. - @since 3.16.0""" + @since 3.16.0 + """ dynamicRegistration: NotRequired[bool] """ Whether implementation supports dynamic registration. If this is set to `true` @@ -5295,7 +5362,8 @@ class LinkedEditingRangeClientCapabilities(TypedDict): class MonikerClientCapabilities(TypedDict): """Client capabilities specific to the moniker request. - @since 3.16.0""" + @since 3.16.0 + """ dynamicRegistration: NotRequired[bool] """ Whether moniker supports dynamic registration. If this is set to `true` @@ -5315,7 +5383,8 @@ class TypeHierarchyClientCapabilities(TypedDict): class InlineValueClientCapabilities(TypedDict): """Client capabilities specific to inline values. - @since 3.17.0""" + @since 3.17.0 + """ dynamicRegistration: NotRequired[bool] """ Whether implementation supports dynamic registration for inline value providers. """ @@ -5324,7 +5393,8 @@ class InlineValueClientCapabilities(TypedDict): class InlayHintClientCapabilities(TypedDict): """Inlay hint client capabilities. - @since 3.17.0""" + @since 3.17.0 + """ dynamicRegistration: NotRequired[bool] """ Whether inlay hints support dynamic registration. """ @@ -5336,7 +5406,8 @@ class InlayHintClientCapabilities(TypedDict): class DiagnosticClientCapabilities(TypedDict): """Client capabilities specific to diagnostic pull requests. - @since 3.17.0""" + @since 3.17.0 + """ dynamicRegistration: NotRequired[bool] """ Whether implementation supports dynamic registration. If this is set to `true` @@ -5349,7 +5420,8 @@ class DiagnosticClientCapabilities(TypedDict): class NotebookDocumentSyncClientCapabilities(TypedDict): """Notebook specific client capabilities. - @since 3.17.0""" + @since 3.17.0 + """ dynamicRegistration: NotRequired[bool] """ Whether implementation supports dynamic registration. If this is @@ -5363,16 +5435,15 @@ class NotebookDocumentSyncClientCapabilities(TypedDict): class ShowMessageRequestClientCapabilities(TypedDict): """Show message request client capabilities""" - messageActionItem: NotRequired[ - "__ShowMessageRequestClientCapabilities_messageActionItem_Type_1" - ] + messageActionItem: NotRequired["__ShowMessageRequestClientCapabilities_messageActionItem_Type_1"] """ Capabilities specific to the `MessageActionItem` type. """ class ShowDocumentClientCapabilities(TypedDict): """Client capabilities for the showDocument request. - @since 3.16.0""" + @since 3.16.0 + """ support: bool """ The client has support for the showDocument @@ -5382,7 +5453,8 @@ class ShowDocumentClientCapabilities(TypedDict): class RegularExpressionsClientCapabilities(TypedDict): """Client capabilities specific to regular expressions. - @since 3.16.0""" + @since 3.16.0 + """ engine: str """ The engine's name. """ @@ -5393,13 +5465,14 @@ class RegularExpressionsClientCapabilities(TypedDict): class MarkdownClientCapabilities(TypedDict): """Client capabilities specific to the used markdown parser. - @since 3.16.0""" + @since 3.16.0 + """ parser: str """ The name of the parser. """ version: NotRequired[str] """ The version of the parser. """ - allowedTags: NotRequired[List[str]] + allowedTags: NotRequired[list[str]] """ A list of HTML tags that the client allows / supports in Markdown. @@ -5412,10 +5485,8 @@ class __CodeActionClientCapabilities_codeActionLiteralSupport_Type_1(TypedDict): set. """ -class __CodeActionClientCapabilities_codeActionLiteralSupport_codeActionKind_Type_1( - TypedDict -): - valueSet: List["CodeActionKind"] +class __CodeActionClientCapabilities_codeActionLiteralSupport_codeActionKind_Type_1(TypedDict): + valueSet: list["CodeActionKind"] """ The code action kind values the client supports. When this property exists the client also guarantees that it will handle values outside its set gracefully and falls back @@ -5423,7 +5494,7 @@ class __CodeActionClientCapabilities_codeActionLiteralSupport_codeActionKind_Typ class __CodeActionClientCapabilities_resolveSupport_Type_1(TypedDict): - properties: List[str] + properties: list[str] """ The properties that a client can resolve lazily. """ @@ -5435,7 +5506,7 @@ class __CodeAction_disabled_Type_1(TypedDict): class __CompletionClientCapabilities_completionItemKind_Type_1(TypedDict): - valueSet: NotRequired[List["CompletionItemKind"]] + valueSet: NotRequired[list["CompletionItemKind"]] """ The completion item kind values the client supports. When this property exists the client also guarantees that it will handle values outside its set gracefully and falls back @@ -5456,16 +5527,14 @@ class __CompletionClientCapabilities_completionItem_Type_1(TypedDict): that is typing in one will update others too. """ commitCharactersSupport: NotRequired[bool] """ Client supports commit characters on a completion item. """ - documentationFormat: NotRequired[List["MarkupKind"]] + documentationFormat: NotRequired[list["MarkupKind"]] """ Client supports the following content formats for the documentation property. The order describes the preferred format of the client. """ deprecatedSupport: NotRequired[bool] """ Client supports the deprecated property on a completion item. """ preselectSupport: NotRequired[bool] """ Client supports the preselect property on a completion item. """ - tagSupport: NotRequired[ - "__CompletionClientCapabilities_completionItem_tagSupport_Type_1" - ] + tagSupport: NotRequired["__CompletionClientCapabilities_completionItem_tagSupport_Type_1"] """ Client supports the tag property on a completion item. Clients supporting tags have to handle unknown tags gracefully. Clients especially need to preserve unknown tags when sending a completion item back to the server in @@ -5477,17 +5546,13 @@ class __CompletionClientCapabilities_completionItem_Type_1(TypedDict): completion item is inserted in the text or should replace text. @since 3.16.0 """ - resolveSupport: NotRequired[ - "__CompletionClientCapabilities_completionItem_resolveSupport_Type_1" - ] + resolveSupport: NotRequired["__CompletionClientCapabilities_completionItem_resolveSupport_Type_1"] """ Indicates which properties a client can resolve lazily on a completion item. Before version 3.16.0 only the predefined properties `documentation` and `details` could be resolved lazily. @since 3.16.0 """ - insertTextModeSupport: NotRequired[ - "__CompletionClientCapabilities_completionItem_insertTextModeSupport_Type_1" - ] + insertTextModeSupport: NotRequired["__CompletionClientCapabilities_completionItem_insertTextModeSupport_Type_1"] """ The client supports the `insertTextMode` property on a completion item to override the whitespace handling mode as defined by the client (see `insertTextMode`). @@ -5500,24 +5565,22 @@ class __CompletionClientCapabilities_completionItem_Type_1(TypedDict): @since 3.17.0 """ -class __CompletionClientCapabilities_completionItem_insertTextModeSupport_Type_1( - TypedDict -): - valueSet: List["InsertTextMode"] +class __CompletionClientCapabilities_completionItem_insertTextModeSupport_Type_1(TypedDict): + valueSet: list["InsertTextMode"] class __CompletionClientCapabilities_completionItem_resolveSupport_Type_1(TypedDict): - properties: List[str] + properties: list[str] """ The properties that a client can resolve lazily. """ class __CompletionClientCapabilities_completionItem_tagSupport_Type_1(TypedDict): - valueSet: List["CompletionItemTag"] + valueSet: list["CompletionItemTag"] """ The tags supported by the client. """ class __CompletionClientCapabilities_completionList_Type_1(TypedDict): - itemDefaults: NotRequired[List[str]] + itemDefaults: NotRequired[list[str]] """ The client supports the following itemDefaults on a completion list. @@ -5529,13 +5592,11 @@ class __CompletionClientCapabilities_completionList_Type_1(TypedDict): class __CompletionList_itemDefaults_Type_1(TypedDict): - commitCharacters: NotRequired[List[str]] + commitCharacters: NotRequired[list[str]] """ A default commit character set. @since 3.17.0 """ - editRange: NotRequired[ - Union["Range", "__CompletionList_itemDefaults_editRange_Type_1"] - ] + editRange: NotRequired[Union["Range", "__CompletionList_itemDefaults_editRange_Type_1"]] """ A default edit range. @since 3.17.0 """ @@ -5577,7 +5638,7 @@ class __CompletionOptions_completionItem_Type_2(TypedDict): class __DocumentSymbolClientCapabilities_symbolKind_Type_1(TypedDict): - valueSet: NotRequired[List["SymbolKind"]] + valueSet: NotRequired[list["SymbolKind"]] """ The symbol kind values the client supports. When this property exists the client also guarantees that it will handle values outside its set gracefully and falls back @@ -5589,12 +5650,12 @@ class __DocumentSymbolClientCapabilities_symbolKind_Type_1(TypedDict): class __DocumentSymbolClientCapabilities_tagSupport_Type_1(TypedDict): - valueSet: List["SymbolTag"] + valueSet: list["SymbolTag"] """ The tags supported by the client. """ class __FoldingRangeClientCapabilities_foldingRangeKind_Type_1(TypedDict): - valueSet: NotRequired[List["FoldingRangeKind"]] + valueSet: NotRequired[list["FoldingRangeKind"]] """ The folding range kind values the client supports. When this property exists the client also guarantees that it will handle values outside its set gracefully and falls back @@ -5612,7 +5673,7 @@ class __FoldingRangeClientCapabilities_foldingRange_Type_1(TypedDict): class __GeneralClientCapabilities_staleRequestSupport_Type_1(TypedDict): cancel: bool """ The client will actively cancel the request. """ - retryOnContentModified: List[str] + retryOnContentModified: list[str] """ The list of requests for which the client will retry the request if it receives a response with error code `ContentModified` """ @@ -5626,7 +5687,7 @@ class __InitializeResult_serverInfo_Type_1(TypedDict): class __InlayHintClientCapabilities_resolveSupport_Type_1(TypedDict): - properties: List[str] + properties: list[str] """ The properties that a client can resolve lazily. """ @@ -5639,27 +5700,25 @@ class __NotebookDocumentChangeEvent_cells_Type_1(TypedDict): structure: NotRequired["__NotebookDocumentChangeEvent_cells_structure_Type_1"] """ Changes to the cell structure to add or remove cells. """ - data: NotRequired[List["NotebookCell"]] + data: NotRequired[list["NotebookCell"]] """ Changes to notebook cells properties like its kind, execution summary or metadata. """ - textContent: NotRequired[ - List["__NotebookDocumentChangeEvent_cells_textContent_Type_1"] - ] + textContent: NotRequired[list["__NotebookDocumentChangeEvent_cells_textContent_Type_1"]] """ Changes to the text content of notebook cells. """ class __NotebookDocumentChangeEvent_cells_structure_Type_1(TypedDict): array: "NotebookCellArrayChange" """ The change to the cell array. """ - didOpen: NotRequired[List["TextDocumentItem"]] + didOpen: NotRequired[list["TextDocumentItem"]] """ Additional opened cell text documents. """ - didClose: NotRequired[List["TextDocumentIdentifier"]] + didClose: NotRequired[list["TextDocumentIdentifier"]] """ Additional closed cell text documents. """ class __NotebookDocumentChangeEvent_cells_textContent_Type_1(TypedDict): document: "VersionedTextDocumentIdentifier" - changes: List["TextDocumentContentChangeEvent"] + changes: list["TextDocumentContentChangeEvent"] class __NotebookDocumentFilter_Type_1(TypedDict): @@ -5694,9 +5753,7 @@ class __NotebookDocumentSyncOptions_notebookSelector_Type_1(TypedDict): """ The notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. """ - cells: NotRequired[ - List["__NotebookDocumentSyncOptions_notebookSelector_cells_Type_1"] - ] + cells: NotRequired[list["__NotebookDocumentSyncOptions_notebookSelector_cells_Type_1"]] """ The cells of the matching notebook to be synced. """ @@ -5705,7 +5762,7 @@ class __NotebookDocumentSyncOptions_notebookSelector_Type_2(TypedDict): """ The notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. """ - cells: List["__NotebookDocumentSyncOptions_notebookSelector_cells_Type_2"] + cells: list["__NotebookDocumentSyncOptions_notebookSelector_cells_Type_2"] """ The cells of the matching notebook to be synced. """ @@ -5714,9 +5771,7 @@ class __NotebookDocumentSyncOptions_notebookSelector_Type_3(TypedDict): """ The notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. """ - cells: NotRequired[ - List["__NotebookDocumentSyncOptions_notebookSelector_cells_Type_3"] - ] + cells: NotRequired[list["__NotebookDocumentSyncOptions_notebookSelector_cells_Type_3"]] """ The cells of the matching notebook to be synced. """ @@ -5725,7 +5780,7 @@ class __NotebookDocumentSyncOptions_notebookSelector_Type_4(TypedDict): """ The notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. """ - cells: List["__NotebookDocumentSyncOptions_notebookSelector_cells_Type_4"] + cells: list["__NotebookDocumentSyncOptions_notebookSelector_cells_Type_4"] """ The cells of the matching notebook to be synced. """ @@ -5755,17 +5810,15 @@ class __PrepareRenameResult_Type_2(TypedDict): class __PublishDiagnosticsClientCapabilities_tagSupport_Type_1(TypedDict): - valueSet: List["DiagnosticTag"] + valueSet: list["DiagnosticTag"] """ The tags supported by the client. """ class __SemanticTokensClientCapabilities_requests_Type_1(TypedDict): - range: NotRequired[Union[bool, dict]] + range: NotRequired[bool | dict] """ The client will send the `textDocument/semanticTokens/range` request if the server provides a corresponding handler. """ - full: NotRequired[ - Union[bool, "__SemanticTokensClientCapabilities_requests_full_Type_1"] - ] + full: NotRequired[Union[bool, "__SemanticTokensClientCapabilities_requests_full_Type_1"]] """ The client will send the `textDocument/semanticTokens/full` request if the server provides a corresponding handler. """ @@ -5805,12 +5858,10 @@ class __ShowMessageRequestClientCapabilities_messageActionItem_Type_1(TypedDict) class __SignatureHelpClientCapabilities_signatureInformation_Type_1(TypedDict): - documentationFormat: NotRequired[List["MarkupKind"]] + documentationFormat: NotRequired[list["MarkupKind"]] """ Client supports the following content formats for the documentation property. The order describes the preferred format of the client. """ - parameterInformation: NotRequired[ - "__SignatureHelpClientCapabilities_signatureInformation_parameterInformation_Type_1" - ] + parameterInformation: NotRequired["__SignatureHelpClientCapabilities_signatureInformation_parameterInformation_Type_1"] """ Client capabilities specific to parameter information. """ activeParameterSupport: NotRequired[bool] """ The client supports the `activeParameter` property on `SignatureInformation` @@ -5819,9 +5870,7 @@ class __SignatureHelpClientCapabilities_signatureInformation_Type_1(TypedDict): @since 3.16.0 """ -class __SignatureHelpClientCapabilities_signatureInformation_parameterInformation_Type_1( - TypedDict -): +class __SignatureHelpClientCapabilities_signatureInformation_parameterInformation_Type_1(TypedDict): labelOffsetSupport: NotRequired[bool] """ The client supports processing label offsets instead of a simple label string. @@ -5880,13 +5929,13 @@ class __WorkspaceEditClientCapabilities_changeAnnotationSupport_Type_1(TypedDict class __WorkspaceSymbolClientCapabilities_resolveSupport_Type_1(TypedDict): - properties: List[str] + properties: list[str] """ The properties that a client can resolve lazily. Usually `location.range` """ class __WorkspaceSymbolClientCapabilities_symbolKind_Type_1(TypedDict): - valueSet: NotRequired[List["SymbolKind"]] + valueSet: NotRequired[list["SymbolKind"]] """ The symbol kind values the client supports. When this property exists the client also guarantees that it will handle values outside its set gracefully and falls back @@ -5898,7 +5947,7 @@ class __WorkspaceSymbolClientCapabilities_symbolKind_Type_1(TypedDict): class __WorkspaceSymbolClientCapabilities_tagSupport_Type_1(TypedDict): - valueSet: List["SymbolTag"] + valueSet: list["SymbolTag"] """ The tags supported by the client. """ diff --git a/src/solidlsp/lsp_protocol_handler/server.py b/src/solidlsp/lsp_protocol_handler/server.py index a224143..c628d43 100644 --- a/src/solidlsp/lsp_protocol_handler/server.py +++ b/src/solidlsp/lsp_protocol_handler/server.py @@ -1,8 +1,8 @@ """ -This file provides the implementation of the JSON-RPC client, that launches and +This file provides the implementation of the JSON-RPC client, that launches and communicates with the language server. -The initial implementation of this file was obtained from +The initial implementation of this file was obtained from https://github.com/predragnikolic/OLSP under the MIT License with the following terms: MIT License @@ -34,16 +34,17 @@ import json import logging import os import threading +from collections.abc import Callable +from typing import Any, Union import psutil -from typing import Any, Callable, Dict, List, Optional, Union +from ..multilspy_exceptions import MultilspyException from .lsp_requests import LspNotification, LspRequest from .lsp_types import ErrorCodes -from ..multilspy_exceptions import MultilspyException -StringDict = Dict[str, Any] -PayloadLike = Union[List[StringDict], StringDict, None] +StringDict = dict[str, Any] +PayloadLike = Union[list[StringDict], StringDict, None] CONTENT_LENGTH = "Content-Length: " ENCODING = "utf-8" log = logging.getLogger(__name__) @@ -59,7 +60,7 @@ class ProcessLaunchInfo: cmd: str # The environment variables to set for the process - env: Dict[str, str] = dataclasses.field(default_factory=dict) + env: dict[str, str] = dataclasses.field(default_factory=dict) # The working directory for the process cwd: str = os.getcwd() @@ -120,8 +121,8 @@ class MessageType: class Request: def __init__(self) -> None: self.cv = asyncio.Condition() - self.result: Optional[PayloadLike] = None - self.error: Optional[Error] = None + self.result: PayloadLike | None = None + self.error: Error | None = None async def on_result(self, params: PayloadLike) -> None: self.result = params @@ -134,14 +135,14 @@ class Request: self.cv.notify() -def content_length(line: bytes) -> Optional[int]: +def content_length(line: bytes) -> int | None: if line.startswith(b"Content-Length: "): _, value = line.split(b"Content-Length: ") value = value.strip() try: return int(value) except ValueError: - raise ValueError("Invalid Content-Length header: {}".format(value)) + raise ValueError(f"Invalid Content-Length header: {value}") return None @@ -181,12 +182,13 @@ class LanguageServerHandler: language server process in an independent process group. Default is `True`. Setting it to `False` means that the language server process will be in the same process group as the the current process, and any SIGINT and SIGTERM signals will be sent to both processes. + """ def __init__( self, process_launch_info: ProcessLaunchInfo, - logger: Optional[Callable[[str, str, StringDict | str], None]] = None, + logger: Callable[[str, str, StringDict | str], None] | None = None, start_independent_lsp_process=True, ) -> None: """ @@ -203,7 +205,7 @@ class LanguageServerHandler: self._received_shutdown = False self.request_id = 1 - self._response_handlers: Dict[Any, Request] = {} + self._response_handlers: dict[Any, Request] = {} self.on_request_handlers = {} self.on_notification_handlers = {} self.logger = logger @@ -218,8 +220,6 @@ class LanguageServerHandler: self._response_handlers_lock = threading.Lock() self._tasks_lock = threading.Lock() - - def is_running(self) -> bool: """ Checks if the language server process is currently running. @@ -250,7 +250,7 @@ class LanguageServerHandler: log.error("Language server has already terminated/could not be started") # Process has already terminated stderr_data = await self.process.stderr.read() - error_message = stderr_data.decode('utf-8', errors='replace') + error_message = stderr_data.decode("utf-8", errors="replace") raise RuntimeError(f"Process terminated immediately with code {self.process.returncode}. Error: {error_message}") self.loop = asyncio.get_event_loop() @@ -262,21 +262,19 @@ class LanguageServerHandler: self.tasks[self.task_counter] = self.loop.create_task(self.run_forever_stderr()) self.task_counter += 1 - - async def stop(self) -> None: """ Sends the terminate signal to the language server process and waits for it to exit, with a timeout, killing it if necessary """ # First cancel all tasks await self._cancel_pending_tasks() - + process = self.process self.process = None - + if not process: return - + # Clean up the process await self._cleanup_process(process) @@ -294,7 +292,7 @@ class LanguageServerHandler: if pending_tasks: try: await asyncio.wait_for(asyncio.gather(*pending_tasks, return_exceptions=True), timeout=5.0) - except (asyncio.TimeoutError, Exception): + except (TimeoutError, Exception): pass # Clear tasks dictionary under lock @@ -306,18 +304,18 @@ class LanguageServerHandler: # Close stdin first to prevent deadlocks # See: https://bugs.python.org/issue35539 self._safely_close_pipe(process.stdin) - + # Terminate/kill the process if it's still running if process.returncode is None: await self._terminate_or_kill_process(process) - + # Close stdout and stderr pipes after process has exited # This is essential to prevent "I/O operation on closed pipe" errors and # "Event loop is closed" errors during garbage collection # See: https://bugs.python.org/issue41320 and https://github.com/python/cpython/issues/88050 self._safely_close_pipe(process.stdout) self._safely_close_pipe(process.stderr) - + # Small delay to ensure OS has released file handles await asyncio.sleep(0.5) @@ -333,11 +331,11 @@ class LanguageServerHandler: """Try to terminate the process gracefully, then forcefully if necessary.""" # First try to terminate the process tree gracefully self._signal_process_tree(process, terminate=True) - + # Wait for the process to exit (with timeout) try: await asyncio.wait_for(process.wait(), timeout=10) - except (asyncio.TimeoutError, Exception): + except (TimeoutError, Exception): # If termination failed, forcefully kill the process tree self._signal_process_tree(process, terminate=False) try: @@ -349,14 +347,14 @@ class LanguageServerHandler: def _signal_process_tree(self, process, terminate=True): """Send signal (terminate or kill) to the process and all its children.""" signal_method = "terminate" if terminate else "kill" - + # Try to get the parent process parent = None try: parent = psutil.Process(process.pid) except (psutil.NoSuchProcess, psutil.AccessDenied, Exception): pass - + # If we have the parent process and it's running, signal the entire tree if parent and parent.is_running(): # Signal children first @@ -365,7 +363,7 @@ class LanguageServerHandler: getattr(child, signal_method)() except (psutil.NoSuchProcess, psutil.AccessDenied, Exception): pass - + # Then signal the parent try: getattr(parent, signal_method)() @@ -378,7 +376,6 @@ class LanguageServerHandler: except Exception: pass - async def shutdown(self) -> None: """ Perform the shutdown sequence for the client, including sending the shutdown request to the server and notifying it of exit @@ -433,7 +430,6 @@ class LanguageServerHandler: pass return self._received_shutdown - async def run_forever_stderr(self) -> None: """ Continuously read from the language server process stderr and log the messages @@ -443,7 +439,7 @@ class LanguageServerHandler: line = await self.process.stderr.readline() if not line: continue - self._log("LSP stderr: " + line.decode(ENCODING, errors='replace')) + self._log("LSP stderr: " + line.decode(ENCODING, errors="replace")) except (BrokenPipeError, ConnectionResetError, StopLoopException): pass @@ -453,7 +449,7 @@ class LanguageServerHandler: """ try: await self._receive_payload(json.loads(body)) - except IOError as ex: + except OSError as ex: self._log(f"malformed {ENCODING}: {ex}") except UnicodeDecodeError as ex: self._log(f"malformed {ENCODING}: {ex}") @@ -479,7 +475,7 @@ class LanguageServerHandler: except Exception as err: self._log(f"Error handling server payload: {err}") - def send_notification(self, method: str, params: Optional[dict] = None) -> None: + def send_notification(self, method: str, params: dict | None = None) -> None: """ Send notification pertaining to the given method to the server with the given parameters """ @@ -491,25 +487,19 @@ class LanguageServerHandler: """ # Use lock to prevent race conditions on tasks and task_counter with self._tasks_lock: - self.tasks[self.task_counter] = asyncio.get_event_loop().create_task( - self._send_payload(make_response(request_id, params)) - ) + self.tasks[self.task_counter] = asyncio.get_event_loop().create_task(self._send_payload(make_response(request_id, params))) self.task_counter += 1 - def send_error_response(self, request_id: Any, err: Error) -> None: """ Send error response to the given request id to the server with the given error """ # Use lock to prevent race conditions on tasks and task_counter with self._tasks_lock: - self.tasks[self.task_counter] = asyncio.get_event_loop().create_task( - self._send_payload(make_error_response(request_id, err)) - ) + self.tasks[self.task_counter] = asyncio.get_event_loop().create_task(self._send_payload(make_error_response(request_id, err))) self.task_counter += 1 - - async def send_request(self, method: str, params: Optional[dict] = None) -> PayloadLike: + async def send_request(self, method: str, params: dict | None = None) -> PayloadLike: """ Send request to the server, register the request id, and wait for the response """ @@ -527,13 +517,14 @@ class LanguageServerHandler: await self._send_payload(make_request(method, request_id, params)) self._log(f"Waiting for asyncio condition for request {method} with params:\n{params}") await request.cv.wait() - self._log(f"Finished waiting, processing result") + self._log("Finished waiting, processing result") if isinstance(request.error, Error): - raise MultilspyException(f"Could not process request {method} with params:\n{params}.\n Language server error: {request.error}") from request.error + raise MultilspyException( + f"Could not process request {method} with params:\n{params}.\n Language server error: {request.error}" + ) from request.error self._log(f"Returning non-error result, which is:\n{request.result}") return request.result - def _send_payload_sync(self, payload: StringDict) -> None: """ Send the payload to the server by writing to its stdin synchronously @@ -554,7 +545,6 @@ class LanguageServerHandler: self.logger("client", "logger", f"Failed to write to stdin: {e}") return - async def _send_payload(self, payload: StringDict) -> None: """ Send the payload to the server by writing to its stdin asynchronously. @@ -575,7 +565,6 @@ class LanguageServerHandler: self.logger("client", "logger", f"Failed to write to stdin: {e}") return - def on_request(self, method: str, cb) -> None: """ Register the callback function to handle requests from the server to the client for the given method @@ -602,7 +591,6 @@ class LanguageServerHandler: else: await request.on_error(Error(ErrorCodes.InvalidRequest, "")) - async def _request_handler(self, response: StringDict) -> None: """ Handle the request received from the server: call the appropriate callback function and return the result @@ -616,7 +604,7 @@ class LanguageServerHandler: request_id, Error( ErrorCodes.MethodNotFound, - "method '{}' not handled on client.".format(method), + f"method '{method}' not handled on client.", ), ) return diff --git a/src/solidlsp/multilspy_config.py b/src/solidlsp/multilspy_config.py index c1d77ae..f676e52 100644 --- a/src/solidlsp/multilspy_config.py +++ b/src/solidlsp/multilspy_config.py @@ -1,10 +1,10 @@ """ Configuration parameters for Multilspy. """ + import fnmatch -from enum import Enum -from typing import List from dataclasses import dataclass, field +from enum import Enum class FilenameMatcher: @@ -77,6 +77,7 @@ class MultilspyConfig: """ Configuration parameters """ + code_language: Language trace_lsp_communication: bool = False start_independent_lsp_process: bool = True @@ -89,7 +90,5 @@ class MultilspyConfig: Create a MultilspyConfig instance from a dictionary """ import inspect - return cls(**{ - k: v for k, v in env.items() - if k in inspect.signature(cls).parameters - }) + + return cls(**{k: v for k, v in env.items() if k in inspect.signature(cls).parameters}) diff --git a/src/solidlsp/multilspy_exceptions.py b/src/solidlsp/multilspy_exceptions.py index d645d13..1dc12ed 100644 --- a/src/solidlsp/multilspy_exceptions.py +++ b/src/solidlsp/multilspy_exceptions.py @@ -2,6 +2,7 @@ This module contains the exceptions raised by the Multilspy framework. """ + class MultilspyException(Exception): """ Exceptions raised by the Multilspy framework. @@ -11,4 +12,4 @@ class MultilspyException(Exception): """ Initializes the exception with the given message. """ - super().__init__(message) \ No newline at end of file + super().__init__(message) diff --git a/src/solidlsp/multilspy_logger.py b/src/solidlsp/multilspy_logger.py index c6135a5..993aa3b 100644 --- a/src/solidlsp/multilspy_logger.py +++ b/src/solidlsp/multilspy_logger.py @@ -1,9 +1,11 @@ """ Multilspy logger module. """ + import inspect import logging from datetime import datetime + from pydantic import BaseModel @@ -34,7 +36,6 @@ class MultilspyLogger: """ Log the debug and sanitized messages using the logger """ - debug_message = debug_message.replace("'", '"').replace("\n", " ") sanitized_error_message = sanitized_error_message.replace("'", '"').replace("\n", " ") diff --git a/src/solidlsp/multilspy_settings.py b/src/solidlsp/multilspy_settings.py index 5d7ebfa..b404030 100644 --- a/src/solidlsp/multilspy_settings.py +++ b/src/solidlsp/multilspy_settings.py @@ -5,10 +5,12 @@ Defines the settings for multilspy. import os import pathlib + class MultilspySettings: """ Provides the various settings for multilspy. """ + @staticmethod def get_language_server_directory() -> str: """Returns the directory for language servers""" diff --git a/src/solidlsp/multilspy_types.py b/src/solidlsp/multilspy_types.py index dad0116..3d4d465 100644 --- a/src/solidlsp/multilspy_types.py +++ b/src/solidlsp/multilspy_types.py @@ -4,16 +4,19 @@ Defines wrapper objects around the types returned by LSP to ensure decoupling be from __future__ import annotations -from enum import IntEnum, Enum -from typing_extensions import NotRequired, TypedDict, List, Dict, Union +from enum import Enum, IntEnum +from typing import NotRequired, Union + +from typing_extensions import TypedDict URI = str DocumentUri = str Uint = int RegExp = str + class Position(TypedDict): - """Position in a text document expressed as zero-based line and character + r"""Position in a text document expressed as zero-based line and character offset. Prior to 3.17 the offsets were always based on a UTF-16 string representation. So a string of the form `a𐐀b` the character offset of the character `a` is 0, the character offset of `𐐀` is 1 and the character @@ -39,7 +42,8 @@ class Position(TypedDict): Positions are line end character agnostic. So you can not specify a position that denotes `\r|\n` or `\n|` where `|` represents the character offset. - @since 3.17.0 - support for negotiated position encoding.""" + @since 3.17.0 - support for negotiated position encoding. + """ line: Uint """ Line position in a document (zero-based). @@ -67,7 +71,8 @@ class Range(TypedDict): start: { line: 5, character: 23 } end : { line 6, character : 0 } } - ```""" + ``` + """ start: Position """ The range's start position. """ @@ -77,12 +82,14 @@ class Range(TypedDict): class Location(TypedDict): """Represents a location inside a resource, such as a line - inside a text file.""" + inside a text file. + """ uri: DocumentUri range: Range absolutePath: str - relativePath: Union[str, None] + relativePath: str | None + class CompletionItemKind(IntEnum): """The kind of a completion entry.""" @@ -113,9 +120,11 @@ class CompletionItemKind(IntEnum): Operator = 24 TypeParameter = 25 + class CompletionItem(TypedDict): """A completion item represents a text snippet that is - proposed to complete text that is being typed.""" + proposed to complete text that is being typed. + """ completionText: str """ The completionText of this completion item. @@ -131,6 +140,7 @@ class CompletionItem(TypedDict): """ A human-readable string with additional information about this item, like type or symbol information. """ + class SymbolKind(IntEnum): """A symbol kind.""" @@ -161,17 +171,21 @@ class SymbolKind(IntEnum): Operator = 25 TypeParameter = 26 + class SymbolTag(IntEnum): """Symbol tags are extra annotations that tweak the rendering of a symbol. - @since 3.16""" + @since 3.16 + """ Deprecated = 1 """ Render a symbol as obsolete, usually using a strike-out. """ + class UnifiedSymbolInformation(TypedDict): """Represents information about programming constructs like variables, classes, - interfaces etc.""" + interfaces etc. + """ deprecated: NotRequired[bool] """ Indicates if this symbol is deprecated. @@ -191,7 +205,7 @@ class UnifiedSymbolInformation(TypedDict): """ The name of this symbol. """ kind: SymbolKind """ The kind of this symbol. """ - tags: NotRequired[List[SymbolTag]] + tags: NotRequired[list[SymbolTag]] """ Tags for this symbol. @since 3.16.0 """ @@ -207,7 +221,7 @@ class UnifiedSymbolInformation(TypedDict): detail: NotRequired[str] """ More detail for this symbol, e.g the signature of a function. """ - + range: NotRequired[Range] """ The range enclosing this symbol not including leading/trailing whitespace but everything else like comments. This information is typically used to determine if the clients cursor is @@ -215,37 +229,40 @@ class UnifiedSymbolInformation(TypedDict): selectionRange: NotRequired[Range] """ The range that should be selected and revealed when this symbol is being picked, e.g the name of a function. Must be contained by the `range`. """ - + body: NotRequired[str] """ The body of the symbol. """ - - children: List[UnifiedSymbolInformation] + + children: list[UnifiedSymbolInformation] """ The children of the symbol. Added to be compatible with `lsp_types.DocumentSymbol`, since it is sometimes useful to have the children of the symbol as a user-facing feature.""" - + parent: NotRequired[UnifiedSymbolInformation | None] """The parent of the symbol, if there is any. Added with Serena, not part of the LSP. All symbols except the root packages will have a parent. """ - + class MarkupKind(Enum): """Describes the content type that a client supports in various result literals like `Hover`, `ParameterInfo` or `CompletionItem`. Please note that `MarkupKinds` must not start with a `$`. This kinds - are reserved for internal usage.""" + are reserved for internal usage. + """ PlainText = "plaintext" """ Plain text is supported as a content format """ Markdown = "markdown" """ Markdown is supported as a content format """ + class __MarkedString_Type_1(TypedDict): language: str value: str + MarkedString = Union[str, "__MarkedString_Type_1"] """ MarkedString can be used to render human readable text. It is either a markdown string or a code-block that provides a language and a code snippet. The language identifier @@ -260,8 +277,9 @@ ${value} Note that markdown strings will be sanitized - that means html will be escaped. @deprecated use MarkupContent instead. """ + class MarkupContent(TypedDict): - """A `MarkupContent` literal represents a string value which content is interpreted base on its + r"""A `MarkupContent` literal represents a string value which content is interpreted base on its kind flag. Currently the protocol supports `plaintext` and `markdown` as markup kinds. If the kind is `markdown` then the value can contain fenced code blocks like in GitHub issues. @@ -282,18 +300,20 @@ class MarkupContent(TypedDict): ``` *Please Note* that clients might sanitize the return markdown. A client could decide to - remove HTML from the markdown to avoid script execution.""" + remove HTML from the markdown to avoid script execution. + """ - kind: "MarkupKind" + kind: MarkupKind """ The type of the Markup """ value: str """ The content itself """ + class Hover(TypedDict): """The result of a hover request.""" - contents: Union["MarkupContent", "MarkedString", List["MarkedString"]] + contents: MarkupContent | MarkedString | list[MarkedString] """ The hover's content """ - range: NotRequired["Range"] + range: NotRequired[Range] """ An optional range inside the text document that is used to - visualize the hover, e.g. by changing the background color. """ \ No newline at end of file + visualize the hover, e.g. by changing the background color. """ diff --git a/src/solidlsp/multilspy_utils.py b/src/solidlsp/multilspy_utils.py index 92cca5f..e1b71c2 100644 --- a/src/solidlsp/multilspy_utils.py +++ b/src/solidlsp/multilspy_utils.py @@ -5,17 +5,16 @@ This file contains various utility functions like I/O operations, handling paths import gzip import logging import os -from typing import Tuple, Union -import requests -import shutil -import uuid - import platform +import shutil import subprocess +import uuid from enum import Enum +from pathlib import Path, PurePath + +import requests from solidlsp.multilspy_exceptions import MultilspyException -from pathlib import PurePath, Path from solidlsp.multilspy_logger import MultilspyLogger from solidlsp.multilspy_types import UnifiedSymbolInformation @@ -24,8 +23,9 @@ class TextUtils: """ Utilities for text operations. """ + @staticmethod - def get_line_col_from_index(text: str, index: int) -> Tuple[int, int]: + def get_line_col_from_index(text: str, index: int) -> tuple[int, int]: """ Returns the zero-indexed line and column number of the given index in the given text """ @@ -33,7 +33,7 @@ class TextUtils: c = 0 idx = 0 while idx < index: - if text[idx] == '\n': + if text[idx] == "\n": l += 1 c = 0 else: @@ -41,7 +41,7 @@ class TextUtils: idx += 1 return l, c - + @staticmethod def get_index_from_line_col(text: str, line: int, col: int) -> int: """ @@ -55,35 +55,35 @@ class TextUtils: idx += 1 idx += col return idx - + @staticmethod - def _get_updated_position_from_line_and_column_and_edit(l: int, c: int, text_to_be_inserted: str) -> Tuple[int, int]: + def _get_updated_position_from_line_and_column_and_edit(l: int, c: int, text_to_be_inserted: str) -> tuple[int, int]: """ Utility function to get the position of the cursor after inserting text at a given line and column. """ - num_newlines_in_gen_text = text_to_be_inserted.count('\n') + num_newlines_in_gen_text = text_to_be_inserted.count("\n") if num_newlines_in_gen_text > 0: l += num_newlines_in_gen_text - c = len(text_to_be_inserted.split('\n')[-1]) + c = len(text_to_be_inserted.split("\n")[-1]) else: c += len(text_to_be_inserted) return (l, c) - + @staticmethod - def delete_text_between_positions(text: str, start_line: int, start_col: int, end_line: int, end_col: int) -> Tuple[str, str]: + def delete_text_between_positions(text: str, start_line: int, start_col: int, end_line: int, end_col: int) -> tuple[str, str]: """ Deletes the text between the given start and end positions. Returns the modified text and the deleted text. """ del_start_idx = TextUtils.get_index_from_line_col(text, start_line, start_col) del_end_idx = TextUtils.get_index_from_line_col(text, end_line, end_col) - + deleted_text = text[del_start_idx:del_end_idx] new_text = text[:del_start_idx] + text[del_end_idx:] return new_text, deleted_text - + @staticmethod - def insert_text_at_position(text: str, line: int, col: int, text_to_be_inserted: str) -> Tuple[str, int, int]: + def insert_text_at_position(text: str, line: int, col: int, text_to_be_inserted: str) -> tuple[str, int, int]: """ Inserts the given text at the given line and column. Returns the modified text and the new line and column. @@ -98,6 +98,7 @@ class PathUtils: """ Utilities for platform-agnostic path operations. """ + @staticmethod def uri_to_path(uri: str) -> str: """ @@ -106,14 +107,15 @@ class PathUtils: This method was obtained from https://stackoverflow.com/a/61922504 """ try: - from urllib.parse import urlparse, unquote + from urllib.parse import unquote, urlparse from urllib.request import url2pathname except ImportError: # backwards compatibility - from urlparse import urlparse from urllib import unquote, url2pathname + + from urlparse import urlparse parsed = urlparse(uri) - host = "{0}{0}{mnt}{0}".format(os.path.sep, mnt=parsed.netloc) + host = f"{os.path.sep}{os.path.sep}{parsed.netloc}{os.path.sep}" return os.path.normpath(os.path.join(host, url2pathname(unquote(parsed.path)))) @staticmethod @@ -126,10 +128,10 @@ class PathUtils: @staticmethod def is_glob_pattern(pattern: str) -> bool: """Check if a pattern contains glob-specific characters.""" - return any(c in pattern for c in '*?[]!') + return any(c in pattern for c in "*?[]!") @staticmethod - def get_relative_path(path: str, base_path: str) -> Union[str, None]: + def get_relative_path(path: str, base_path: str) -> str | None: """ Gets relative path if it's possible (paths should be on the same drive), returns `None` otherwise. @@ -153,12 +155,12 @@ class FileUtils: logger.log(f"File read '{file_path}' failed: File does not exist.", logging.ERROR) raise MultilspyException(f"File read '{file_path}' failed: File does not exist.") try: - with open(file_path, "r", encoding="utf-8") as inp_file: + with open(file_path, encoding="utf-8") as inp_file: return inp_file.read() except Exception as exc: logger.log(f"File read '{file_path}' failed to read with encoding 'utf-8': {exc}", logging.ERROR) raise MultilspyException("File read failed.") from None - + @staticmethod def download_file(logger: MultilspyLogger, url: str, target_path: str) -> None: """ @@ -215,6 +217,7 @@ class PlatformId(str, Enum): """ multilspy supported platforms """ + WIN_x86 = "win-x86" WIN_x64 = "win-x64" WIN_arm64 = "win-arm64" @@ -232,6 +235,7 @@ class DotnetVersion(str, Enum): """ multilspy supported dotnet versions """ + V4 = "4" V6 = "6" V7 = "7" @@ -260,7 +264,7 @@ class PlatformUtils: platform_id = system_map[system] + "-" + machine_map[machine] if system == "Linux" and bitness == "64bit": libc = platform.libc_ver()[0] - if libc != 'glibc': + if libc != "glibc": platform_id += "-" + libc return PlatformId(platform_id) else: @@ -274,13 +278,13 @@ class PlatformUtils: class SYSTEM_INFO(ctypes.Structure): class _U(ctypes.Union): class _S(ctypes.Structure): - _fields_ = [("wProcessorArchitecture", wintypes.WORD), - ("wReserved", wintypes.WORD)] - _fields_ = [("dwOemId", wintypes.DWORD), - ("s", _S)] + _fields_ = [("wProcessorArchitecture", wintypes.WORD), ("wReserved", wintypes.WORD)] + + _fields_ = [("dwOemId", wintypes.DWORD), ("s", _S)] _anonymous_ = ("s",) - _fields_ = [("u", _U), + _fields_ = [ + ("u", _U), ("dwPageSize", wintypes.DWORD), ("lpMinimumApplicationAddress", wintypes.LPVOID), ("lpMaximumApplicationAddress", wintypes.LPVOID), @@ -289,22 +293,22 @@ class PlatformUtils: ("dwProcessorType", wintypes.DWORD), ("dwAllocationGranularity", wintypes.DWORD), ("wProcessorLevel", wintypes.WORD), - ("wProcessorRevision", wintypes.WORD)] + ("wProcessorRevision", wintypes.WORD), + ] _anonymous_ = ("u",) sys_info = SYSTEM_INFO() ctypes.windll.kernel32.GetNativeSystemInfo(ctypes.byref(sys_info)) arch_map = { - 9: 'AMD64', - 5: 'ARM', - 12: 'arm64', - 6: 'Intel Itanium-based', - 0: 'i386', + 9: "AMD64", + 5: "ARM", + 12: "arm64", + 6: "Intel Itanium-based", + 0: "i386", } - return arch_map.get(sys_info.wProcessorArchitecture, f'Unknown ({sys_info.wProcessorArchitecture})') - + return arch_map.get(sys_info.wProcessorArchitecture, f"Unknown ({sys_info.wProcessorArchitecture})") @staticmethod def get_dotnet_version() -> DotnetVersion: @@ -314,14 +318,14 @@ class PlatformUtils: try: result = subprocess.run(["dotnet", "--list-runtimes"], capture_output=True, check=True) available_version_cmd_output = [] - for line in result.stdout.decode('utf-8').split('\n'): - if line.startswith('Microsoft.NETCore.App'): - version_cmd_output = line.split(' ')[1] + for line in result.stdout.decode("utf-8").split("\n"): + if line.startswith("Microsoft.NETCore.App"): + version_cmd_output = line.split(" ")[1] available_version_cmd_output.append(version_cmd_output) - + if not available_version_cmd_output: raise MultilspyException("dotnet not found on the system") - + # Check for supported versions in order of preference (latest first) for version_cmd_output in available_version_cmd_output: if version_cmd_output.startswith("8"): @@ -335,9 +339,11 @@ class PlatformUtils: for version_cmd_output in available_version_cmd_output: if version_cmd_output.startswith("4"): return DotnetVersion.V4 - + # If no supported version found, raise exception with all available versions - raise MultilspyException(f"No supported dotnet version found. Available versions: {', '.join(available_version_cmd_output)}. Supported versions: 4, 6, 7, 8") + raise MultilspyException( + f"No supported dotnet version found. Available versions: {', '.join(available_version_cmd_output)}. Supported versions: 4, 6, 7, 8" + ) except (FileNotFoundError, subprocess.CalledProcessError): try: result = subprocess.run(["mono", "--version"], capture_output=True, check=True) @@ -346,7 +352,6 @@ class PlatformUtils: raise MultilspyException("dotnet or mono not found on the system") - class SymbolUtils: @staticmethod def symbol_tree_contains_name(roots: list[UnifiedSymbolInformation], name: str) -> bool: diff --git a/src/solidlsp/type_helpers.py b/src/solidlsp/type_helpers.py index 0a805e4..53a10de 100644 --- a/src/solidlsp/type_helpers.py +++ b/src/solidlsp/type_helpers.py @@ -3,14 +3,15 @@ This module provides type-helpers used across multilspy implementation """ import inspect - -from typing import Callable, TypeVar, Type +from collections.abc import Callable +from typing import TypeVar R = TypeVar("R", bound=object) + def ensure_all_methods_implemented( - source_cls: Type[object], -) -> Callable[[Type[R]], Type[R]]: + source_cls: type[object], +) -> Callable[[type[R]], type[R]]: """ A decorator to ensure that all methods of source_cls class are implemented in the decorated class. """ @@ -24,4 +25,4 @@ def ensure_all_methods_implemented( return target_cls - return check_all_methods_implemented \ No newline at end of file + return check_all_methods_implemented diff --git a/test/conftest.py b/test/conftest.py index 9630cc6..0eeda4a 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -6,11 +6,11 @@ import pytest from sensai.util.logging import configure from multilspy.language_server import SyncLanguageServer -from solidlsp.multilspy_config import Language, MultilspyConfig -from solidlsp.multilspy_logger import MultilspyLogger from serena.constants import USE_SOLID_LSP from serena.util.file_system import GitignoreParser from solidlsp.ls import SolidLanguageServer +from solidlsp.multilspy_config import Language, MultilspyConfig +from solidlsp.multilspy_logger import MultilspyLogger configure(level=logging.DEBUG) diff --git a/test/multilspy/python/test_python_basic.py b/test/multilspy/python/test_python_basic.py index 20ddabb..a3edbea 100644 --- a/test/multilspy/python/test_python_basic.py +++ b/test/multilspy/python/test_python_basic.py @@ -10,8 +10,8 @@ import os import pytest from multilspy.language_server import SyncLanguageServer -from solidlsp.multilspy_config import Language from serena.text_utils import LineType +from solidlsp.multilspy_config import Language @pytest.mark.python diff --git a/test/serena/test_serena_agent.py b/test/serena/test_serena_agent.py index 1642b38..a31ccd4 100644 --- a/test/serena/test_serena_agent.py +++ b/test/serena/test_serena_agent.py @@ -5,9 +5,9 @@ from dataclasses import dataclass import pytest -from solidlsp.multilspy_config import Language from serena.agent import FindReferencingSymbolsTool, FindSymbolTool, Project, ProjectConfig, SerenaAgent, SerenaConfigBase from serena.process_isolated_agent import ProcessIsolatedSerenaAgent +from solidlsp.multilspy_config import Language from test.conftest import get_repo_path diff --git a/test/serena/test_symbol_editing.py b/test/serena/test_symbol_editing.py index ba00ad1..bf6e2a3 100644 --- a/test/serena/test_symbol_editing.py +++ b/test/serena/test_symbol_editing.py @@ -11,8 +11,8 @@ from typing import Literal import pytest -from solidlsp.multilspy_config import Language from serena.symbol import CodeDiff +from solidlsp.multilspy_config import Language from src.serena.symbol import SymbolManager from test.conftest import create_ls, get_repo_path