Skip to content

Commit

Permalink
Import __future__ annotations
Browse files Browse the repository at this point in the history
This commit...

1. adds `from __future__ import annotations` to each relevant module in order
   to enable language level type annotation support.
2. as a result most quotation marks can be removed from type annotations.
  • Loading branch information
deathaxe committed Apr 21, 2024
1 parent c5321ad commit 276953c
Show file tree
Hide file tree
Showing 82 changed files with 159 additions and 77 deletions.
1 change: 1 addition & 0 deletions boot.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import os
import sublime
import sublime_plugin
Expand Down
1 change: 1 addition & 0 deletions plugin/code_actions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from .core.promise import Promise
from .core.protocol import CodeAction
from .core.protocol import CodeActionKind
Expand Down
1 change: 1 addition & 0 deletions plugin/code_lens.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from .core.constants import CODE_LENS_ENABLED_KEY
from .core.protocol import CodeLens
from .core.protocol import CodeLensExtended
Expand Down
1 change: 1 addition & 0 deletions plugin/color.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from .core.edit import apply_text_edits
from .core.protocol import ColorInformation
from .core.protocol import ColorPresentation
Expand Down
13 changes: 7 additions & 6 deletions plugin/completion.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from .core.constants import COMPLETION_KINDS
from .core.edit import apply_text_edits
from .core.logging import debug
Expand Down Expand Up @@ -28,17 +29,17 @@
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
from typing_extensions import TypeAlias, TypeGuard
import functools
import html
import sublime
import weakref
import webbrowser

SessionName = str
CompletionResponse = Union[List[CompletionItem], CompletionList, None]
ResolvedCompletions = Tuple[Union[CompletionResponse, Error], 'weakref.ref[Session]']
CompletionsStore = Tuple[List[CompletionItem], CompletionItemDefaults]
SessionName: TypeAlias = str
CompletionResponse: TypeAlias = Union[List[CompletionItem], CompletionList, None]
ResolvedCompletions: TypeAlias = Tuple[Union[CompletionResponse, Error], 'weakref.ref[Session]']
CompletionsStore: TypeAlias = Tuple[List[CompletionItem], CompletionItemDefaults]


def format_completion(
Expand Down Expand Up @@ -199,7 +200,7 @@ def _create_completion_request_async(self, session: Session) -> Promise[Resolved
return promise.then(lambda response: self._on_completion_response_async(response, request_id, weak_session))

def _on_completion_response_async(
self, response: CompletionResponse, request_id: int, weak_session: 'weakref.ref[Session]'
self, response: CompletionResponse, request_id: int, weak_session: weakref.ref[Session]
) -> ResolvedCompletions:
self._pending_completion_requests.pop(request_id, None)
return (response, weak_session)
Expand Down
1 change: 1 addition & 0 deletions plugin/configuration.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from .core.registry import windows
from .core.settings import client_configs
from .core.windows import WindowManager
Expand Down
1 change: 1 addition & 0 deletions plugin/core/active_request.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from .sessions import SessionViewProtocol
from .progress import ProgressReporter
from .progress import ViewProgressReporter
Expand Down
1 change: 1 addition & 0 deletions plugin/core/collections.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Module with additional collections.
"""
from __future__ import annotations
from copy import deepcopy
from typing import Any, Dict, Generator, Optional
import sublime
Expand Down
1 change: 1 addition & 0 deletions plugin/core/configurations.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from .logging import debug
from .logging import exception_log
from .logging import printf
Expand Down
1 change: 1 addition & 0 deletions plugin/core/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from .protocol import CodeActionKind
from .protocol import CompletionItemKind
from .protocol import DiagnosticSeverity
Expand Down
1 change: 1 addition & 0 deletions plugin/core/css.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from typing import Optional
import sublime

Expand Down
1 change: 1 addition & 0 deletions plugin/core/diagnostics_storage.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from .protocol import Diagnostic, DiagnosticSeverity, DocumentUri
from .url import parse_uri
from .views import diagnostic_severity
Expand Down
1 change: 1 addition & 0 deletions plugin/core/edit.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from .logging import debug
from .protocol import Position
from .protocol import TextEdit
Expand Down
1 change: 1 addition & 0 deletions plugin/core/file_watcher.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from .protocol import FileChangeType
from .protocol import WatchKind
from abc import ABCMeta
Expand Down
1 change: 1 addition & 0 deletions plugin/core/input_handlers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from .constants import ST_VERSION
from abc import ABCMeta
from abc import abstractmethod
Expand Down
1 change: 1 addition & 0 deletions plugin/core/logging.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from typing import Any
import traceback
import inspect
Expand Down
1 change: 1 addition & 0 deletions plugin/core/message_request_handler.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from .protocol import MessageType
from .protocol import Response
from .protocol import ShowMessageRequestParams
Expand Down
1 change: 1 addition & 0 deletions plugin/core/open.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from .constants import ST_VERSION
from .logging import exception_log
from .promise import Promise
Expand Down
1 change: 1 addition & 0 deletions plugin/core/panels.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from .types import PANEL_FILE_REGEX
from .types import PANEL_LINE_REGEX
from typing import Iterable, Optional
Expand Down
1 change: 1 addition & 0 deletions plugin/core/paths.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from .protocol import DocumentUri
from .sessions import Session
from .views import parse_uri
Expand Down
1 change: 1 addition & 0 deletions plugin/core/progress.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from typing import Optional, Union
import sublime

Expand Down
1 change: 1 addition & 0 deletions plugin/core/promise.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from typing import Callable, Generic, List, Optional, Protocol, Tuple, TypeVar, Union
import functools
import threading
Expand Down
Loading

0 comments on commit 276953c

Please sign in to comment.