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

refactor: update plugin for Pyright 1.1.98 #48

Merged
merged 3 commits into from
Jan 4, 2021
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
39 changes: 0 additions & 39 deletions plugin.py
Original file line number Diff line number Diff line change
@@ -1,7 +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 notification_handler
from lsp_utils import NpmClientHandler
import os
import sublime
Expand All @@ -21,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)
Expand All @@ -39,24 +32,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 #
# -------------- #
Expand All @@ -76,17 +51,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
72 changes: 64 additions & 8 deletions sublime-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -517,24 +547,50 @@
"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",
"information",
"trace"
]
},
Expand Down