From 7bccc4ce82d5f0f66f15287d8d4179a8e0180879 Mon Sep 17 00:00:00 2001 From: Jack Cherng Date: Sat, 2 Jan 2021 11:23:41 +0800 Subject: [PATCH 1/3] chore: update sublime-package.json for Pyright 1.1.98 From https://github.com/microsoft/pyright/blob/1.1.98/packages/vscode-pyright/package.json Signed-off-by: Jack Cherng --- sublime-package.json | 78 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 11 deletions(-) diff --git a/sublime-package.json b/sublime-package.json index 35b3fcc..d35d48b 100644 --- a/sublime-package.json +++ b/sublime-package.json @@ -34,6 +34,14 @@ "default": true, "description": "Automatically add common search paths like 'src'?" }, + "python.analysis.extraPaths": { + "type": "array", + "default": [], + "items": { + "type": "string" + }, + "description": "Additional import search resolution paths" + }, "python.analysis.stubPath": { "type": "string", "default": "typings", @@ -78,6 +86,17 @@ "error" ] }, + "reportFunctionMemberAccess": { + "type": "string", + "description": "Diagnostics for member accesses on functions.", + "default": "none", + "enum": [ + "none", + "information", + "warning", + "error" + ] + }, "reportMissingImports": { "type": "string", "description": "Diagnostics for imports that have no corresponding imported python file or type stub file.", @@ -419,6 +438,17 @@ "error" ] }, + "reportInvalidTypeVarUse": { + "type": "string", + "description": "Diagnostics for improper use of type variables in a function signature.", + "default": "warning", + "enum": [ + "none", + "information", + "warning", + "error" + ] + }, "reportCallInDefaultInitializer": { "type": "string", "description": "Diagnostics for function calls within a default value initialization expression. Such calls can mask expensive operations that are performed at module initialization time.", @@ -517,25 +547,51 @@ "warning", "error" ] + }, + "reportUnusedCallResult": { + "type": "string", + "description": "Diagnostics for call expressions whose results are not consumed and are not None.", + "default": "none", + "enum": [ + "none", + "information", + "warning", + "error" + ] + }, + "reportUnusedCoroutine": { + "type": "string", + "description": "Diagnostics for call expressions that return a Coroutine and whose results are not consumed.", + "default": "error", + "enum": [ + "none", + "information", + "warning", + "error" + ] + }, + "reportUnsupportedDunderAll": { + "type": "string", + "description": "Diagnostics for unsupported operations performed on __all__.", + "default": "warning", + "enum": [ + "none", + "information", + "warning", + "error" + ] } } }, - "python.analysis.extraPaths": { - "type": "array", - "description": "Additional import search resolution paths.", - "items": { - "type": "string" - } - }, "python.analysis.logLevel": { "type": "string", "default": "info", "description": "Specifies the level of logging for the Output panel", "enum": [ - "error", - "warning", - "info", - "trace" + "Error", + "Warning", + "Information", + "Trace" ] }, "python.analysis.typeCheckingMode": { From 2bda6b5562f86a63e779d11bc1f813364c2bb2af Mon Sep 17 00:00:00 2001 From: Jack Cherng Date: Sat, 2 Jan 2021 11:32:32 +0800 Subject: [PATCH 2/3] refactor: Pyright uses LSP-native progress reporting So reported messages should be dealt in LSP. Signed-off-by: Jack Cherng --- plugin.py | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/plugin.py b/plugin.py index 47cad4e..2ed3300 100644 --- a/plugin.py +++ b/plugin.py @@ -1,7 +1,6 @@ from LSP.plugin import DottedDict from LSP.plugin.core.typing import Any, List, Optional, Tuple from lsp_utils import ActivityIndicator -from lsp_utils import notification_handler from lsp_utils import NpmClientHandler import os import sublime @@ -39,24 +38,6 @@ def on_settings_changed(self, settings: DottedDict) -> None: extraPaths.extend(self.find_package_dependency_dirs()) settings.set("python.analysis.extraPaths", extraPaths) - # ---------------- # - # message handlers # - # ---------------- # - - @notification_handler("pyright/beginProgress") - def handle_begin_progress(self, params) -> None: - # we don't know why we begin this progress - # the reason will be updated in "pyright/reportProgress" - self._start_indicator("{}: Working...".format(self.package_name)) - - @notification_handler("pyright/endProgress") - def handle_end_progress(self, params) -> None: - self._stop_indicator() - - @notification_handler("pyright/reportProgress") - def handle_report_progress(self, params: List[str]) -> None: - self._start_indicator("{}: {}".format(self.package_name, "; ".join(params))) - # -------------- # # custom methods # # -------------- # @@ -76,17 +57,3 @@ def find_package_dependency_dirs() -> List[str]: dep_dirs.append(packages_path) return [path for path in dep_dirs if os.path.isdir(path)] - - def _start_indicator(self, msg: str = "") -> None: - if self._activity_indicator: - self._activity_indicator.set_label(msg) - else: - view = sublime.active_window().active_view() - if view: - self._activity_indicator = ActivityIndicator(view, msg) - self._activity_indicator.start() - - def _stop_indicator(self) -> None: - if self._activity_indicator: - self._activity_indicator.stop() - self._activity_indicator = None From dd789f815f8905840902e77f5597a0211669b81f Mon Sep 17 00:00:00 2001 From: Jack Cherng Date: Sun, 3 Jan 2021 10:18:10 +0800 Subject: [PATCH 3/3] fixup! Signed-off-by: Jack Cherng --- plugin.py | 6 ------ sublime-package.json | 8 ++++---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/plugin.py b/plugin.py index 2ed3300..c2685c7 100644 --- a/plugin.py +++ b/plugin.py @@ -1,6 +1,5 @@ from LSP.plugin import DottedDict from LSP.plugin.core.typing import Any, List, Optional, Tuple -from lsp_utils import ActivityIndicator from lsp_utils import NpmClientHandler import os import sublime @@ -20,11 +19,6 @@ class LspPyrightPlugin(NpmClientHandler): server_directory = "language-server" server_binary_path = os.path.join(server_directory, "node_modules", "pyright", "langserver.index.js") - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - - self._activity_indicator = None # type: Optional[ActivityIndicator] - @classmethod def minimum_node_version(cls) -> Tuple[int, int, int]: return (12, 0, 0) diff --git a/sublime-package.json b/sublime-package.json index d35d48b..b8cde6d 100644 --- a/sublime-package.json +++ b/sublime-package.json @@ -588,10 +588,10 @@ "default": "info", "description": "Specifies the level of logging for the Output panel", "enum": [ - "Error", - "Warning", - "Information", - "Trace" + "error", + "warning", + "information", + "trace" ] }, "python.analysis.typeCheckingMode": {