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

Import __future__ annotations #2458

Merged
merged 4 commits into from
Apr 21, 2024
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
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
3 changes: 2 additions & 1 deletion 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 Expand Up @@ -58,7 +59,7 @@ def create(
events: List[FileWatcherEventType],
ignores: List[str],
handler: FileWatcherProtocol
) -> 'FileWatcher':
) -> FileWatcher:
"""
Creates a new instance of the file watcher.

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
7 changes: 4 additions & 3 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 Expand Up @@ -65,7 +66,7 @@ def process_value(value):
"""

@staticmethod
def resolve(resolve_value: S) -> 'Promise[S]':
def resolve(resolve_value: S) -> Promise[S]:
"""Immediately resolves a Promise.

Convenience function for creating a Promise that gets immediately
Expand Down Expand Up @@ -99,7 +100,7 @@ def __call__(self, resolver: ResolveFunc[TExecutor]) -> None:

# Could also support passing plain S.
@staticmethod
def all(promises: List['Promise[S]']) -> 'Promise[List[S]]':
def all(promises: List[Promise[S]]) -> Promise[List[S]]:
"""
Takes a list of promises and returns a Promise that gets resolved when all promises
gets resolved.
Expand Down Expand Up @@ -147,7 +148,7 @@ def __repr__(self) -> str:
return 'Promise({})'.format(self.value)
return 'Promise(<pending>)'

def then(self, onfullfilled: FullfillFunc[T, TResult]) -> 'Promise[TResult]':
def then(self, onfullfilled: FullfillFunc[T, TResult]) -> Promise[TResult]:
"""Create a new promise and chain it with this promise.

When this promise gets resolved, the callback will be called with the
Expand Down
Loading