From c5321ad504a2060e7be466a0779544e3d72af319 Mon Sep 17 00:00:00 2001 From: jwortmann Date: Sat, 20 Apr 2024 20:43:37 +0200 Subject: [PATCH] Import from typing, typing_extensions and enum modules on Python 3.8 (#2446) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * "Add .python-version file" * remove pathlib from dependencies * change import * Revert "change import" (: This reverts commit c70cd57055ddeb8ca0b4ff36acb8531dd81a6e07. * Fix failing unittests on MacOS (#2436) This commit adopts `unittesting.ViewTestCase` to run view related test cases. ViewTestCase ... 1. provides `view` and `window` members pointing to a dedicated view, being created for testing. 2. ensures not to close empty windows, which was probably the most likely reason for unittests failing before on MacOS. * keep the same order as before * rchlint * add release notes * Import from enum and typing modules * Keep using fake enums * Import remaining classes from typing_extensions * Fix enum types and import from enum module * Quoted type annotation not needed anymore with the ParamSpec from typing_extensions --------- Co-authored-by: Предраг Николић Co-authored-by: Rafal Chlodnicki Co-authored-by: deathaxe Co-authored-by: Raoul Wols --- boot.py | 2 +- dependencies.json | 1 + plugin/code_actions.py | 4 ++- plugin/code_lens.py | 3 +- plugin/color.py | 2 +- plugin/completion.py | 4 ++- plugin/core/active_request.py | 2 +- plugin/core/collections.py | 2 +- plugin/core/configurations.py | 2 +- plugin/core/constants.py | 2 +- plugin/core/css.py | 2 +- plugin/core/diagnostics_storage.py | 2 +- plugin/core/edit.py | 2 +- plugin/core/file_watcher.py | 2 +- plugin/core/input_handlers.py | 5 ++-- plugin/core/logging.py | 2 +- plugin/core/message_request_handler.py | 2 +- plugin/core/open.py | 4 +-- plugin/core/panels.py | 2 +- plugin/core/paths.py | 2 +- plugin/core/progress.py | 2 +- plugin/core/promise.py | 2 +- plugin/core/protocol.py | 30 ++++++++++--------- plugin/core/registry.py | 2 +- plugin/core/sessions.py | 40 +++++++++++++++----------- plugin/core/settings.py | 2 +- plugin/core/signature_help.py | 2 +- plugin/core/transports.py | 2 +- plugin/core/tree_view.py | 3 +- plugin/core/types.py | 4 +-- plugin/core/url.py | 2 +- plugin/core/views.py | 3 +- plugin/core/windows.py | 2 +- plugin/core/workspace.py | 2 +- plugin/diagnostics.py | 2 +- plugin/document_link.py | 2 +- plugin/documents.py | 4 +-- plugin/edit.py | 2 +- plugin/execute_command.py | 2 +- plugin/folding_range.py | 2 +- plugin/formatting.py | 2 +- plugin/goto.py | 2 +- plugin/goto_diagnostic.py | 4 +-- plugin/hierarchy.py | 4 +-- plugin/hover.py | 2 +- plugin/inlay_hint.py | 3 +- plugin/locationpicker.py | 2 +- plugin/panels.py | 2 +- plugin/references.py | 2 +- plugin/rename.py | 5 ++-- plugin/save_command.py | 2 +- plugin/selection_range.py | 2 +- plugin/semantic_highlighting.py | 3 +- plugin/session_buffer.py | 5 ++-- plugin/session_view.py | 2 +- plugin/symbols.py | 5 ++-- plugin/tooling.py | 3 +- tests/setup.py | 2 +- tests/test_code_actions.py | 2 +- tests/test_collections.py | 4 +-- tests/test_completion.py | 2 +- tests/test_documents.py | 2 +- tests/test_edit.py | 2 +- tests/test_file_watcher.py | 2 +- tests/test_mocks.py | 2 +- tests/test_server_notifications.py | 2 +- tests/test_server_requests.py | 2 +- tests/test_session.py | 2 +- tests/test_types.py | 2 +- 69 files changed, 130 insertions(+), 107 deletions(-) diff --git a/boot.py b/boot.py index 65baf6f42..647e0ca49 100644 --- a/boot.py +++ b/boot.py @@ -36,7 +36,6 @@ from .plugin.core.transports import kill_all_subprocesses from .plugin.core.tree_view import LspCollapseTreeItemCommand from .plugin.core.tree_view import LspExpandTreeItemCommand -from .plugin.core.typing import Any, Optional, List, Type, Dict from .plugin.core.views import LspRunTextCommandHelperCommand from .plugin.document_link import LspOpenLinkCommand from .plugin.documents import DocumentSyncListener @@ -86,6 +85,7 @@ from .plugin.tooling import LspOnDoubleClickCommand from .plugin.tooling import LspParseVscodePackageJson from .plugin.tooling import LspTroubleshootServerCommand +from typing import Any, Dict, List, Optional, Type def _get_final_subclasses(derived: List[Type], results: List[Type]) -> None: diff --git a/dependencies.json b/dependencies.json index 0a08cadb6..89cc5ab0c 100644 --- a/dependencies.json +++ b/dependencies.json @@ -3,6 +3,7 @@ ">=4096": [ "bracex", "mdpopups", + "typing_extensions", "wcmatch" ] } diff --git a/plugin/code_actions.py b/plugin/code_actions.py index ad9b96649..8258c24b2 100644 --- a/plugin/code_actions.py +++ b/plugin/code_actions.py @@ -11,7 +11,6 @@ from .core.sessions import AbstractViewListener from .core.sessions import SessionBufferProtocol from .core.settings import userprefs -from .core.typing import Any, List, Dict, Callable, Optional, Tuple, TypeGuard, Union, cast from .core.views import entire_content_region from .core.views import first_selection_region from .core.views import format_code_actions_for_quick_panel @@ -21,6 +20,9 @@ from abc import ABCMeta from abc import abstractmethod from functools import partial +from typing import Any, Callable, Dict, List, Optional, Tuple, Union +from typing import cast +from typing_extensions import TypeGuard import sublime ConfigName = str diff --git a/plugin/code_lens.py b/plugin/code_lens.py index cd6ccef78..2dd136d56 100644 --- a/plugin/code_lens.py +++ b/plugin/code_lens.py @@ -2,7 +2,6 @@ from .core.protocol import CodeLens from .core.protocol import CodeLensExtended from .core.protocol import Error -from .core.typing import List, Tuple, Dict, Iterable, Optional, Generator, Union, cast from .core.registry import LspTextCommand from .core.registry import LspWindowCommand from .core.registry import windows @@ -10,6 +9,8 @@ from .core.views import range_to_region from html import escape as html_escape from functools import partial +from typing import Dict, Generator, Iterable, List, Optional, Tuple, Union +from typing import cast import itertools import sublime diff --git a/plugin/color.py b/plugin/color.py index 88d964cef..5b3bfcf06 100644 --- a/plugin/color.py +++ b/plugin/color.py @@ -4,9 +4,9 @@ from .core.protocol import ColorPresentationParams from .core.protocol import Request from .core.registry import LspTextCommand -from .core.typing import List from .core.views import range_to_region from .core.views import text_document_identifier +from typing import List import sublime diff --git a/plugin/completion.py b/plugin/completion.py index 4e8825bfb..235107a7b 100644 --- a/plugin/completion.py +++ b/plugin/completion.py @@ -19,7 +19,6 @@ from .core.registry import LspTextCommand from .core.sessions import Session from .core.settings import userprefs -from .core.typing import Callable, List, Dict, Optional, Generator, Tuple, Union, cast, Any, TypeGuard from .core.views import FORMAT_STRING, FORMAT_MARKUP_CONTENT from .core.views import MarkdownLangMap from .core.views import minihtml @@ -27,6 +26,9 @@ from .core.views import show_lsp_popup from .core.views import text_document_position_params from .core.views import update_lsp_popup +from typing import Any, Callable, Dict, Generator, List, Optional, Tuple, Union +from typing import cast +from typing_extensions import TypeGuard import functools import html import sublime diff --git a/plugin/core/active_request.py b/plugin/core/active_request.py index af56c0ac9..ac514bb48 100644 --- a/plugin/core/active_request.py +++ b/plugin/core/active_request.py @@ -3,7 +3,7 @@ from .progress import ViewProgressReporter from .progress import WindowProgressReporter from .protocol import Request -from .typing import Any, Optional, Dict +from typing import Any, Dict, Optional from weakref import ref import sublime diff --git a/plugin/core/collections.py b/plugin/core/collections.py index c3b2ebca1..1e8f52934 100644 --- a/plugin/core/collections.py +++ b/plugin/core/collections.py @@ -1,8 +1,8 @@ """ Module with additional collections. """ -from .typing import Optional, Dict, Any, Generator from copy import deepcopy +from typing import Any, Dict, Generator, Optional import sublime diff --git a/plugin/core/configurations.py b/plugin/core/configurations.py index d8e2dc929..facf61443 100644 --- a/plugin/core/configurations.py +++ b/plugin/core/configurations.py @@ -2,13 +2,13 @@ from .logging import exception_log from .logging import printf from .types import ClientConfig -from .typing import Generator, List, Optional, Set, Dict, Deque from .url import parse_uri from .workspace import enable_in_project, disable_in_project from abc import ABCMeta from abc import abstractmethod from collections import deque from datetime import datetime, timedelta +from typing import Deque, Dict, Generator, List, Optional, Set from weakref import WeakSet import sublime diff --git a/plugin/core/constants.py b/plugin/core/constants.py index c60fae826..f5b3267ef 100644 --- a/plugin/core/constants.py +++ b/plugin/core/constants.py @@ -3,7 +3,7 @@ from .protocol import DiagnosticSeverity from .protocol import DocumentHighlightKind from .protocol import SymbolKind -from .typing import Dict, Tuple +from typing import Dict, Tuple import sublime diff --git a/plugin/core/css.py b/plugin/core/css.py index 737804e11..bfc1010a0 100644 --- a/plugin/core/css.py +++ b/plugin/core/css.py @@ -1,5 +1,5 @@ +from typing import Optional import sublime -from .typing import Optional class CSS: diff --git a/plugin/core/diagnostics_storage.py b/plugin/core/diagnostics_storage.py index fe5c602bd..cf59227d1 100644 --- a/plugin/core/diagnostics_storage.py +++ b/plugin/core/diagnostics_storage.py @@ -1,8 +1,8 @@ from .protocol import Diagnostic, DiagnosticSeverity, DocumentUri -from .typing import Callable, Iterator, List, Tuple, TypeVar from .url import parse_uri from .views import diagnostic_severity from collections import OrderedDict +from typing import Callable, Iterator, List, Tuple, TypeVar import functools ParsedUri = Tuple[str, str] diff --git a/plugin/core/edit.py b/plugin/core/edit.py index 92a6bcf57..8fc135100 100644 --- a/plugin/core/edit.py +++ b/plugin/core/edit.py @@ -3,7 +3,7 @@ from .protocol import TextEdit from .protocol import UINT_MAX from .protocol import WorkspaceEdit -from .typing import List, Dict, Optional, Tuple +from typing import Dict, List, Optional, Tuple import sublime diff --git a/plugin/core/file_watcher.py b/plugin/core/file_watcher.py index 840db8bbf..c12b3b957 100644 --- a/plugin/core/file_watcher.py +++ b/plugin/core/file_watcher.py @@ -1,8 +1,8 @@ from .protocol import FileChangeType from .protocol import WatchKind -from .typing import List, Literal, Optional, Protocol, Tuple, Type, Union from abc import ABCMeta from abc import abstractmethod +from typing import List, Literal, Optional, Protocol, Tuple, Type, Union DEFAULT_KIND = WatchKind.Create | WatchKind.Change | WatchKind.Delete diff --git a/plugin/core/input_handlers.py b/plugin/core/input_handlers.py index 234c1d933..d6f900276 100644 --- a/plugin/core/input_handlers.py +++ b/plugin/core/input_handlers.py @@ -1,8 +1,9 @@ from .constants import ST_VERSION -from .typing import Any, Callable, Dict, List, Optional, ParamSpec, Tuple, Union -from .typing import final from abc import ABCMeta from abc import abstractmethod +from typing import Any, Callable, Dict, List, Optional, Tuple, Union +from typing import final +from typing_extensions import ParamSpec import functools import sublime import sublime_plugin diff --git a/plugin/core/logging.py b/plugin/core/logging.py index 3ced4435f..d35ef461e 100644 --- a/plugin/core/logging.py +++ b/plugin/core/logging.py @@ -1,4 +1,4 @@ -from .typing import Any +from typing import Any import traceback import inspect import sublime diff --git a/plugin/core/message_request_handler.py b/plugin/core/message_request_handler.py index 9b1ac6b54..1d6ccc9a7 100644 --- a/plugin/core/message_request_handler.py +++ b/plugin/core/message_request_handler.py @@ -2,9 +2,9 @@ from .protocol import Response from .protocol import ShowMessageRequestParams from .sessions import Session -from .typing import Any, Dict, List from .views import show_lsp_popup from .views import text2html +from typing import Any, Dict, List import sublime diff --git a/plugin/core/open.py b/plugin/core/open.py index b23503f77..aa5411dad 100644 --- a/plugin/core/open.py +++ b/plugin/core/open.py @@ -5,10 +5,10 @@ from .protocol import DocumentUri from .protocol import Range from .protocol import UINT_MAX -from .typing import Dict, Tuple, Optional -from .typing import cast from .url import parse_uri from .views import range_to_region +from typing import Dict, Optional, Tuple +from typing import cast from urllib.parse import unquote, urlparse import os import re diff --git a/plugin/core/panels.py b/plugin/core/panels.py index d4dfd7f1d..e8dbb68ad 100644 --- a/plugin/core/panels.py +++ b/plugin/core/panels.py @@ -1,6 +1,6 @@ from .types import PANEL_FILE_REGEX from .types import PANEL_LINE_REGEX -from .typing import Iterable, Optional +from typing import Iterable, Optional import sublime diff --git a/plugin/core/paths.py b/plugin/core/paths.py index e4b49463d..fcf137303 100644 --- a/plugin/core/paths.py +++ b/plugin/core/paths.py @@ -1,8 +1,8 @@ from .protocol import DocumentUri from .sessions import Session -from .typing import Iterable, Optional, Tuple from .views import parse_uri from pathlib import Path +from typing import Iterable, Optional, Tuple def simple_path(session: Optional[Session], uri: DocumentUri) -> str: diff --git a/plugin/core/progress.py b/plugin/core/progress.py index 22ec4482d..2bde72416 100644 --- a/plugin/core/progress.py +++ b/plugin/core/progress.py @@ -1,5 +1,5 @@ +from typing import Optional, Union import sublime -from .typing import Optional, Union class ProgressReporter: diff --git a/plugin/core/promise.py b/plugin/core/promise.py index fa6ca782a..6becd251e 100644 --- a/plugin/core/promise.py +++ b/plugin/core/promise.py @@ -1,4 +1,4 @@ -from .typing import Callable, Generic, List, Optional, Protocol, Tuple, TypeVar, Union +from typing import Callable, Generic, List, Optional, Protocol, Tuple, TypeVar, Union import functools import threading diff --git a/plugin/core/protocol.py b/plugin/core/protocol.py index 21cefb7d3..72d72fe14 100644 --- a/plugin/core/protocol.py +++ b/plugin/core/protocol.py @@ -1,6 +1,8 @@ -from .typing import Enum, IntEnum, IntFlag, StrEnum -from .typing import Any, Dict, Generic, Iterable, List, Literal, Mapping, NotRequired, Optional, TypedDict, TypeVar, Union # noqa: E501 +from .typing import StrEnum +from enum import IntEnum, IntFlag from functools import total_ordering +from typing import Any, Dict, Generic, Iterable, List, Literal, Mapping, Optional, TypedDict, TypeVar, Union +from typing_extensions import NotRequired import sublime INT_MAX = 2**31 - 1 @@ -14,7 +16,7 @@ RegExp = str -class SemanticTokenTypes(Enum): +class SemanticTokenTypes(StrEnum): """ A set of predefined token types. This set is not fixed an clients can specify additional token types via the corresponding client capabilities. @@ -48,7 +50,7 @@ class SemanticTokenTypes(Enum): """ @since 3.17.0 """ -class SemanticTokenModifiers(Enum): +class SemanticTokenModifiers(StrEnum): """ A set of predefined token modifiers. This set is not fixed an clients can specify additional token types via the corresponding client capabilities. @@ -66,7 +68,7 @@ class SemanticTokenModifiers(Enum): DefaultLibrary = 'defaultLibrary' -class DocumentDiagnosticReportKind(Enum): +class DocumentDiagnosticReportKind(StrEnum): """ The document diagnostic report kinds. @since 3.17.0 """ @@ -167,7 +169,7 @@ class SymbolTag(IntEnum): """ Render a symbol as obsolete, usually using a strike-out. """ -class UniquenessLevel(Enum): +class UniquenessLevel(StrEnum): """ Moniker uniqueness level to define scope of the moniker. @since 3.16.0 """ @@ -183,7 +185,7 @@ class UniquenessLevel(Enum): """ The moniker is globally unique """ -class MonikerKind(Enum): +class MonikerKind(StrEnum): """ The moniker kind. @since 3.16.0 """ @@ -383,7 +385,7 @@ class CodeActionKind(StrEnum): @since 3.15.0 """ -class TraceValues(Enum): +class TraceValues(StrEnum): Off = 'off' """ Turn tracing off. """ Messages = 'messages' @@ -392,7 +394,7 @@ class TraceValues(Enum): """ Verbose message tracing. """ -class MarkupKind(Enum): +class MarkupKind(StrEnum): """ Describes the content type that a client supports in various result literals like `Hover`, `ParameterInfo` or `CompletionItem`. @@ -415,7 +417,7 @@ class InlineCompletionTriggerKind(IntEnum): """ Completion was triggered automatically while editing. """ -class PositionEncodingKind(Enum): +class PositionEncodingKind(StrEnum): """ A set of predefined position encoding kinds. @since 3.17.0 """ @@ -517,7 +519,7 @@ class CodeActionTriggerKind(IntEnum): also be triggered when file content changes. """ -class FileOperationPatternKind(Enum): +class FileOperationPatternKind(StrEnum): """ A pattern kind describing if a glob pattern matches a file a folder or both. @@ -538,7 +540,7 @@ class NotebookCellKind(IntEnum): """ A code-cell is source code. """ -class ResourceOperationKind(Enum): +class ResourceOperationKind(StrEnum): Create = 'create' """ Supports creating new files and folders. """ Rename = 'rename' @@ -547,7 +549,7 @@ class ResourceOperationKind(Enum): """ Supports deleting existing files and folders. """ -class FailureHandlingKind(Enum): +class FailureHandlingKind(StrEnum): Abort = 'abort' """ Applying the workspace change is simply aborted if one of the changes provided fails. All operations executed before the failing operation stay executed. """ @@ -569,7 +571,7 @@ class PrepareSupportDefaultBehavior(IntEnum): according the to language's syntax rule. """ -class TokenFormat(Enum): +class TokenFormat(StrEnum): Relative = 'relative' diff --git a/plugin/core/registry.py b/plugin/core/registry.py index 5f6b48f69..e6ca3a069 100644 --- a/plugin/core/registry.py +++ b/plugin/core/registry.py @@ -3,7 +3,6 @@ from .protocol import LocationLink from .sessions import AbstractViewListener from .sessions import Session -from .typing import Optional, Any, Generator, Iterable, List, Union from .views import first_selection_region from .views import get_uri_and_position_from_location from .views import MissingUriError @@ -12,6 +11,7 @@ from .windows import WindowManager from .windows import WindowRegistry from functools import partial +from typing import Any, Generator, Iterable, List, Optional, Union import operator import sublime import sublime_plugin diff --git a/plugin/core/sessions.py b/plugin/core/sessions.py index b9f615b1b..76bdcaa74 100644 --- a/plugin/core/sessions.py +++ b/plugin/core/sessions.py @@ -96,7 +96,6 @@ from .types import SettingsRegistration from .types import sublime_pattern_to_glob from .types import WORKSPACE_DIAGNOSTICS_TIMEOUT -from .typing import Callable, cast, Dict, Any, Optional, List, Tuple, Generator, Type, TypeGuard, Protocol, Set, TypeVar, Union # noqa: E501 from .url import filename_to_uri from .url import parse_uri from .url import unparse_uri @@ -111,6 +110,10 @@ from abc import ABCMeta from abc import abstractmethod from abc import abstractproperty +from enum import IntEnum +from typing import Any, Callable, Dict, Generator, List, Optional, Protocol, Set, Tuple, Type, TypeVar, Union +from typing import cast +from typing_extensions import TypeGuard from weakref import WeakSet import functools import mdpopups @@ -238,23 +241,29 @@ def on_post_exit_async(self, session: 'Session', exit_code: int, exception: Opti raise NotImplementedError() +def _enum_to_list(e: Type[IntEnum]) -> List[int]: + return [v.value for v in e] + + def _enum_like_class_to_list(c: Type[object]) -> List[Union[int, str]]: return [v for k, v in c.__dict__.items() if not k.startswith('_')] def get_initialize_params(variables: Dict[str, str], workspace_folders: List[WorkspaceFolder], config: ClientConfig) -> InitializeParams: - completion_kinds = cast(List[CompletionItemKind], _enum_like_class_to_list(CompletionItemKind)) - symbol_kinds = cast(List[SymbolKind], _enum_like_class_to_list(SymbolKind)) - diagnostic_tag_value_set = cast(List[DiagnosticTag], _enum_like_class_to_list(DiagnosticTag)) - completion_tag_value_set = cast(List[CompletionItemTag], _enum_like_class_to_list(CompletionItemTag)) - symbol_tag_value_set = cast(List[SymbolTag], _enum_like_class_to_list(SymbolTag)) + completion_kinds = cast(List[CompletionItemKind], _enum_to_list(CompletionItemKind)) + symbol_kinds = cast(List[SymbolKind], _enum_to_list(SymbolKind)) + diagnostic_tag_value_set = cast(List[DiagnosticTag], _enum_to_list(DiagnosticTag)) + completion_tag_value_set = cast(List[CompletionItemTag], _enum_to_list(CompletionItemTag)) + symbol_tag_value_set = cast(List[SymbolTag], _enum_to_list(SymbolTag)) semantic_token_types = cast(List[str], _enum_like_class_to_list(SemanticTokenTypes)) if config.semantic_tokens is not None: for token_type in config.semantic_tokens.keys(): if token_type not in semantic_token_types: semantic_token_types.append(token_type) semantic_token_modifiers = cast(List[str], _enum_like_class_to_list(SemanticTokenModifiers)) + supported_markup_kinds = [MarkupKind.Markdown, MarkupKind.PlainText] + folding_range_kind_value_set = cast(List[FoldingRangeKind], _enum_like_class_to_list(FoldingRangeKind)) first_folder = workspace_folders[0] if workspace_folders else None general_capabilities: GeneralClientCapabilities = { # https://microsoft.github.io/language-server-protocol/specification#regExp @@ -280,14 +289,14 @@ def get_initialize_params(variables: Dict[str, str], workspace_folders: List[Wor }, "hover": { "dynamicRegistration": True, - "contentFormat": [MarkupKind.Markdown, MarkupKind.PlainText] + "contentFormat": supported_markup_kinds }, "completion": { "dynamicRegistration": True, "completionItem": { "snippetSupport": True, "deprecatedSupport": True, - "documentationFormat": [MarkupKind.Markdown, MarkupKind.PlainText], + "documentationFormat": supported_markup_kinds, "tagSupport": { "valueSet": completion_tag_value_set }, @@ -296,14 +305,14 @@ def get_initialize_params(variables: Dict[str, str], workspace_folders: List[Wor }, "insertReplaceSupport": True, "insertTextModeSupport": { - "valueSet": [InsertTextMode.AdjustIndentation] + "valueSet": cast(List[InsertTextMode], [InsertTextMode.AdjustIndentation.value]) }, "labelDetailsSupport": True, }, "completionItemKind": { "valueSet": completion_kinds }, - "insertTextMode": InsertTextMode.AdjustIndentation, + "insertTextMode": cast(InsertTextMode, InsertTextMode.AdjustIndentation.value), "completionList": { "itemDefaults": ["editRange", "insertTextFormat", "data"] } @@ -313,7 +322,7 @@ def get_initialize_params(variables: Dict[str, str], workspace_folders: List[Wor "contextSupport": True, "signatureInformation": { "activeParameterSupport": True, - "documentationFormat": [MarkupKind.Markdown, MarkupKind.PlainText], + "documentationFormat": supported_markup_kinds, "parameterInformation": { "labelOffsetSupport": True } @@ -388,7 +397,8 @@ def get_initialize_params(variables: Dict[str, str], workspace_folders: List[Wor "rename": { "dynamicRegistration": True, "prepareSupport": True, - "prepareSupportDefaultBehavior": PrepareSupportDefaultBehavior.Identifier, + "prepareSupportDefaultBehavior": cast( + PrepareSupportDefaultBehavior, PrepareSupportDefaultBehavior.Identifier.value), }, "colorProvider": { "dynamicRegistration": True # exceptional @@ -412,11 +422,7 @@ def get_initialize_params(variables: Dict[str, str], workspace_folders: List[Wor "foldingRange": { "dynamicRegistration": True, "foldingRangeKind": { - "valueSet": [ - FoldingRangeKind.Comment, - FoldingRangeKind.Imports, - FoldingRangeKind.Region - ] + "valueSet": folding_range_kind_value_set } }, "codeLens": { diff --git a/plugin/core/settings.py b/plugin/core/settings.py index 92b2a81d7..ff1148093 100644 --- a/plugin/core/settings.py +++ b/plugin/core/settings.py @@ -4,7 +4,7 @@ from .types import read_dict_setting from .types import Settings from .types import SettingsRegistration -from .typing import Any, Optional, Dict, Callable +from typing import Any, Callable, Dict, Optional import os import sublime diff --git a/plugin/core/signature_help.py b/plugin/core/signature_help.py index 1bb7545b6..6f9d42d50 100644 --- a/plugin/core/signature_help.py +++ b/plugin/core/signature_help.py @@ -2,11 +2,11 @@ from .protocol import SignatureHelp from .protocol import SignatureInformation from .registry import LspTextCommand -from .typing import Optional, List from .views import FORMAT_MARKUP_CONTENT from .views import FORMAT_STRING from .views import MarkdownLangMap from .views import minihtml +from typing import List, Optional import functools import html import re diff --git a/plugin/core/transports.py b/plugin/core/transports.py index 52f4eeaa8..d5e06d1f3 100644 --- a/plugin/core/transports.py +++ b/plugin/core/transports.py @@ -1,10 +1,10 @@ from .logging import exception_log, debug from .types import TCP_CONNECT_TIMEOUT from .types import TransportConfig -from .typing import Dict, Any, Optional, IO, Protocol, Generic, List, Callable, Tuple, TypeVar, Union from contextlib import closing from functools import partial from queue import Queue +from typing import Any, Callable, Dict, Generic, IO, List, Optional, Protocol, Tuple, TypeVar, Union import http import json import os diff --git a/plugin/core/tree_view.py b/plugin/core/tree_view.py index 80783e296..d9194076e 100644 --- a/plugin/core/tree_view.py +++ b/plugin/core/tree_view.py @@ -3,10 +3,11 @@ from .promise import Promise from .registry import LspWindowCommand from .registry import windows -from .typing import Dict, IntEnum, List, Optional, TypeVar from abc import ABCMeta from abc import abstractmethod +from enum import IntEnum from functools import partial +from typing import Dict, List, Optional, TypeVar import html import sublime import sublime_api # pyright: ignore[reportMissingImports] diff --git a/plugin/core/types.py b/plugin/core/types.py index afd64a42e..a73d72fde 100644 --- a/plugin/core/types.py +++ b/plugin/core/types.py @@ -2,10 +2,10 @@ from .file_watcher import FileWatcherEventType from .logging import debug, set_debug_logging from .protocol import TextDocumentSyncKind -from .typing import Any, Optional, List, Dict, Generator, Callable, Iterable, Union, Set, Tuple, TypedDict, TypeVar -from .typing import cast from .url import filename_to_uri from .url import parse_uri +from typing import Any, Callable, Dict, Generator, Iterable, List, Optional, Set, Tuple, TypedDict, TypeVar, Union +from typing import cast from wcmatch.glob import BRACE from wcmatch.glob import globmatch from wcmatch.glob import GLOBSTAR diff --git a/plugin/core/url.py b/plugin/core/url.py index 1f6699f91..951be28ef 100644 --- a/plugin/core/url.py +++ b/plugin/core/url.py @@ -1,4 +1,4 @@ -from .typing import Any, Tuple +from typing import Any, Tuple from urllib.parse import urljoin from urllib.parse import urlparse from urllib.request import pathname2url diff --git a/plugin/core/views.py b/plugin/core/views.py index e928a4547..64d05700f 100644 --- a/plugin/core/views.py +++ b/plugin/core/views.py @@ -38,9 +38,10 @@ from .protocol import WillSaveTextDocumentParams from .settings import userprefs from .types import ClientConfig -from .typing import Callable, Optional, Dict, Any, Iterable, List, Union, Tuple, cast from .url import parse_uri from .workspace import is_subpath_of +from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union +from typing import cast import html import itertools import linecache diff --git a/plugin/core/windows.py b/plugin/core/windows.py index 49853575e..e3213249c 100644 --- a/plugin/core/windows.py +++ b/plugin/core/windows.py @@ -27,7 +27,6 @@ from .types import ClientConfig from .types import matches_pattern from .types import sublime_pattern_to_glob -from .typing import Optional, Any, Dict, Deque, List, Generator, Tuple, TYPE_CHECKING from .url import parse_uri from .views import extract_variables from .views import format_diagnostic_for_panel @@ -39,6 +38,7 @@ from datetime import datetime from subprocess import CalledProcessError from time import perf_counter +from typing import Any, Deque, Dict, Generator, List, Optional, Tuple, TYPE_CHECKING from weakref import ref from weakref import WeakSet import functools diff --git a/plugin/core/workspace.py b/plugin/core/workspace.py index 67c216318..0a82077fb 100644 --- a/plugin/core/workspace.py +++ b/plugin/core/workspace.py @@ -2,8 +2,8 @@ from .types import diff from .types import matches_pattern from .types import sublime_pattern_to_glob -from .typing import Any, List, Union from .url import filename_to_uri +from typing import Any, List, Union import sublime import os diff --git a/plugin/diagnostics.py b/plugin/diagnostics.py index 343357ed7..86fe0772a 100644 --- a/plugin/diagnostics.py +++ b/plugin/diagnostics.py @@ -3,9 +3,9 @@ from .core.protocol import Diagnostic from .core.protocol import DiagnosticSeverity from .core.settings import userprefs -from .core.typing import List, Tuple from .core.views import diagnostic_severity from .core.views import format_diagnostics_for_annotation +from typing import List, Tuple import sublime diff --git a/plugin/document_link.py b/plugin/document_link.py index e6cf563d3..60ee64d80 100644 --- a/plugin/document_link.py +++ b/plugin/document_link.py @@ -6,7 +6,7 @@ from .core.protocol import URI from .core.registry import get_position from .core.registry import LspTextCommand -from .core.typing import Optional +from typing import Optional import sublime diff --git a/plugin/documents.py b/plugin/documents.py index e2a3f92d5..94159946b 100644 --- a/plugin/documents.py +++ b/plugin/documents.py @@ -35,8 +35,6 @@ from .core.types import DebouncerNonThreadSafe from .core.types import FEATURES_TIMEOUT from .core.types import SettingsRegistration -from .core.typing import Any, Callable, Optional, Dict, Generator, Iterable, List, Tuple -from .core.typing import cast from .core.url import parse_uri from .core.url import view_to_uri from .core.views import diagnostic_severity @@ -56,6 +54,8 @@ from .session_buffer import SessionBuffer from .session_view import SessionView from functools import partial +from typing import Any, Callable, Dict, Generator, Iterable, List, Optional, Tuple +from typing import cast from weakref import WeakSet from weakref import WeakValueDictionary import itertools diff --git a/plugin/edit.py b/plugin/edit.py index 6ddcfdf06..bcf17ee0a 100644 --- a/plugin/edit.py +++ b/plugin/edit.py @@ -3,8 +3,8 @@ from .core.protocol import TextEdit from .core.protocol import WorkspaceEdit from .core.registry import LspWindowCommand -from .core.typing import List, Optional, Any, Generator, Iterable, Tuple from contextlib import contextmanager +from typing import Any, Generator, Iterable, List, Optional, Tuple import operator import re import sublime diff --git a/plugin/execute_command.py b/plugin/execute_command.py index 3609ab54b..1d8106525 100644 --- a/plugin/execute_command.py +++ b/plugin/execute_command.py @@ -1,13 +1,13 @@ from .core.protocol import Error from .core.protocol import ExecuteCommandParams from .core.registry import LspTextCommand -from .core.typing import List, Optional, Any from .core.views import first_selection_region from .core.views import offset_to_point from .core.views import region_to_range from .core.views import text_document_identifier from .core.views import text_document_position_params from .core.views import uri_from_view +from typing import Any, List, Optional import sublime diff --git a/plugin/folding_range.py b/plugin/folding_range.py index 141fb2bb5..eca29e957 100644 --- a/plugin/folding_range.py +++ b/plugin/folding_range.py @@ -5,10 +5,10 @@ from .core.protocol import Request from .core.protocol import UINT_MAX from .core.registry import LspTextCommand -from .core.typing import List, Optional from .core.views import range_to_region from .core.views import text_document_identifier from functools import partial +from typing import List, Optional import sublime diff --git a/plugin/formatting.py b/plugin/formatting.py index c9db6a950..6c804c660 100644 --- a/plugin/formatting.py +++ b/plugin/formatting.py @@ -8,7 +8,6 @@ from .core.registry import windows from .core.sessions import Session from .core.settings import userprefs -from .core.typing import Callable, List, Optional, Iterator, Union from .core.views import entire_content_region from .core.views import first_selection_region from .core.views import has_single_nonempty_selection @@ -18,6 +17,7 @@ from .core.views import will_save_wait_until from .save_command import LspSaveCommand, SaveTask from functools import partial +from typing import Callable, Iterator, List, Optional, Union import sublime diff --git a/plugin/goto.py b/plugin/goto.py index c0315b99a..71fbf5642 100644 --- a/plugin/goto.py +++ b/plugin/goto.py @@ -4,12 +4,12 @@ from .core.registry import get_position from .core.registry import LspTextCommand from .core.sessions import Session, method_to_capability -from .core.typing import List, Optional, Union from .core.views import get_symbol_kind_from_scope from .core.views import text_document_position_params from .locationpicker import LocationPicker from .locationpicker import open_location_async from functools import partial +from typing import List, Optional, Union import sublime diff --git a/plugin/goto_diagnostic.py b/plugin/goto_diagnostic.py index 19f864c3b..11d884421 100644 --- a/plugin/goto_diagnostic.py +++ b/plugin/goto_diagnostic.py @@ -13,8 +13,6 @@ from .core.sessions import Session from .core.settings import userprefs from .core.types import ClientConfig -from .core.typing import Dict, Iterator, List, Optional, Tuple, Union -from .core.typing import cast from .core.url import parse_uri, unparse_uri from .core.views import diagnostic_severity from .core.views import format_diagnostic_for_html @@ -26,6 +24,8 @@ from .core.views import uri_from_view from collections import Counter, OrderedDict from pathlib import Path +from typing import Dict, Iterator, List, Optional, Tuple, Union +from typing import cast import functools import os import sublime diff --git a/plugin/hierarchy.py b/plugin/hierarchy.py index 9f7f2e260..b38ddac62 100644 --- a/plugin/hierarchy.py +++ b/plugin/hierarchy.py @@ -18,13 +18,13 @@ from .core.tree_view import new_tree_view_sheet from .core.tree_view import TreeDataProvider from .core.tree_view import TreeItem -from .core.typing import Callable, List, Optional, TypedDict, Union -from .core.typing import cast from .core.views import make_command_link from .core.views import text_document_position_params from abc import ABCMeta from abc import abstractmethod from functools import partial +from typing import Callable, List, Optional, TypedDict, Union +from typing import cast import sublime import weakref diff --git a/plugin/hover.py b/plugin/hover.py index 6357fd5e8..946ecc70b 100644 --- a/plugin/hover.py +++ b/plugin/hover.py @@ -20,7 +20,6 @@ from .core.sessions import AbstractViewListener from .core.sessions import SessionBufferProtocol from .core.settings import userprefs -from .core.typing import List, Optional, Dict, Tuple, Sequence, Union from .core.url import parse_uri from .core.views import diagnostic_severity from .core.views import first_selection_region @@ -39,6 +38,7 @@ from .core.views import unpack_href_location from .core.views import update_lsp_popup from functools import partial +from typing import Dict, List, Optional, Sequence, Tuple, Union from urllib.parse import urlparse import html import mdpopups diff --git a/plugin/inlay_hint.py b/plugin/inlay_hint.py index c37bcf801..edaa8bec2 100644 --- a/plugin/inlay_hint.py +++ b/plugin/inlay_hint.py @@ -8,8 +8,9 @@ from .core.registry import LspWindowCommand from .core.sessions import Session from .core.settings import userprefs -from .core.typing import cast, Optional, Union from .core.views import position_to_offset +from typing import Optional, Union +from typing import cast import html import sublime import uuid diff --git a/plugin/locationpicker.py b/plugin/locationpicker.py index f89c3b1d7..e2cc83aac 100644 --- a/plugin/locationpicker.py +++ b/plugin/locationpicker.py @@ -5,10 +5,10 @@ from .core.protocol import LocationLink from .core.protocol import Position from .core.sessions import Session -from .core.typing import Union, List, Optional, Tuple from .core.views import get_uri_and_position_from_location from .core.views import location_to_human_readable from .core.views import to_encoded_filename +from typing import List, Optional, Tuple, Union from urllib.request import url2pathname import functools import sublime diff --git a/plugin/panels.py b/plugin/panels.py index e264c5609..43d6b3fbc 100644 --- a/plugin/panels.py +++ b/plugin/panels.py @@ -1,9 +1,9 @@ from .core.panels import LOG_LINES_LIMIT_SETTING_NAME from .core.panels import PanelName from .core.registry import windows -from .core.typing import Optional, Generator from contextlib import contextmanager from sublime_plugin import WindowCommand +from typing import Generator, Optional import sublime import sublime_plugin diff --git a/plugin/references.py b/plugin/references.py index dcc96c4a5..621653927 100644 --- a/plugin/references.py +++ b/plugin/references.py @@ -7,13 +7,13 @@ from .core.sessions import Session from .core.settings import userprefs from .core.types import ClientConfig -from .core.typing import Dict, List, Literal, Optional, Tuple from .core.views import get_line from .core.views import get_symbol_kind_from_scope from .core.views import get_uri_and_position_from_location from .core.views import position_to_offset from .core.views import text_document_position_params from .locationpicker import LocationPicker +from typing import Dict, List, Literal, Optional, Tuple import functools import linecache import os diff --git a/plugin/rename.py b/plugin/rename.py index e3864f55a..66514b910 100644 --- a/plugin/rename.py +++ b/plugin/rename.py @@ -11,14 +11,15 @@ from .core.registry import LspTextCommand from .core.registry import windows from .core.sessions import Session -from .core.typing import Any, Optional, List, TypeGuard -from .core.typing import cast from .core.url import parse_uri from .core.views import first_selection_region from .core.views import get_line from .core.views import range_to_region from .core.views import text_document_position_params from functools import partial +from typing import Any, List, Optional +from typing import cast +from typing_extensions import TypeGuard import os import sublime import sublime_plugin diff --git a/plugin/save_command.py b/plugin/save_command.py index b877c7f46..44633ec47 100644 --- a/plugin/save_command.py +++ b/plugin/save_command.py @@ -1,8 +1,8 @@ from .core.registry import LspTextCommand from .core.settings import userprefs -from .core.typing import Any, Callable, Dict, List, Optional, Type from abc import ABCMeta, abstractmethod from functools import partial +from typing import Any, Callable, Dict, List, Optional, Type import sublime import sublime_plugin diff --git a/plugin/selection_range.py b/plugin/selection_range.py index dbc7882e4..9da8ab4b7 100644 --- a/plugin/selection_range.py +++ b/plugin/selection_range.py @@ -2,9 +2,9 @@ from .core.protocol import SelectionRange from .core.registry import get_position from .core.registry import LspTextCommand -from .core.typing import Any, Optional, List, Tuple from .core.views import range_to_region from .core.views import selection_range_params +from typing import Any, List, Optional, Tuple import sublime diff --git a/plugin/semantic_highlighting.py b/plugin/semantic_highlighting.py index e4cec4585..9f3ad4dae 100644 --- a/plugin/semantic_highlighting.py +++ b/plugin/semantic_highlighting.py @@ -1,5 +1,6 @@ from .core.registry import LspTextCommand -from .core.typing import Any, List, Tuple, cast +from typing import Any, List, Tuple +from typing import cast import sublime import os diff --git a/plugin/session_buffer.py b/plugin/session_buffer.py index b71312ad5..45babed8a 100644 --- a/plugin/session_buffer.py +++ b/plugin/session_buffer.py @@ -27,8 +27,6 @@ from .core.types import DebouncerNonThreadSafe from .core.types import FEATURES_TIMEOUT from .core.types import WORKSPACE_DIAGNOSTICS_TIMEOUT -from .core.typing import Any, Callable, Iterable, Optional, List, Protocol, Set, Dict, Tuple, TypeGuard, Union -from .core.typing import cast from .core.views import diagnostic_severity from .core.views import DiagnosticSeverityData from .core.views import did_change @@ -47,6 +45,9 @@ from .inlay_hint import LspToggleInlayHintsCommand from .semantic_highlighting import SemanticToken from functools import partial +from typing import Any, Callable, Dict, Iterable, List, Optional, Protocol, Set, Tuple, Union +from typing import cast +from typing_extensions import TypeGuard from weakref import WeakSet import sublime import time diff --git a/plugin/session_view.py b/plugin/session_view.py index c593a09cd..6b6619453 100644 --- a/plugin/session_view.py +++ b/plugin/session_view.py @@ -16,12 +16,12 @@ from .core.sessions import AbstractViewListener from .core.sessions import Session from .core.settings import userprefs -from .core.typing import Any, Iterable, List, Tuple, Optional, Dict, Generator from .core.views import DIAGNOSTIC_SEVERITY from .core.views import DiagnosticSeverityData from .core.views import text_document_identifier from .diagnostics import DiagnosticsAnnotationsView from .session_buffer import SessionBuffer +from typing import Any, Dict, Generator, Iterable, List, Optional, Tuple from weakref import ref from weakref import WeakValueDictionary import functools diff --git a/plugin/symbols.py b/plugin/symbols.py index 5f547ee14..51d195064 100644 --- a/plugin/symbols.py +++ b/plugin/symbols.py @@ -15,11 +15,12 @@ from .core.registry import LspTextCommand from .core.registry import LspWindowCommand from .core.sessions import print_to_status_bar -from .core.typing import Any, Dict, List, NotRequired, Optional, Tuple, TypedDict, TypeGuard, Union -from .core.typing import cast from .core.views import offset_to_point from .core.views import range_to_region from .core.views import text_document_identifier +from typing import Any, Dict, List, Optional, Tuple, TypedDict, Union +from typing import cast +from typing_extensions import NotRequired, TypeGuard import functools import os import sublime diff --git a/plugin/tooling.py b/plugin/tooling.py index c428bd465..2cced21cf 100644 --- a/plugin/tooling.py +++ b/plugin/tooling.py @@ -7,7 +7,6 @@ from .core.transports import TransportCallbacks from .core.types import Capabilities from .core.types import ClientConfig -from .core.typing import Any, Callable, cast, Dict, List, Optional, Tuple from .core.version import __version__ from .core.views import extract_variables from .core.views import make_command_link @@ -17,6 +16,8 @@ from base64 import b64decode from base64 import b64encode from subprocess import list2cmdline +from typing import Any, Callable, Dict, List, Optional, Tuple +from typing import cast import json import mdpopups import os diff --git a/tests/setup.py b/tests/setup.py index 059b4b7a6..b3731ab3a 100644 --- a/tests/setup.py +++ b/tests/setup.py @@ -4,12 +4,12 @@ from LSP.plugin.core.registry import windows from LSP.plugin.core.settings import client_configs from LSP.plugin.core.types import ClientConfig, ClientStates -from LSP.plugin.core.typing import Any, Generator, List, Optional, Tuple, Union, Dict from LSP.plugin.documents import DocumentSyncListener from os import environ from os.path import join from sublime_plugin import view_event_listeners from test_mocks import basic_responses +from typing import Any, Dict, Generator, List, Optional, Tuple, Union from unittesting import DeferrableTestCase import sublime diff --git a/tests/test_code_actions.py b/tests/test_code_actions.py index 48c99b8f8..4315c39c3 100644 --- a/tests/test_code_actions.py +++ b/tests/test_code_actions.py @@ -1,7 +1,6 @@ from copy import deepcopy from LSP.plugin.code_actions import get_matching_on_save_kinds, kinds_include_kind from LSP.plugin.core.protocol import Point, Range -from LSP.plugin.core.typing import Any, Dict, Generator, List, Tuple, Optional from LSP.plugin.core.url import filename_to_uri from LSP.plugin.core.views import entire_content from LSP.plugin.documents import DocumentSyncListener @@ -9,6 +8,7 @@ from LSP.plugin.core.views import versioned_text_document_identifier from setup import TextDocumentTestCase from test_single_document import TEST_FILE_PATH +from typing import Any, Dict, Generator, List, Optional, Tuple import unittest import sublime diff --git a/tests/test_collections.py b/tests/test_collections.py index 4137cd399..0bd6722bf 100644 --- a/tests/test_collections.py +++ b/tests/test_collections.py @@ -1,6 +1,6 @@ -from unittest import TestCase from LSP.plugin.core.collections import DottedDict -from LSP.plugin.core.typing import Any +from typing import Any +from unittest import TestCase class DottedDictTests(TestCase): diff --git a/tests/test_completion.py b/tests/test_completion.py index ea27a23b4..1c4f27068 100644 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -7,8 +7,8 @@ from LSP.plugin.core.protocol import CompletionItemLabelDetails from LSP.plugin.core.protocol import CompletionItemTag from LSP.plugin.core.protocol import InsertTextFormat -from LSP.plugin.core.typing import Any, Generator, List, Dict, Callable, Optional from setup import TextDocumentTestCase +from typing import Any, Callable, Dict, Generator, List, Optional from unittest import TestCase import sublime diff --git a/tests/test_documents.py b/tests/test_documents.py index 74a994601..25bcfdd1b 100644 --- a/tests/test_documents.py +++ b/tests/test_documents.py @@ -2,7 +2,6 @@ from LSP.plugin.core.protocol import Request from LSP.plugin.core.registry import windows from LSP.plugin.core.types import ClientStates -from LSP.plugin.core.typing import Any, Generator from LSP.plugin.documents import DocumentSyncListener from os.path import join from setup import add_config @@ -13,6 +12,7 @@ from setup import TIMEOUT_TIME from setup import YieldPromise from sublime_plugin import view_event_listeners +from typing import Any, Generator from unittesting import DeferrableTestCase import sublime diff --git a/tests/test_edit.py b/tests/test_edit.py index 14782f84b..6d3037ed2 100644 --- a/tests/test_edit.py +++ b/tests/test_edit.py @@ -1,7 +1,6 @@ from LSP.plugin import apply_text_edits from LSP.plugin.core.edit import parse_workspace_edit from LSP.plugin.core.protocol import TextDocumentEdit, TextEdit, WorkspaceEdit -from LSP.plugin.core.typing import List from LSP.plugin.core.url import filename_to_uri from LSP.plugin.core.views import entire_content from LSP.plugin.edit import _parse_text_edit as parse_text_edit @@ -9,6 +8,7 @@ from LSP.plugin.edit import temporary_setting from setup import TextDocumentTestCase from test_protocol import LSP_RANGE +from typing import List import sublime import unittest diff --git a/tests/test_file_watcher.py b/tests/test_file_watcher.py index 70d7c88a4..db16d9a74 100644 --- a/tests/test_file_watcher.py +++ b/tests/test_file_watcher.py @@ -7,10 +7,10 @@ from LSP.plugin.core.protocol import WatchKind from LSP.plugin.core.types import ClientConfig from LSP.plugin.core.types import sublime_pattern_to_glob -from LSP.plugin.core.typing import Generator, List, Optional from os.path import join from setup import expand from setup import TextDocumentTestCase +from typing import Generator, List, Optional import sublime import unittest diff --git a/tests/test_mocks.py b/tests/test_mocks.py index 75c57a588..629ad6db5 100644 --- a/tests/test_mocks.py +++ b/tests/test_mocks.py @@ -3,7 +3,7 @@ from LSP.plugin.core.protocol import Request from LSP.plugin.core.protocol import Response from LSP.plugin.core.types import ClientConfig -from LSP.plugin.core.typing import List, Any, Callable +from typing import Any, Callable, List TEST_CONFIG = ClientConfig(name="test", command=[], selector="text.plain", tcp_port=None) diff --git a/tests/test_server_notifications.py b/tests/test_server_notifications.py index 7b3e02d16..aabbf82aa 100644 --- a/tests/test_server_notifications.py +++ b/tests/test_server_notifications.py @@ -1,9 +1,9 @@ from LSP.plugin.core.protocol import DiagnosticSeverity from LSP.plugin.core.protocol import DiagnosticTag from LSP.plugin.core.protocol import PublishDiagnosticsParams -from LSP.plugin.core.typing import Generator from LSP.plugin.core.url import filename_to_uri from setup import TextDocumentTestCase +from typing import Generator import sublime diff --git a/tests/test_server_requests.py b/tests/test_server_requests.py index 2ac9d5814..1139f4fe7 100644 --- a/tests/test_server_requests.py +++ b/tests/test_server_requests.py @@ -2,9 +2,9 @@ from LSP.plugin.core.protocol import TextDocumentSyncKind from LSP.plugin.core.sessions import SessionBufferProtocol from LSP.plugin.core.types import ClientConfig -from LSP.plugin.core.typing import Any, Dict, Generator, Optional, List from LSP.plugin.core.url import filename_to_uri from setup import TextDocumentTestCase +from typing import Any, Dict, Generator, List, Optional import os import sublime import tempfile diff --git a/tests/test_session.py b/tests/test_session.py index b6a82d61e..58f02f377 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -8,9 +8,9 @@ from LSP.plugin.core.sessions import Manager from LSP.plugin.core.sessions import Session from LSP.plugin.core.types import ClientConfig -from LSP.plugin.core.typing import Any, Optional, Generator, List, Dict from LSP.plugin.core.workspace import WorkspaceFolder from test_mocks import TEST_CONFIG +from typing import Any, Dict, Generator, List, Optional import sublime import unittest import unittest.mock diff --git a/tests/test_types.py b/tests/test_types.py index 244769412..ac044beb5 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -1,7 +1,7 @@ from LSP.plugin.core.types import diff from LSP.plugin.core.types import basescope2languageid from LSP.plugin.core.types import DocumentSelector -from LSP.plugin.core.typing import List +from typing import List from unittest.mock import MagicMock import sublime import unittest