Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions generator/plugins/python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def _reset(self):
self._imports: List[str] = [
"import enum",
"import functools",
"from typing import Any, Dict, List, Optional, Tuple, Union",
"from typing import Any, Dict, Optional, Sequence, Tuple, Union",
"import attrs",
"from . import validators",
]
Expand Down Expand Up @@ -271,7 +271,7 @@ def _generate_type_name(
# This is a linear collection type, LSP does not specify if
# this needs to be ordered. Also, usingList here because
# cattrs does not work well withIterable for some reason.
return f"List[{self._generate_type_name(type_def.element, class_name, prefix)}]"
return f"Sequence[{self._generate_type_name(type_def.element, class_name, prefix)}]"

if type_def.kind == "or":
# This type means that you can have either of the types under `items`
Expand Down
39 changes: 26 additions & 13 deletions packages/python/lsprotocol/_hooks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import sys
from typing import Any, List, Optional, Tuple, Union
from typing import Any, List, Optional, Sequence, Tuple, Union

import attrs
import cattrs
Expand Down Expand Up @@ -888,7 +888,7 @@ def _notebook_sync_registration_option_selector_hook(
_inlay_hint_provider_hook,
),
(
Union[str, List[lsp_types.InlayHintLabelPart]],
Union[str, Sequence[lsp_types.InlayHintLabelPart]],
_inlay_hint_label_part_hook,
),
(
Expand All @@ -908,22 +908,27 @@ def _notebook_sync_registration_option_selector_hook(
_code_action_hook,
),
(
Optional[Union[List[lsp_types.CompletionItem], lsp_types.CompletionList]],
Optional[
Union[Sequence[lsp_types.CompletionItem], lsp_types.CompletionList]
],
_completion_list_hook,
),
(
Optional[
Union[
lsp_types.Location,
List[lsp_types.Location],
List[lsp_types.LocationLink],
Sequence[lsp_types.Location],
Sequence[lsp_types.LocationLink],
]
],
_location_hook,
),
(
Optional[
Union[List[lsp_types.SymbolInformation], List[lsp_types.DocumentSymbol]]
Union[
Sequence[lsp_types.SymbolInformation],
Sequence[lsp_types.DocumentSymbol],
]
],
_symbol_hook,
),
Expand All @@ -932,7 +937,7 @@ def _notebook_sync_registration_option_selector_hook(
lsp_types.MarkupContent,
str,
lsp_types.MarkedString_Type1,
List[Union[str, lsp_types.MarkedString_Type1]],
Sequence[Union[str, lsp_types.MarkedString_Type1]],
],
_markup_content_hook,
),
Expand Down Expand Up @@ -1033,7 +1038,8 @@ def _notebook_sync_registration_option_selector_hook(
(
Optional[
Union[
lsp_types.InlineCompletionList, List[lsp_types.InlineCompletionItem]
lsp_types.InlineCompletionList,
Sequence[lsp_types.InlineCompletionItem],
]
],
_inline_completion_list_hook,
Expand All @@ -1045,7 +1051,8 @@ def _notebook_sync_registration_option_selector_hook(
(
Optional[
Union[
List[lsp_types.SymbolInformation], List[lsp_types.WorkspaceSymbol]
Sequence[lsp_types.SymbolInformation],
Sequence[lsp_types.WorkspaceSymbol],
]
],
_symbol_list_hook,
Expand Down Expand Up @@ -1148,12 +1155,18 @@ def _notebook_filter_hook(
),
(NotebookSelectorItem, _notebook_filter_hook),
(
Union[lsp_types.LSPObject, List["LSPAny"], str, int, float, bool, None],
Union[lsp_types.LSPObject, Sequence["LSPAny"], str, int, float, bool, None],
_lsp_object_hook,
),
(
Union[
lsp_types.LSPObject, List[lsp_types.LSPAny], str, int, float, bool, None
lsp_types.LSPObject,
Sequence[lsp_types.LSPAny],
str,
int,
float,
bool,
None,
],
_lsp_object_hook,
),
Expand All @@ -1169,10 +1182,10 @@ def _notebook_filter_hook(
(
Union[
lsp_types.LSPObject,
List[
Sequence[
Union[
lsp_types.LSPObject,
List["LSPAny"],
Sequence["LSPAny"],
str,
int,
float,
Expand Down
Loading