Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use generated types for python 38 #2500

Merged
merged 24 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
996acb8
use generated types for python 3.8
predragnikolic Jun 27, 2024
28989a7
remove CompletionEditRange because it is no longer necessary
predragnikolic Jun 27, 2024
b659980
fix flake8
predragnikolic Jun 27, 2024
62edfcf
LSP only supports TextEdits for WorkspaceChanges currently
predragnikolic Jun 28, 2024
9cd147f
Implement activeParameter being `null` in 3.18 in which case the clie…
predragnikolic Jun 28, 2024
eabf060
cast langauge_id to LanguageKind
predragnikolic Jun 28, 2024
1a1c30b
I should really setup flake8 locally
predragnikolic Jun 28, 2024
3b49862
a
predragnikolic Jun 28, 2024
28bcaf6
set "noActiveParameterSupport" to False
predragnikolic Jun 28, 2024
1166ef1
remove accidentally committed file
predragnikolic Jun 28, 2024
740420c
add space
predragnikolic Jun 28, 2024
e2db57f
remove noActiveParameterSupport": False
predragnikolic Jul 2, 2024
fab1ad9
import on separate line
predragnikolic Jul 2, 2024
e10634a
one import per line
predragnikolic Jul 2, 2024
3449621
change Enum to StrEnum
predragnikolic Jul 2, 2024
0f80797
remove unused import
predragnikolic Jul 2, 2024
39ad51a
sort lines
predragnikolic Jul 4, 2024
0cf5c20
remove casting
predragnikolic Jul 4, 2024
d66ad92
remove uint
predragnikolic Jul 4, 2024
c7ecd32
fix detecting textEdits not applying because .get('newText') was falsy
predragnikolic Jul 12, 2024
48dfa59
Merge branch 'main' into use-generated-types-for-python-38
rchl Aug 20, 2024
ee0b9ba
address type issue
rchl Aug 20, 2024
1dcaba8
allowed AnnotatedTextEdit
rchl Aug 20, 2024
bf45f72
fix syntax
rchl Aug 20, 2024
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 plugin/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .core.edit import apply_text_edits
from .core.logging import debug
from .core.promise import Promise
from .core.protocol import CompletionEditRange
from .core.protocol import EditRangeWithInsertReplace
from .core.protocol import CompletionItem
from .core.protocol import CompletionItemDefaults
from .core.protocol import CompletionItemKind
Expand Down Expand Up @@ -127,7 +127,7 @@ def is_range(val: Any) -> TypeGuard[Range]:
return isinstance(val, dict) and 'start' in val and 'end' in val


def is_edit_range(val: Any) -> TypeGuard[CompletionEditRange]:
def is_edit_range(val: Any) -> TypeGuard[EditRangeWithInsertReplace]:
return isinstance(val, dict) and 'insert' in val and 'replace' in val


Expand Down
11 changes: 8 additions & 3 deletions plugin/core/edit.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from __future__ import annotations
from .logging import debug
from .protocol import AnnotatedTextEdit
from .protocol import Position
from .protocol import TextEdit
from .protocol import UINT_MAX
from .protocol import WorkspaceEdit
from typing import Dict, List, Optional, Tuple
from typing import Dict, List, Optional, Tuple, Union
import sublime


WorkspaceChanges = Dict[str, Tuple[List[TextEdit], Optional[int]]]
WorkspaceChanges = Dict[str, Tuple[List[Union[TextEdit, AnnotatedTextEdit]], Optional[int]]]


def parse_workspace_edit(workspace_edit: WorkspaceEdit) -> WorkspaceChanges:
Expand All @@ -24,7 +25,11 @@ def parse_workspace_edit(workspace_edit: WorkspaceEdit) -> WorkspaceChanges:
uri = text_document['uri']
version = text_document.get('version')
edits = document_change.get('edits')
changes.setdefault(uri, ([], version))[0].extend(edits)
for edit in edits:
if 'snippet' in edit:
debug('Ignoring unsupported SnippetTextEdit')
continue
changes.setdefault(uri, ([], version))[0].append(edit)
else:
raw_changes = workspace_edit.get('changes')
if isinstance(raw_changes, dict):
Expand Down
Loading