From c802e181ed7fd9a5e90adfbe332d937bb05f566e Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 21 Apr 2024 09:05:42 +0200 Subject: [PATCH] Import annotations in test modules --- plugin/core/sessions.py | 7 +++---- tests/server.py | 1 + tests/setup.py | 1 + tests/test_code_actions.py | 1 + tests/test_collections.py | 1 + tests/test_completion.py | 1 + tests/test_configs.py | 1 + tests/test_configurations.py | 1 + tests/test_documents.py | 1 + tests/test_edit.py | 1 + tests/test_file_watcher.py | 1 + tests/test_message_request_handler.py | 5 +++-- tests/test_mocks.py | 1 + tests/test_protocol.py | 1 + tests/test_rename_panel.py | 1 + tests/test_server_notifications.py | 1 + tests/test_server_panel_circular.py | 1 + tests/test_server_requests.py | 1 + tests/test_session.py | 1 + tests/test_signature_help.py | 1 + tests/test_single_document.py | 1 + tests/test_types.py | 1 + tests/test_url.py | 1 + tests/test_views.py | 1 + tests/test_workspace.py | 1 + 25 files changed, 29 insertions(+), 6 deletions(-) diff --git a/plugin/core/sessions.py b/plugin/core/sessions.py index 2d280c4de..d9152ddc2 100644 --- a/plugin/core/sessions.py +++ b/plugin/core/sessions.py @@ -113,7 +113,7 @@ 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, TYPE_CHECKING +from typing import cast from typing_extensions import TypeGuard from weakref import WeakSet import functools @@ -122,9 +122,8 @@ import sublime import weakref -if TYPE_CHECKING: - InitCallback = Callable[[Session, bool], None] - T = TypeVar('T') +InitCallback = Callable[['Session', bool], None] +T = TypeVar('T') def is_workspace_full_document_diagnostic_report( diff --git a/tests/server.py b/tests/server.py index 9db43a69d..eb55e41e5 100644 --- a/tests/server.py +++ b/tests/server.py @@ -20,6 +20,7 @@ TODO: Untested on Windows. """ +from __future__ import annotations from argparse import ArgumentParser from enum import IntEnum from typing import Any, Callable, Dict, List, Optional, Tuple, Union, Iterable, Awaitable diff --git a/tests/setup.py b/tests/setup.py index b3731ab3a..4c57a7855 100644 --- a/tests/setup.py +++ b/tests/setup.py @@ -1,3 +1,4 @@ +from __future__ import annotations from LSP.plugin.core.promise import Promise from LSP.plugin.core.logging import debug from LSP.plugin.core.protocol import Notification, Request diff --git a/tests/test_code_actions.py b/tests/test_code_actions.py index 4315c39c3..6ca704895 100644 --- a/tests/test_code_actions.py +++ b/tests/test_code_actions.py @@ -1,3 +1,4 @@ +from __future__ import annotations 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 diff --git a/tests/test_collections.py b/tests/test_collections.py index 0bd6722bf..327e3fb1c 100644 --- a/tests/test_collections.py +++ b/tests/test_collections.py @@ -1,3 +1,4 @@ +from __future__ import annotations from LSP.plugin.core.collections import DottedDict from typing import Any from unittest import TestCase diff --git a/tests/test_completion.py b/tests/test_completion.py index 1c4f27068..0f595311e 100644 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -1,3 +1,4 @@ +from __future__ import annotations from copy import deepcopy from LSP.plugin.completion import format_completion from LSP.plugin.completion import completion_with_defaults diff --git a/tests/test_configs.py b/tests/test_configs.py index b3cc51e28..3cdade0b2 100644 --- a/tests/test_configs.py +++ b/tests/test_configs.py @@ -1,3 +1,4 @@ +from __future__ import annotations import sublime from LSP.plugin.core.settings import read_client_config, update_client_config from LSP.plugin.core.views import get_uri_and_position_from_location diff --git a/tests/test_configurations.py b/tests/test_configurations.py index 533c12229..300e01aa5 100644 --- a/tests/test_configurations.py +++ b/tests/test_configurations.py @@ -1,3 +1,4 @@ +from __future__ import annotations from LSP.plugin.core.configurations import WindowConfigManager from test_mocks import DISABLED_CONFIG from test_mocks import TEST_CONFIG diff --git a/tests/test_documents.py b/tests/test_documents.py index dbca23565..f87be7971 100644 --- a/tests/test_documents.py +++ b/tests/test_documents.py @@ -1,3 +1,4 @@ +from __future__ import annotations from LSP.plugin.core.logging import debug from LSP.plugin.core.protocol import Request from LSP.plugin.core.registry import windows diff --git a/tests/test_edit.py b/tests/test_edit.py index 6d3037ed2..9607ecdfe 100644 --- a/tests/test_edit.py +++ b/tests/test_edit.py @@ -1,3 +1,4 @@ +from __future__ import annotations 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 diff --git a/tests/test_file_watcher.py b/tests/test_file_watcher.py index db16d9a74..81f525c41 100644 --- a/tests/test_file_watcher.py +++ b/tests/test_file_watcher.py @@ -1,3 +1,4 @@ +from __future__ import annotations from LSP.plugin import FileWatcher from LSP.plugin import FileWatcherEvent from LSP.plugin import FileWatcherEventType diff --git a/tests/test_message_request_handler.py b/tests/test_message_request_handler.py index 1660c2527..4e0e1d52f 100644 --- a/tests/test_message_request_handler.py +++ b/tests/test_message_request_handler.py @@ -1,7 +1,8 @@ -import unittest -from test_mocks import MockSession +from __future__ import annotations from LSP.plugin.core.message_request_handler import MessageRequestHandler +from test_mocks import MockSession import sublime +import unittest class MessageRequestHandlerTest(unittest.TestCase): diff --git a/tests/test_mocks.py b/tests/test_mocks.py index 629ad6db5..f155d5315 100644 --- a/tests/test_mocks.py +++ b/tests/test_mocks.py @@ -1,3 +1,4 @@ +from __future__ import annotations from LSP.plugin.core.logging import debug from LSP.plugin.core.protocol import Notification from LSP.plugin.core.protocol import Request diff --git a/tests/test_protocol.py b/tests/test_protocol.py index 32b6ce538..6b0d5c36c 100644 --- a/tests/test_protocol.py +++ b/tests/test_protocol.py @@ -1,3 +1,4 @@ +from __future__ import annotations from LSP.plugin.core.protocol import Point, Position, Range, Request, Notification from LSP.plugin.core.transports import JsonRpcProcessor import unittest diff --git a/tests/test_rename_panel.py b/tests/test_rename_panel.py index a9fd78a7a..e647a410e 100644 --- a/tests/test_rename_panel.py +++ b/tests/test_rename_panel.py @@ -1,3 +1,4 @@ +from __future__ import annotations from LSP.plugin.rename import utf16_to_code_points import unittest diff --git a/tests/test_server_notifications.py b/tests/test_server_notifications.py index aabbf82aa..587e440ec 100644 --- a/tests/test_server_notifications.py +++ b/tests/test_server_notifications.py @@ -1,3 +1,4 @@ +from __future__ import annotations from LSP.plugin.core.protocol import DiagnosticSeverity from LSP.plugin.core.protocol import DiagnosticTag from LSP.plugin.core.protocol import PublishDiagnosticsParams diff --git a/tests/test_server_panel_circular.py b/tests/test_server_panel_circular.py index d4ca28415..65d2fc04b 100644 --- a/tests/test_server_panel_circular.py +++ b/tests/test_server_panel_circular.py @@ -1,3 +1,4 @@ +from __future__ import annotations from LSP.plugin.core.panels import MAX_LOG_LINES_LIMIT_ON from LSP.plugin.core.panels import PanelName from LSP.plugin.core.registry import windows diff --git a/tests/test_server_requests.py b/tests/test_server_requests.py index 1139f4fe7..3e24d555e 100644 --- a/tests/test_server_requests.py +++ b/tests/test_server_requests.py @@ -1,3 +1,4 @@ +from __future__ import annotations from LSP.plugin.core.protocol import ErrorCodes from LSP.plugin.core.protocol import TextDocumentSyncKind from LSP.plugin.core.sessions import SessionBufferProtocol diff --git a/tests/test_session.py b/tests/test_session.py index 58f02f377..86c42155d 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -1,3 +1,4 @@ +from __future__ import annotations from LSP.plugin.core.collections import DottedDict from LSP.plugin.core.protocol import Diagnostic from LSP.plugin.core.protocol import DocumentUri diff --git a/tests/test_signature_help.py b/tests/test_signature_help.py index 8de8d43f6..5c00275c6 100644 --- a/tests/test_signature_help.py +++ b/tests/test_signature_help.py @@ -1,3 +1,4 @@ +from __future__ import annotations from LSP.plugin.core.protocol import SignatureHelp from LSP.plugin.core.signature_help import SigHelp import sublime diff --git a/tests/test_single_document.py b/tests/test_single_document.py index 673f1842f..5b5e32028 100644 --- a/tests/test_single_document.py +++ b/tests/test_single_document.py @@ -1,3 +1,4 @@ +from __future__ import annotations from copy import deepcopy from LSP.plugin import apply_text_edits, Request from LSP.plugin.core.protocol import UINT_MAX diff --git a/tests/test_types.py b/tests/test_types.py index ac044beb5..35dc30fd0 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -1,3 +1,4 @@ +from __future__ import annotations from LSP.plugin.core.types import diff from LSP.plugin.core.types import basescope2languageid from LSP.plugin.core.types import DocumentSelector diff --git a/tests/test_url.py b/tests/test_url.py index 31a06556f..bf5acaaac 100644 --- a/tests/test_url.py +++ b/tests/test_url.py @@ -1,3 +1,4 @@ +from __future__ import annotations from LSP.plugin.core.url import filename_to_uri from LSP.plugin.core.url import parse_uri from LSP.plugin.core.url import view_to_uri diff --git a/tests/test_views.py b/tests/test_views.py index 5302ecd60..b5f07ddc4 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -1,3 +1,4 @@ +from __future__ import annotations from copy import deepcopy from LSP.plugin.core.protocol import CodeActionKind from LSP.plugin.core.protocol import Diagnostic diff --git a/tests/test_workspace.py b/tests/test_workspace.py index 3d73191b7..ce9e89da6 100644 --- a/tests/test_workspace.py +++ b/tests/test_workspace.py @@ -1,3 +1,4 @@ +from __future__ import annotations from LSP.plugin.core.workspace import sorted_workspace_folders, is_subpath_of, WorkspaceFolder import os import unittest