Skip to content

Commit

Permalink
Switch to logging via VS Code logging (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
karthiknadig authored Jan 19, 2023
1 parent 9ebbcd5 commit 17e828e
Show file tree
Hide file tree
Showing 16 changed files with 298 additions and 432 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pylint extension for Visual Studio Code

A Visual Studio Code extension with support for the `pylint` linter. The extension ships with `pylint=2.15.9`.
A Visual Studio Code extension with support for the `pylint` linter. The extension ships with `pylint=2.15.10`.

Note:

Expand All @@ -20,7 +20,6 @@ If you want to disable pylint, you can [disable this extension](https://code.vis
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| pylint.args | `[]` | Custom arguments passed to `pylint`. E.g `"pylint.args" = ["--rcfile=<file>"]` |
| pylint.severity | `{ "convention": "Information", "error": "Error", "fatal": "Error", "refactor": "Hint", "warning": "Warning", "info": "Information" }` | Controls mapping of severity from `pylint` to VS Code severity when displaying in the problems window. You can override specific `pylint` error codes `{ "convention": "Information", "error": "Error", "fatal": "Error", "refactor": "Hint", "warning": "Warning", "W0611": "Error", "undefined-variable": "Warning" }` |
| pylint.logLevel | `error` | Sets the tracing level for the extension. |
| pylint.path | `[]` | Setting to provide custom `pylint` executable. This will slow down linting, since we will have to run `pylint` executable every time or file save or open. Example 1: `["~/global_env/pylint"]` Example 2: `["conda", "run", "-n", "lint_env", "python", "-m", "pylint"]` |
| pylint.interpreter | `[]` | Path to a python interpreter to use to run the linter server. |
| pylint.importStrategy | `useBundled` | Setting to choose where to load `pylint` from. `useBundled` picks pylint bundled with the extension. `fromEnvironment` uses `pylint` available in the environment. |
Expand Down
12 changes: 1 addition & 11 deletions bundled/tool/lsp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def update_sys_path(path_to_add: str, strategy: str) -> None:
import lsp_jsonrpc as jsonrpc
import lsp_utils as utils
from lsprotocol import types as lsp
from pygls import protocol, server, uris, workspace
from pygls import server, uris, workspace

WORKSPACE_SETTINGS = {}
RUNNER = pathlib.Path(__file__).parent / "runner.py"
Expand Down Expand Up @@ -336,15 +336,6 @@ def initialize(params: lsp.InitializeParams) -> None:
f"Settings used to run Server:\r\n{json.dumps(settings, indent=4, ensure_ascii=False)}\r\n"
)

if isinstance(LSP_SERVER.lsp, protocol.LanguageServerProtocol):
if any(setting["logLevel"] == "debug" for setting in settings):
LSP_SERVER.lsp.trace = lsp.TraceValues.Verbose
elif any(
setting["logLevel"] in ["error", "warn", "info"] for setting in settings
):
LSP_SERVER.lsp.trace = lsp.TraceValues.Messages
else:
LSP_SERVER.lsp.trace = lsp.TraceValues.Off
_log_version_info()


Expand Down Expand Up @@ -401,7 +392,6 @@ def _update_workspace_settings(settings):
WORKSPACE_SETTINGS[key] = {
"workspaceFS": key,
"workspace": uris.from_fs_path(key),
"logLevel": "error",
"path": [],
"interpreter": [sys.executable],
"args": [],
Expand Down
Loading

0 comments on commit 17e828e

Please sign in to comment.