diff --git a/README.md b/README.md index 639d28c3..9e7d14d2 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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="]` | | 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. | diff --git a/bundled/tool/lsp_server.py b/bundled/tool/lsp_server.py index 26b06bde..e273f065 100644 --- a/bundled/tool/lsp_server.py +++ b/bundled/tool/lsp_server.py @@ -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" @@ -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() @@ -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": [], diff --git a/package-lock.json b/package-lock.json index 8f411750..c7d22c94 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,16 +13,16 @@ "vscode-languageclient": "^7.0.0" }, "devDependencies": { - "@types/fs-extra": "^9.0.13", + "@types/fs-extra": "^11.0.0", "@types/glob": "^8.0.0", "@types/node": "14.x", - "@types/vscode": "^1.71.0", - "@typescript-eslint/eslint-plugin": "^5.48.0", - "@typescript-eslint/parser": "^5.48.0", - "@vscode/test-electron": "^2.2.1", + "@types/vscode": "^1.74.0", + "@typescript-eslint/eslint-plugin": "^5.48.1", + "@typescript-eslint/parser": "^5.48.1", + "@vscode/test-electron": "^2.2.2", "eslint": "^8.31.0", "glob": "^8.0.3", - "prettier": "^2.8.1", + "prettier": "^2.8.2", "ts-loader": "^9.4.2", "typescript": "^4.9.4", "vsce": "^2.15.0", @@ -227,11 +227,12 @@ "dev": true }, "node_modules/@types/fs-extra": { - "version": "9.0.13", - "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-9.0.13.tgz", - "integrity": "sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==", + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-11.0.0.tgz", + "integrity": "sha512-zdV5odfHf95B4qr6bdpshG4VMm/3xgnPhSJLa3xh75CYr35e34k+4FQli82Q48sPqwHazJGy+6+jl4T+Vw1AMg==", "dev": true, "dependencies": { + "@types/jsonfile": "*", "@types/node": "*" } }, @@ -251,6 +252,15 @@ "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "dev": true }, + "node_modules/@types/jsonfile": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/@types/jsonfile/-/jsonfile-6.1.1.tgz", + "integrity": "sha512-GSgiRCVeapDN+3pqA35IkQwasaCh/0YFH5dEF6S88iDvEn901DjOeH3/QPY+XYP1DFzDZPvIvfeEgk+7br5png==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/minimatch": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz", @@ -270,20 +280,20 @@ "dev": true }, "node_modules/@types/vscode": { - "version": "1.71.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.71.0.tgz", - "integrity": "sha512-nB50bBC9H/x2CpwW9FzRRRDrTZ7G0/POttJojvN/LiVfzTGfLyQIje1L1QRMdFXK9G41k5UJN/1B9S4of7CSzA==", + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.74.0.tgz", + "integrity": "sha512-LyeCIU3jb9d38w0MXFwta9r0Jx23ugujkAxdwLTNCyspdZTKUc43t7ppPbCiPoQ/Ivd/pnDFZrb4hWd45wrsgA==", "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.48.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.48.0.tgz", - "integrity": "sha512-SVLafp0NXpoJY7ut6VFVUU9I+YeFsDzeQwtK0WZ+xbRN3mtxJ08je+6Oi2N89qDn087COdO0u3blKZNv9VetRQ==", + "version": "5.48.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.48.1.tgz", + "integrity": "sha512-9nY5K1Rp2ppmpb9s9S2aBiF3xo5uExCehMDmYmmFqqyxgenbHJ3qbarcLt4ITgaD6r/2ypdlcFRdcuVPnks+fQ==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.48.0", - "@typescript-eslint/type-utils": "5.48.0", - "@typescript-eslint/utils": "5.48.0", + "@typescript-eslint/scope-manager": "5.48.1", + "@typescript-eslint/type-utils": "5.48.1", + "@typescript-eslint/utils": "5.48.1", "debug": "^4.3.4", "ignore": "^5.2.0", "natural-compare-lite": "^1.4.0", @@ -309,14 +319,14 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "5.48.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.48.0.tgz", - "integrity": "sha512-1mxNA8qfgxX8kBvRDIHEzrRGrKHQfQlbW6iHyfHYS0Q4X1af+S6mkLNtgCOsGVl8+/LUPrqdHMssAemkrQ01qg==", + "version": "5.48.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.48.1.tgz", + "integrity": "sha512-4yg+FJR/V1M9Xoq56SF9Iygqm+r5LMXvheo6DQ7/yUWynQ4YfCRnsKuRgqH4EQ5Ya76rVwlEpw4Xu+TgWQUcdA==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.48.0", - "@typescript-eslint/types": "5.48.0", - "@typescript-eslint/typescript-estree": "5.48.0", + "@typescript-eslint/scope-manager": "5.48.1", + "@typescript-eslint/types": "5.48.1", + "@typescript-eslint/typescript-estree": "5.48.1", "debug": "^4.3.4" }, "engines": { @@ -336,13 +346,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "5.48.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.48.0.tgz", - "integrity": "sha512-0AA4LviDtVtZqlyUQnZMVHydDATpD9SAX/RC5qh6cBd3xmyWvmXYF+WT1oOmxkeMnWDlUVTwdODeucUnjz3gow==", + "version": "5.48.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.48.1.tgz", + "integrity": "sha512-S035ueRrbxRMKvSTv9vJKIWgr86BD8s3RqoRZmsSh/s8HhIs90g6UlK8ZabUSjUZQkhVxt7nmZ63VJ9dcZhtDQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.48.0", - "@typescript-eslint/visitor-keys": "5.48.0" + "@typescript-eslint/types": "5.48.1", + "@typescript-eslint/visitor-keys": "5.48.1" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -353,13 +363,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "5.48.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.48.0.tgz", - "integrity": "sha512-vbtPO5sJyFjtHkGlGK4Sthmta0Bbls4Onv0bEqOGm7hP9h8UpRsHJwsrCiWtCUndTRNQO/qe6Ijz9rnT/DB+7g==", + "version": "5.48.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.48.1.tgz", + "integrity": "sha512-Hyr8HU8Alcuva1ppmqSYtM/Gp0q4JOp1F+/JH5D1IZm/bUBrV0edoewQZiEc1r6I8L4JL21broddxK8HAcZiqQ==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "5.48.0", - "@typescript-eslint/utils": "5.48.0", + "@typescript-eslint/typescript-estree": "5.48.1", + "@typescript-eslint/utils": "5.48.1", "debug": "^4.3.4", "tsutils": "^3.21.0" }, @@ -380,9 +390,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "5.48.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.48.0.tgz", - "integrity": "sha512-UTe67B0Ypius0fnEE518NB2N8gGutIlTojeTg4nt0GQvikReVkurqxd2LvYa9q9M5MQ6rtpNyWTBxdscw40Xhw==", + "version": "5.48.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.48.1.tgz", + "integrity": "sha512-xHyDLU6MSuEEdIlzrrAerCGS3T7AA/L8Hggd0RCYBi0w3JMvGYxlLlXHeg50JI9Tfg5MrtsfuNxbS/3zF1/ATg==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -393,13 +403,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.48.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.48.0.tgz", - "integrity": "sha512-7pjd94vvIjI1zTz6aq/5wwE/YrfIyEPLtGJmRfyNR9NYIW+rOvzzUv3Cmq2hRKpvt6e9vpvPUQ7puzX7VSmsEw==", + "version": "5.48.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.48.1.tgz", + "integrity": "sha512-Hut+Osk5FYr+sgFh8J/FHjqX6HFcDzTlWLrFqGoK5kVUN3VBHF/QzZmAsIXCQ8T/W9nQNBTqalxi1P3LSqWnRA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.48.0", - "@typescript-eslint/visitor-keys": "5.48.0", + "@typescript-eslint/types": "5.48.1", + "@typescript-eslint/visitor-keys": "5.48.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -420,16 +430,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "5.48.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.48.0.tgz", - "integrity": "sha512-x2jrMcPaMfsHRRIkL+x96++xdzvrdBCnYRd5QiW5Wgo1OB4kDYPbC1XjWP/TNqlfK93K/lUL92erq5zPLgFScQ==", + "version": "5.48.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.48.1.tgz", + "integrity": "sha512-SmQuSrCGUOdmGMwivW14Z0Lj8dxG1mOFZ7soeJ0TQZEJcs3n5Ndgkg0A4bcMFzBELqLJ6GTHnEU+iIoaD6hFGA==", "dev": true, "dependencies": { "@types/json-schema": "^7.0.9", "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.48.0", - "@typescript-eslint/types": "5.48.0", - "@typescript-eslint/typescript-estree": "5.48.0", + "@typescript-eslint/scope-manager": "5.48.1", + "@typescript-eslint/types": "5.48.1", + "@typescript-eslint/typescript-estree": "5.48.1", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0", "semver": "^7.3.7" @@ -446,12 +456,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.48.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.48.0.tgz", - "integrity": "sha512-5motVPz5EgxQ0bHjut3chzBkJ3Z3sheYVcSwS5BpHZpLqSptSmELNtGixmgj65+rIfhvtQTz5i9OP2vtzdDH7Q==", + "version": "5.48.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.48.1.tgz", + "integrity": "sha512-Ns0XBwmfuX7ZknznfXozgnydyR8F6ev/KEGePP4i74uL3ArsKbEhJ7raeKr1JSa997DBDwol/4a0Y+At82c9dA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.48.0", + "@typescript-eslint/types": "5.48.1", "eslint-visitor-keys": "^3.3.0" }, "engines": { @@ -463,9 +473,9 @@ } }, "node_modules/@vscode/test-electron": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-2.2.1.tgz", - "integrity": "sha512-DUdwSYVc9p/PbGveaq20dbAAXHfvdq4zQ24ILp6PKizOBxrOfMsOq8Vts5nMzeIo0CxtA/RxZLFyDv001PiUSg==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-2.2.2.tgz", + "integrity": "sha512-s5d2VtMySvff0UgqkJ0BMCr1es+qREE194EAodGIefq518W53ifvv69e80l9e2MrYJEqUUKwukE/w3H9o15YEw==", "dev": true, "dependencies": { "http-proxy-agent": "^4.0.1", @@ -3055,9 +3065,9 @@ } }, "node_modules/prettier": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.1.tgz", - "integrity": "sha512-lqGoSJBQNJidqCHE80vqZJHWHRFoNYsSpP9AjFhlhi9ODCJA541svILes/+/1GM3VaL/abZi7cpFzOpdR9UPKg==", + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.2.tgz", + "integrity": "sha512-BtRV9BcncDyI2tsuS19zzhzoxD8Dh8LiCx7j7tHzrkz8GFXAexeWFdi22mjE1d16dftH2qNaytVxqiRTGlMfpw==", "dev": true, "bin": { "prettier": "bin-prettier.js" @@ -4492,11 +4502,12 @@ "dev": true }, "@types/fs-extra": { - "version": "9.0.13", - "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-9.0.13.tgz", - "integrity": "sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==", + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-11.0.0.tgz", + "integrity": "sha512-zdV5odfHf95B4qr6bdpshG4VMm/3xgnPhSJLa3xh75CYr35e34k+4FQli82Q48sPqwHazJGy+6+jl4T+Vw1AMg==", "dev": true, "requires": { + "@types/jsonfile": "*", "@types/node": "*" } }, @@ -4516,6 +4527,15 @@ "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "dev": true }, + "@types/jsonfile": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/@types/jsonfile/-/jsonfile-6.1.1.tgz", + "integrity": "sha512-GSgiRCVeapDN+3pqA35IkQwasaCh/0YFH5dEF6S88iDvEn901DjOeH3/QPY+XYP1DFzDZPvIvfeEgk+7br5png==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/minimatch": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz", @@ -4535,20 +4555,20 @@ "dev": true }, "@types/vscode": { - "version": "1.71.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.71.0.tgz", - "integrity": "sha512-nB50bBC9H/x2CpwW9FzRRRDrTZ7G0/POttJojvN/LiVfzTGfLyQIje1L1QRMdFXK9G41k5UJN/1B9S4of7CSzA==", + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.74.0.tgz", + "integrity": "sha512-LyeCIU3jb9d38w0MXFwta9r0Jx23ugujkAxdwLTNCyspdZTKUc43t7ppPbCiPoQ/Ivd/pnDFZrb4hWd45wrsgA==", "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "5.48.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.48.0.tgz", - "integrity": "sha512-SVLafp0NXpoJY7ut6VFVUU9I+YeFsDzeQwtK0WZ+xbRN3mtxJ08je+6Oi2N89qDn087COdO0u3blKZNv9VetRQ==", + "version": "5.48.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.48.1.tgz", + "integrity": "sha512-9nY5K1Rp2ppmpb9s9S2aBiF3xo5uExCehMDmYmmFqqyxgenbHJ3qbarcLt4ITgaD6r/2ypdlcFRdcuVPnks+fQ==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "5.48.0", - "@typescript-eslint/type-utils": "5.48.0", - "@typescript-eslint/utils": "5.48.0", + "@typescript-eslint/scope-manager": "5.48.1", + "@typescript-eslint/type-utils": "5.48.1", + "@typescript-eslint/utils": "5.48.1", "debug": "^4.3.4", "ignore": "^5.2.0", "natural-compare-lite": "^1.4.0", @@ -4558,53 +4578,53 @@ } }, "@typescript-eslint/parser": { - "version": "5.48.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.48.0.tgz", - "integrity": "sha512-1mxNA8qfgxX8kBvRDIHEzrRGrKHQfQlbW6iHyfHYS0Q4X1af+S6mkLNtgCOsGVl8+/LUPrqdHMssAemkrQ01qg==", + "version": "5.48.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.48.1.tgz", + "integrity": "sha512-4yg+FJR/V1M9Xoq56SF9Iygqm+r5LMXvheo6DQ7/yUWynQ4YfCRnsKuRgqH4EQ5Ya76rVwlEpw4Xu+TgWQUcdA==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "5.48.0", - "@typescript-eslint/types": "5.48.0", - "@typescript-eslint/typescript-estree": "5.48.0", + "@typescript-eslint/scope-manager": "5.48.1", + "@typescript-eslint/types": "5.48.1", + "@typescript-eslint/typescript-estree": "5.48.1", "debug": "^4.3.4" } }, "@typescript-eslint/scope-manager": { - "version": "5.48.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.48.0.tgz", - "integrity": "sha512-0AA4LviDtVtZqlyUQnZMVHydDATpD9SAX/RC5qh6cBd3xmyWvmXYF+WT1oOmxkeMnWDlUVTwdODeucUnjz3gow==", + "version": "5.48.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.48.1.tgz", + "integrity": "sha512-S035ueRrbxRMKvSTv9vJKIWgr86BD8s3RqoRZmsSh/s8HhIs90g6UlK8ZabUSjUZQkhVxt7nmZ63VJ9dcZhtDQ==", "dev": true, "requires": { - "@typescript-eslint/types": "5.48.0", - "@typescript-eslint/visitor-keys": "5.48.0" + "@typescript-eslint/types": "5.48.1", + "@typescript-eslint/visitor-keys": "5.48.1" } }, "@typescript-eslint/type-utils": { - "version": "5.48.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.48.0.tgz", - "integrity": "sha512-vbtPO5sJyFjtHkGlGK4Sthmta0Bbls4Onv0bEqOGm7hP9h8UpRsHJwsrCiWtCUndTRNQO/qe6Ijz9rnT/DB+7g==", + "version": "5.48.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.48.1.tgz", + "integrity": "sha512-Hyr8HU8Alcuva1ppmqSYtM/Gp0q4JOp1F+/JH5D1IZm/bUBrV0edoewQZiEc1r6I8L4JL21broddxK8HAcZiqQ==", "dev": true, "requires": { - "@typescript-eslint/typescript-estree": "5.48.0", - "@typescript-eslint/utils": "5.48.0", + "@typescript-eslint/typescript-estree": "5.48.1", + "@typescript-eslint/utils": "5.48.1", "debug": "^4.3.4", "tsutils": "^3.21.0" } }, "@typescript-eslint/types": { - "version": "5.48.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.48.0.tgz", - "integrity": "sha512-UTe67B0Ypius0fnEE518NB2N8gGutIlTojeTg4nt0GQvikReVkurqxd2LvYa9q9M5MQ6rtpNyWTBxdscw40Xhw==", + "version": "5.48.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.48.1.tgz", + "integrity": "sha512-xHyDLU6MSuEEdIlzrrAerCGS3T7AA/L8Hggd0RCYBi0w3JMvGYxlLlXHeg50JI9Tfg5MrtsfuNxbS/3zF1/ATg==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "5.48.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.48.0.tgz", - "integrity": "sha512-7pjd94vvIjI1zTz6aq/5wwE/YrfIyEPLtGJmRfyNR9NYIW+rOvzzUv3Cmq2hRKpvt6e9vpvPUQ7puzX7VSmsEw==", + "version": "5.48.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.48.1.tgz", + "integrity": "sha512-Hut+Osk5FYr+sgFh8J/FHjqX6HFcDzTlWLrFqGoK5kVUN3VBHF/QzZmAsIXCQ8T/W9nQNBTqalxi1P3LSqWnRA==", "dev": true, "requires": { - "@typescript-eslint/types": "5.48.0", - "@typescript-eslint/visitor-keys": "5.48.0", + "@typescript-eslint/types": "5.48.1", + "@typescript-eslint/visitor-keys": "5.48.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -4613,35 +4633,35 @@ } }, "@typescript-eslint/utils": { - "version": "5.48.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.48.0.tgz", - "integrity": "sha512-x2jrMcPaMfsHRRIkL+x96++xdzvrdBCnYRd5QiW5Wgo1OB4kDYPbC1XjWP/TNqlfK93K/lUL92erq5zPLgFScQ==", + "version": "5.48.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.48.1.tgz", + "integrity": "sha512-SmQuSrCGUOdmGMwivW14Z0Lj8dxG1mOFZ7soeJ0TQZEJcs3n5Ndgkg0A4bcMFzBELqLJ6GTHnEU+iIoaD6hFGA==", "dev": true, "requires": { "@types/json-schema": "^7.0.9", "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.48.0", - "@typescript-eslint/types": "5.48.0", - "@typescript-eslint/typescript-estree": "5.48.0", + "@typescript-eslint/scope-manager": "5.48.1", + "@typescript-eslint/types": "5.48.1", + "@typescript-eslint/typescript-estree": "5.48.1", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0", "semver": "^7.3.7" } }, "@typescript-eslint/visitor-keys": { - "version": "5.48.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.48.0.tgz", - "integrity": "sha512-5motVPz5EgxQ0bHjut3chzBkJ3Z3sheYVcSwS5BpHZpLqSptSmELNtGixmgj65+rIfhvtQTz5i9OP2vtzdDH7Q==", + "version": "5.48.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.48.1.tgz", + "integrity": "sha512-Ns0XBwmfuX7ZknznfXozgnydyR8F6ev/KEGePP4i74uL3ArsKbEhJ7raeKr1JSa997DBDwol/4a0Y+At82c9dA==", "dev": true, "requires": { - "@typescript-eslint/types": "5.48.0", + "@typescript-eslint/types": "5.48.1", "eslint-visitor-keys": "^3.3.0" } }, "@vscode/test-electron": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-2.2.1.tgz", - "integrity": "sha512-DUdwSYVc9p/PbGveaq20dbAAXHfvdq4zQ24ILp6PKizOBxrOfMsOq8Vts5nMzeIo0CxtA/RxZLFyDv001PiUSg==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-2.2.2.tgz", + "integrity": "sha512-s5d2VtMySvff0UgqkJ0BMCr1es+qREE194EAodGIefq518W53ifvv69e80l9e2MrYJEqUUKwukE/w3H9o15YEw==", "dev": true, "requires": { "http-proxy-agent": "^4.0.1", @@ -6631,9 +6651,9 @@ "dev": true }, "prettier": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.1.tgz", - "integrity": "sha512-lqGoSJBQNJidqCHE80vqZJHWHRFoNYsSpP9AjFhlhi9ODCJA541svILes/+/1GM3VaL/abZi7cpFzOpdR9UPKg==", + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.2.tgz", + "integrity": "sha512-BtRV9BcncDyI2tsuS19zzhzoxD8Dh8LiCx7j7tHzrkz8GFXAexeWFdi22mjE1d16dftH2qNaytVxqiRTGlMfpw==", "dev": true }, "process-nextick-args": { diff --git a/package.json b/package.json index bd21bd27..3546ec01 100644 --- a/package.json +++ b/package.json @@ -102,26 +102,6 @@ }, "type": "array" }, - "pylint.logLevel": { - "default": "error", - "description": "%settings.logLevel.description%", - "enum": [ - "debug", - "error", - "info", - "off", - "warn" - ], - "scope": "window", - "type": "string", - "enumDescriptions": [ - "%settings.logLevel.debug.description%", - "%settings.logLevel.error.description%", - "%settings.logLevel.info.description%", - "%settings.logLevel.off.description%", - "%settings.logLevel.warn.description%" - ] - }, "pylint.path": { "default": [], "description": "%settings.path.description%", @@ -196,16 +176,16 @@ "vscode-languageclient": "^7.0.0" }, "devDependencies": { - "@types/fs-extra": "^9.0.13", + "@types/fs-extra": "^11.0.0", + "@types/vscode": "^1.74.0", "@types/glob": "^8.0.0", "@types/node": "14.x", - "@types/vscode": "^1.71.0", - "@typescript-eslint/eslint-plugin": "^5.48.0", - "@typescript-eslint/parser": "^5.48.0", - "@vscode/test-electron": "^2.2.1", + "@typescript-eslint/eslint-plugin": "^5.48.1", + "@typescript-eslint/parser": "^5.48.1", + "@vscode/test-electron": "^2.2.2", "eslint": "^8.31.0", "glob": "^8.0.3", - "prettier": "^2.8.1", + "prettier": "^2.8.2", "ts-loader": "^9.4.2", "typescript": "^4.9.4", "vsce": "^2.15.0", diff --git a/package.nls.json b/package.nls.json index 63e6d6ed..0376fd28 100644 --- a/package.nls.json +++ b/package.nls.json @@ -1,12 +1,6 @@ { "extension.description": "Linting support for python files using `pylint`.", "command.restartServer": "Restart Server", - "settings.logLevel.description": "The trace level the extension logs at, defaults to 'error'.", - "settings.logLevel.debug.description": "Includes verbose logging intended for debugging purposes.", - "settings.logLevel.error.description": "Only errors and always logged information.", - "settings.logLevel.info.description": "Includes all messages that are not marked as verbose or debug.", - "settings.logLevel.off.description": "Most logging is turned off, any information that is always logged might still be shown.", - "settings.logLevel.warn.description": "Includes all messages in the error category and any additional warnings.", "settings.args.description": "Arguments passed in. Each argument is a separate string in the array.", "settings.severity.description": "Mapping from severity of `pylint` message type to severity shown in problem window.", "settings.path.description": "When set to a path to `pylint` binary, extension will use that for linting. NOTE: Using this option may slowdown linting.", diff --git a/requirements.txt b/requirements.txt index 3a07bf17..372e6c81 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,9 +4,9 @@ # # pip-compile --generate-hashes ./requirements.in # -astroid==2.12.13 \ - --hash=sha256:10e0ad5f7b79c435179d0d0f0df69998c4eef4597534aae44910db060baeb907 \ - --hash=sha256:1493fe8bd3dfd73dc35bd53c9d5b6e49ead98497c47b2307662556a5692d29d7 +astroid==2.13.2 \ + --hash=sha256:3bc7834720e1a24ca797fd785d77efb14f7a28ee8e635ef040b6e2d80ccb3303 \ + --hash=sha256:8f6a8d40c4ad161d6fc419545ae4b2f275ed86d1c989c97825772120842ee0d2 # via pylint attrs==22.2.0 \ --hash=sha256:29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836 \ @@ -80,9 +80,9 @@ mccabe==0.7.0 \ --hash=sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325 \ --hash=sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e # via pylint -packaging==22.0 \ - --hash=sha256:2198ec20bd4c017b8f9717e00f0c8714076fc2fd93816750ab48e2c41de2cfd3 \ - --hash=sha256:957e2148ba0e1a3b282772e791ef1d8083648bc131c8ab0c1feba110ce1146c3 +packaging==23.0 \ + --hash=sha256:714ac14496c3e68c99c29b00845f7a2b85f3bb6f1078fd9f72fd20f0570002b2 \ + --hash=sha256:b6ad297f8907de0fa2fe1ccbd26fdaf387f5f47c7275fedf8cce89f99446cf97 # via -r ./requirements.in platformdirs==2.6.2 \ --hash=sha256:83c8f6d04389165de7c9b6f0c682439697887bca0aa2f1c87ef1826be3584490 \ @@ -92,9 +92,9 @@ pygls==1.0.0 \ --hash=sha256:3414594ac29ff3ab990f004c675d1077e4e2659eae5cc3ae67cc6fa4d861e342 \ --hash=sha256:c2a1c22e30028f7ca9d3f0a04da8eef29f0f1701bdbd97d8614d8e1e6711f336 # via -r ./requirements.in -pylint==2.15.9 \ - --hash=sha256:18783cca3cfee5b83c6c5d10b3cdb66c6594520ffae61890858fe8d932e1c6b4 \ - --hash=sha256:349c8cd36aede4d50a0754a8c0218b43323d13d5d88f4b2952ddfe3e169681eb +pylint==2.15.10 \ + --hash=sha256:9df0d07e8948a1c3ffa3b6e2d7e6e63d9fb457c5da5b961ed63106594780cc7e \ + --hash=sha256:b3dc5ef7d33858f297ac0d06cc73862f01e4f2e74025ec3eff347ce0bc60baf5 # via -r ./requirements.in tomli==2.0.1 \ --hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \ diff --git a/src/common/log/fileLogger.ts b/src/common/log/fileLogger.ts deleted file mode 100644 index b0525581..00000000 --- a/src/common/log/fileLogger.ts +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { WriteStream } from 'fs-extra'; -import * as util from 'util'; -import { Disposable } from 'vscode-jsonrpc'; -import { Arguments, ILogging } from './types'; -import { getTimeForLogging } from '../utilities'; - -function formatMessage(level: string, ...data: Arguments): string { - return `[${level.toUpperCase()} ${getTimeForLogging()}]: ${util.format(...data)}\r\n`; -} - -export class FileLogger implements ILogging, Disposable { - constructor(private readonly stream: WriteStream) {} - - public traceLog(...data: Arguments): void { - this.stream.write(`${util.format(...data)}\r\n`); - } - - public traceError(...data: Arguments): void { - this.stream.write(formatMessage('error', ...data)); - } - - public traceWarn(...data: Arguments): void { - this.stream.write(formatMessage('warn', ...data)); - } - - public traceInfo(...data: Arguments): void { - this.stream.write(formatMessage('info', ...data)); - } - - public traceVerbose(...data: Arguments): void { - this.stream.write(formatMessage('debug', ...data)); - } - - public dispose(): void { - try { - this.stream.close(); - } catch (ex) { - /** do nothing */ - } - } -} diff --git a/src/common/log/logging.ts b/src/common/log/logging.ts index 84188118..16881a79 100644 --- a/src/common/log/logging.ts +++ b/src/common/log/logging.ts @@ -1,71 +1,60 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { createWriteStream } from 'fs-extra'; -import { Disposable } from 'vscode'; -import { FileLogger } from './fileLogger'; -import { Arguments, ILogging, LoggingLevelSettingType, LogLevel } from './types'; +import * as util from 'util'; +import { Disposable, LogOutputChannel } from 'vscode'; -let loggers: ILogging[] = []; -export function registerLogger(logger: ILogging): Disposable { - loggers.push(logger); - return { - dispose: () => { - loggers = loggers.filter((l) => l !== logger); - }, - }; -} +type Arguments = unknown[]; +class OutputChannelLogger { + constructor(private readonly channel: LogOutputChannel) {} -const logLevelMap: Map = new Map([ - ['error', LogLevel.error], - ['warn', LogLevel.warn], - ['info', LogLevel.info], - ['debug', LogLevel.debug], - ['none', LogLevel.off], - ['off', LogLevel.off], - [undefined, LogLevel.error], -]); + public traceLog(...data: Arguments): void { + this.channel.trace(util.format(...data)); + } -let globalLoggingLevel: LogLevel; -export function setLoggingLevel(level?: LoggingLevelSettingType): void { - globalLoggingLevel = logLevelMap.get(level) ?? LogLevel.error; -} + public traceError(...data: Arguments): void { + this.channel.error(util.format(...data)); + } + + public traceWarn(...data: Arguments): void { + this.channel.warn(util.format(...data)); + } + + public traceInfo(...data: Arguments): void { + this.channel.info(util.format(...data)); + } -export function initializeFileLogging(filePath: string, disposables: Disposable[]): unknown { - try { - const fileLogger = new FileLogger(createWriteStream(filePath)); - disposables.push(fileLogger); - disposables.push(registerLogger(fileLogger)); - return undefined; - } catch (ex) { - return ex; + public traceVerbose(...data: Arguments): void { + this.channel.debug(util.format(...data)); } } +let channel: OutputChannelLogger | undefined; +export function registerLogger(logChannel: LogOutputChannel): Disposable { + channel = new OutputChannelLogger(logChannel); + return { + dispose: () => { + channel = undefined; + }, + }; +} + export function traceLog(...args: Arguments): void { - loggers.forEach((l) => l.traceLog(...args)); + channel?.traceLog(...args); } export function traceError(...args: Arguments): void { - if (globalLoggingLevel >= LogLevel.error) { - loggers.forEach((l) => l.traceError(...args)); - } + channel?.traceError(...args); } export function traceWarn(...args: Arguments): void { - if (globalLoggingLevel >= LogLevel.warn) { - loggers.forEach((l) => l.traceWarn(...args)); - } + channel?.traceWarn(...args); } export function traceInfo(...args: Arguments): void { - if (globalLoggingLevel >= LogLevel.info) { - loggers.forEach((l) => l.traceInfo(...args)); - } + channel?.traceInfo(...args); } export function traceVerbose(...args: Arguments): void { - if (globalLoggingLevel >= LogLevel.debug) { - loggers.forEach((l) => l.traceVerbose(...args)); - } + channel?.traceVerbose(...args); } diff --git a/src/common/log/outputChannelLogger.ts b/src/common/log/outputChannelLogger.ts deleted file mode 100644 index ba7c0a51..00000000 --- a/src/common/log/outputChannelLogger.ts +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import * as util from 'util'; -import { OutputChannel } from 'vscode'; -import { Arguments, ILogging } from './types'; -import { getTimeForLogging } from '../utilities'; - -function formatMessage(level: string, ...data: Arguments): string { - return `[${level.toUpperCase()} ${getTimeForLogging()}]: ${util.format(...data)}`; -} - -export class OutputChannelLogger implements ILogging { - constructor(private readonly channel: OutputChannel) {} - - public traceLog(...data: Arguments): void { - this.channel.appendLine(util.format(...data)); - } - - public traceError(...data: Arguments): void { - this.channel.appendLine(formatMessage('error', ...data)); - } - - public traceWarn(...data: Arguments): void { - this.channel.appendLine(formatMessage('warn', ...data)); - } - - public traceInfo(...data: Arguments): void { - this.channel.appendLine(formatMessage('info', ...data)); - } - - public traceVerbose(...data: Arguments): void { - this.channel.appendLine(formatMessage('debug', ...data)); - } -} diff --git a/src/common/log/types.ts b/src/common/log/types.ts deleted file mode 100644 index 4d11da8f..00000000 --- a/src/common/log/types.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -export type Arguments = unknown[]; - -export interface ILogging { - traceLog(...data: Arguments): void; - traceError(...data: Arguments): void; - traceWarn(...data: Arguments): void; - traceInfo(...data: Arguments): void; - traceVerbose(...data: Arguments): void; -} - -export type LoggingLevelSettingType = 'off' | 'error' | 'warn' | 'info' | 'debug'; -export enum LogLevel { - off = 0, - error = 10, - warn = 20, - info = 30, - debug = 40, -} diff --git a/src/common/server.ts b/src/common/server.ts index 4c951547..f3a4d77a 100644 --- a/src/common/server.ts +++ b/src/common/server.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { Disposable, OutputChannel } from 'vscode'; +import { Disposable, LogOutputChannel, WorkspaceFolder } from 'vscode'; import { State } from 'vscode-languageclient'; import { LanguageClient, @@ -13,21 +13,22 @@ import { DEBUG_SERVER_SCRIPT_PATH, SERVER_SCRIPT_PATH } from './constants'; import { traceError, traceInfo, traceVerbose } from './log/logging'; import { getDebuggerPath } from './python'; import { getExtensionSettings, getWorkspaceSettings, ISettings } from './settings'; -import { getProjectRoot, traceLevelToLSTrace } from './utilities'; +import { getLSClientTraceLevel, getProjectRoot } from './utilities'; import { isVirtualWorkspace } from './vscodeapi'; export type IInitOptions = { settings: ISettings[] }; -export async function createServer( +async function createServer( + projectRoot: WorkspaceFolder, interpreter: string[], serverId: string, serverName: string, - outputChannel: OutputChannel, + outputChannel: LogOutputChannel, initializationOptions: IInitOptions, workspaceSetting: ISettings, ): Promise { const command = interpreter[0]; - const cwd = getProjectRoot().uri.fsPath; + const cwd = projectRoot.uri.fsPath; // Set debugger path needed for debugging python code. const newEnv = { ...process.env }; @@ -80,7 +81,7 @@ let _disposables: Disposable[] = []; export async function restartServer( serverId: string, serverName: string, - outputChannel: OutputChannel, + outputChannel: LogOutputChannel, lsClient?: LanguageClient, ): Promise { if (lsClient) { @@ -89,7 +90,8 @@ export async function restartServer( _disposables.forEach((d) => d.dispose()); _disposables = []; } - const workspaceSetting = await getWorkspaceSettings(serverId, getProjectRoot(), true); + const projectRoot = await getProjectRoot(); + const workspaceSetting = await getWorkspaceSettings(serverId, projectRoot, true); if (workspaceSetting.interpreter.length === 0) { traceError( 'Python interpreter missing:\r\n' + @@ -100,6 +102,7 @@ export async function restartServer( } const newLSClient = await createServer( + projectRoot, workspaceSetting.interpreter, serverId, serverName, @@ -109,8 +112,7 @@ export async function restartServer( }, workspaceSetting, ); - - newLSClient.trace = traceLevelToLSTrace(workspaceSetting.logLevel); + newLSClient.trace = getLSClientTraceLevel(outputChannel.logLevel); traceInfo(`Server: Start requested.`); _disposables.push( newLSClient.onDidChangeState((e) => { @@ -127,6 +129,9 @@ export async function restartServer( } }), newLSClient.start(), + outputChannel.onDidChangeLogLevel((e) => { + newLSClient.trace = getLSClientTraceLevel(e); + }), ); return newLSClient; } diff --git a/src/common/settings.ts b/src/common/settings.ts index ba23e9ee..6f6d3a92 100644 --- a/src/common/settings.ts +++ b/src/common/settings.ts @@ -2,7 +2,6 @@ // Licensed under the MIT License. import { ConfigurationChangeEvent, WorkspaceFolder } from 'vscode'; -import { LoggingLevelSettingType } from './log/types'; import { getInterpreterDetails } from './python'; import { getConfiguration, getWorkspaceFolders } from './vscodeapi'; @@ -16,7 +15,6 @@ const DEFAULT_SEVERITY: Record = { }; export interface ISettings { workspace: string; - logLevel: LoggingLevelSettingType; args: string[]; severity: Record; path: string[]; @@ -93,7 +91,6 @@ export async function getWorkspaceSettings( const path = getPath(namespace, workspace).map((s) => resolveWorkspace(workspace, s)); const workspaceSetting = { workspace: workspace.uri.toString(), - logLevel: config.get('logLevel', 'error'), args, severity: config.get>('severity', DEFAULT_SEVERITY), path, @@ -106,7 +103,6 @@ export async function getWorkspaceSettings( export function checkIfConfigurationChanged(e: ConfigurationChangeEvent, namespace: string): boolean { const settings = [ - `${namespace}.trace`, `${namespace}.args`, `${namespace}.severity`, `${namespace}.path`, diff --git a/src/common/utilities.ts b/src/common/utilities.ts index fc19950c..3b5b4d82 100644 --- a/src/common/utilities.ts +++ b/src/common/utilities.ts @@ -1,30 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +import * as fs from 'fs-extra'; import * as path from 'path'; -import { Uri, WorkspaceFolder } from 'vscode'; -import { Trace } from 'vscode-jsonrpc/node'; +import { env, LogLevel, Uri, WorkspaceFolder } from 'vscode'; +import { Trace, TraceValues } from 'vscode-jsonrpc/node'; import { getWorkspaceFolders } from './vscodeapi'; -export function getTimeForLogging(): string { - const date = new Date(); - return `${date.getFullYear()}-${date.getMonth()}-${date.getDate()} ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}.${date.getMilliseconds()}`; -} - -export function traceLevelToLSTrace(level: string): Trace { - switch (level) { - case 'error': - case 'warn': - case 'info': +export function getLSClientTraceLevel(logLevel: LogLevel): Trace { + switch (logLevel) { + case LogLevel.Error: + case LogLevel.Warning: + case LogLevel.Info: return Trace.Messages; - case 'debug': + case LogLevel.Debug: return Trace.Verbose; + case LogLevel.Off: default: return Trace.Off; } } -export function getProjectRoot(): WorkspaceFolder { +export async function getProjectRoot(): Promise { const workspaces: readonly WorkspaceFolder[] = getWorkspaceFolders(); if (workspaces.length === 0) { return { @@ -35,10 +32,18 @@ export function getProjectRoot(): WorkspaceFolder { } else if (workspaces.length === 1) { return workspaces[0]; } else { - let root = workspaces[0].uri.fsPath; let rootWorkspace = workspaces[0]; + let root = undefined; + for (const w of workspaces) { + if (await fs.pathExists(w.uri.fsPath)) { + root = w.uri.fsPath; + rootWorkspace = w; + break; + } + } + for (const w of workspaces) { - if (root.length > w.uri.fsPath.length) { + if (root && root.length > w.uri.fsPath.length && (await fs.pathExists(w.uri.fsPath))) { root = w.uri.fsPath; rootWorkspace = w; } diff --git a/src/common/vscodeapi.ts b/src/common/vscodeapi.ts index 9d806c8d..26327f27 100644 --- a/src/common/vscodeapi.ts +++ b/src/common/vscodeapi.ts @@ -7,7 +7,7 @@ import { commands, ConfigurationScope, Disposable, - OutputChannel, + LogOutputChannel, Uri, window, workspace, @@ -15,8 +15,8 @@ import { WorkspaceFolder, } from 'vscode'; -export function createOutputChannel(name: string): OutputChannel { - return window.createOutputChannel(name); +export function createOutputChannel(name: string): LogOutputChannel { + return window.createOutputChannel(name, { log: true }); } export function getConfiguration(config: string, scope?: ConfigurationScope): WorkspaceConfiguration { diff --git a/src/extension.ts b/src/extension.ts index eb624087..e57cbfe8 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -3,8 +3,7 @@ import * as vscode from 'vscode'; import { LanguageClient } from 'vscode-languageclient/node'; -import { registerLogger, setLoggingLevel, traceLog, traceVerbose } from './common/log/logging'; -import { OutputChannelLogger } from './common/log/outputChannelLogger'; +import { registerLogger, traceLog, traceVerbose } from './common/log/logging'; import { getInterpreterDetails, initializePython, @@ -12,12 +11,7 @@ import { runPythonExtensionCommand, } from './common/python'; import { restartServer } from './common/server'; -import { - checkIfConfigurationChanged, - getExtensionSettings, - getInterpreterFromSetting, - ISettings, -} from './common/settings'; +import { checkIfConfigurationChanged, getInterpreterFromSetting } from './common/settings'; import { loadServerDefaults } from './common/setup'; import { getProjectRoot } from './common/utilities'; import { createOutputChannel, onDidChangeConfiguration, registerCommand } from './common/vscodeapi'; @@ -30,13 +24,9 @@ export async function activate(context: vscode.ExtensionContext): Promise const serverName = serverInfo.name; const serverId = serverInfo.module; - const settings: ISettings[] = await getExtensionSettings(serverId); - // Setup logging const outputChannel = createOutputChannel(serverName); - context.subscriptions.push(outputChannel); - setLoggingLevel(settings.length > 0 ? settings[0].logLevel : undefined); - context.subscriptions.push(registerLogger(new OutputChannelLogger(outputChannel))); + context.subscriptions.push(outputChannel, registerLogger(outputChannel)); traceLog(`Name: ${serverName}`); traceLog(`Module: ${serverInfo.module}`); @@ -59,7 +49,8 @@ export async function activate(context: vscode.ExtensionContext): Promise if (interpreter?.length || interpreterDetails.path) { await runServer(); } else { - runPythonExtensionCommand('python.triggerEnvSelection', getProjectRoot().uri); + const projectRoot = await getProjectRoot(); + runPythonExtensionCommand('python.triggerEnvSelection', projectRoot.uri); } }), ); @@ -67,9 +58,6 @@ export async function activate(context: vscode.ExtensionContext): Promise context.subscriptions.push( onDidChangeConfiguration(async (e: vscode.ConfigurationChangeEvent) => { if (checkIfConfigurationChanged(e, serverId)) { - const newSettings = await getExtensionSettings(serverId); - setLoggingLevel(newSettings[0].logLevel); - await runServer(); } }), diff --git a/src/test/python_tests/requirements.txt b/src/test/python_tests/requirements.txt index 0d00156c..f9d16045 100644 --- a/src/test/python_tests/requirements.txt +++ b/src/test/python_tests/requirements.txt @@ -22,13 +22,13 @@ importlib-metadata==6.0.0 \ # via # pluggy # pytest -iniconfig==1.1.1 \ - --hash=sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3 \ - --hash=sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32 +iniconfig==2.0.0 \ + --hash=sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3 \ + --hash=sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374 # via pytest -packaging==22.0 \ - --hash=sha256:2198ec20bd4c017b8f9717e00f0c8714076fc2fd93816750ab48e2c41de2cfd3 \ - --hash=sha256:957e2148ba0e1a3b282772e791ef1d8083648bc131c8ab0c1feba110ce1146c3 +packaging==23.0 \ + --hash=sha256:714ac14496c3e68c99c29b00845f7a2b85f3bb6f1078fd9f72fd20f0570002b2 \ + --hash=sha256:b6ad297f8907de0fa2fe1ccbd26fdaf387f5f47c7275fedf8cce89f99446cf97 # via pytest pluggy==1.0.0 \ --hash=sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159 \ @@ -54,72 +54,72 @@ typing-extensions==4.4.0 \ --hash=sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa \ --hash=sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e # via importlib-metadata -ujson==5.6.0 \ - --hash=sha256:0f0f21157d1a84ad5fb54388f31767cde9c1a48fb29de7ef91d8887fdc2ca92b \ - --hash=sha256:1217326ba80eab1ff3f644f9eee065bd4fcc4e0c068a2f86f851cafd05737169 \ - --hash=sha256:169b3fbd1188647c6ce00cb690915526aff86997c89a94c1b50432010ad7ae0f \ - --hash=sha256:1a7e4023c79d9a053c0c6b7c6ec50ea0af78381539ab27412e6af8d9410ae555 \ - --hash=sha256:20d929a27822cb79e034cc5e0bb62daa0257ab197247cb6f35d5149f2f438983 \ - --hash=sha256:213e41dc501b4a6d029873039da3e45ba7766b9f9eba97ecc4287c371f5403cc \ - --hash=sha256:23051f062bb257a87f3e55ea5a055ea98d56f08185fd415b34313268fa4d814e \ - --hash=sha256:24d40e01accbf4f0ba5181c4db1bac83749fdc1a5413466da582529f2a096085 \ - --hash=sha256:2a24b9a96364f943a4754fa00b47855d0a01b84ac4b8b11ebf058c8fb68c1f77 \ - --hash=sha256:2cb7a4bd91de97b4c8e57fb5289d1e5f3f019723b59d01d79e2df83783dce5a6 \ - --hash=sha256:31288f85db6295ec63e128daff7285bb0bc220935e1b5107bd2d67e2dc687b7e \ - --hash=sha256:35423460954d0c61602da734697724e8dd5326a8aa7900123e584b935116203e \ - --hash=sha256:355ef5311854936b9edc7f1ce638f8257cb45fb6b9873f6b2d16a715eafc9570 \ - --hash=sha256:3a68a204386648ec92ae9b526c1ffca528f38221eca70f98b4709390c3204275 \ - --hash=sha256:3ad74eb53ee07e76c82f9ef8e7256c33873b81bd1f97a274fdb65ed87c2801f6 \ - --hash=sha256:3b49a1014d396b962cb1d6c5f867f88b2c9aa9224c3860ee6ff63b2837a2965b \ - --hash=sha256:3f00dff3bf26bbb96791ceaf51ca95a3f34e2a21985748da855a650c38633b99 \ - --hash=sha256:3f8b9e8c0420ce3dcc193ab6dd5628840ba79ad1b76e1816ac7ca6752c6bf035 \ - --hash=sha256:52f536712d16a1f4e0f9d084982c28e11b7e70c397a1059069e4d28d53b3f522 \ - --hash=sha256:551408a5c4306839b4a4f91503c96069204dbef2c7ed91a9dab08874ac1ed679 \ - --hash=sha256:57904e5b49ffe93189349229dcd83f73862ef9bb8517e8f1e62d0ff73f313847 \ - --hash=sha256:5e5715b0e2767b1987ceed0066980fc0a53421dd2f197b4f88460d474d6aef4c \ - --hash=sha256:61fdf24f7bddc402ce06b25e4bed7bf5ee4f03e23028a0a09116835c21d54888 \ - --hash=sha256:6d0a60c5f065737a81249c819475d001a86da9a41900d888287e34619c9b4851 \ - --hash=sha256:6ea9024749a41864bffb12da15aace4a3193c03ea97e77b069557aefa342811f \ - --hash=sha256:7174e81c137d480abe2f8036e9fb69157e509f2db0bfdee4488eb61dc3f0ff6b \ - --hash=sha256:72fa6e850831280a46704032721c75155fd41b839ddadabb6068ab218c56a37a \ - --hash=sha256:74671d1bde8c03daeb92abdbd972960978347b1a1d432c4c1b3c9284ce4094cf \ - --hash=sha256:798116b88158f13ed687417526100ef353ba4692e0aef8afbc622bd4bf7e9057 \ - --hash=sha256:7a66c5a75b46545361271b4cf55560d9ad8bad794dd054a14b3fbb031407948e \ - --hash=sha256:7bde16cb18b95a8f68cc48715e4652b394b4fee68cb3f9fee0fd7d26b29a53b6 \ - --hash=sha256:82bf24ea72a73c7d77402a7adc954931243e7ec4241d5738ae74894b53944458 \ - --hash=sha256:87578ccfc35461c77e73660fb7d89bc577732f671364f442bda9e2c58b571765 \ - --hash=sha256:91000612a2c30f50c6a009e6459a677e5c1972e51b59ecefd6063543dc47a4e9 \ - --hash=sha256:9cf04fcc958bb52a6b6c301b780cb9afab3ec68713b17ca5aa423e1f99c2c1cf \ - --hash=sha256:9f4efcac06f45183b6ed8e2321554739a964a02d8aa3089ec343253d86bf2804 \ - --hash=sha256:a51cbe614acb5ea8e2006e4fd80b4e8ea7c51ae51e42c75290012f4925a9d6ab \ - --hash=sha256:a8795de7ceadf84bcef88f947f91900d647eda234a2c6cc89912c25048cc0490 \ - --hash=sha256:ae723b8308ac17a591bb8be9478b58c2c26fada23fd2211fc323796801ad7ff5 \ - --hash=sha256:aff708a1b9e2d4979f74375ade0bff978be72c8bd90422a756d24d8a46d78059 \ - --hash=sha256:b2aece7a92dffc9c78787f5f36e47e24b95495812270c27abc2fa430435a931d \ - --hash=sha256:b4420bfff18ca6aa39cfb22fe35d8aba3811fa1190c4f4e1ad816b0aad72f7e3 \ - --hash=sha256:b64d2ac99503a9a5846157631addacc9f74e23f64d5a886fe910e9662660fa10 \ - --hash=sha256:b72d4d948749e9c6afcd3d7af9ecc780fccde84e26d275c97273dd83c68a488b \ - --hash=sha256:b74396a655ac8a5299dcb765b4a17ba706e45c0df95818bcc6c13c4645a1c38e \ - --hash=sha256:b9e9d26600020cf635a4e58763959f5a59f8c70f75d72ebf26ceae94c2efac74 \ - --hash=sha256:bca074d08f0677f05df8170b25ce6e61db3bcdfda78062444972fa6508dc825f \ - --hash=sha256:bca3c06c3f10ce03fa80b1301dce53765815c2578a24bd141ce4e5769bb7b709 \ - --hash=sha256:bfb1fdf61763fafc0f8a20becf9cc4287c14fc41c0e14111d28c0d0dfda9ba56 \ - --hash=sha256:c169e12642f0edf1dde607fb264721b88787b55a6da5fb3824302a9cac6f9405 \ - --hash=sha256:c4277f6b1d24be30b7f87ec5346a87693cbc1e55bbc5877f573381b2250c4dd6 \ - --hash=sha256:ceee5aef3e234c7e998fdb52e5236c41e50cdedc116360f7f1874a04829f6490 \ - --hash=sha256:d1b5e233e42f53bbbc6961caeb492986e9f3aeacd30be811467583203873bad2 \ - --hash=sha256:d6f4be832d97836d62ac0c148026ec021f9f36481f38e455b51538fcd949ed2a \ - --hash=sha256:dd5ccc036b0f4721b98e1c03ccc604e7f3e1db53866ccc92b2add40ace1782f7 \ - --hash=sha256:dde59d2f06297fc4e70b2bae6e4a6b3ce89ca89697ab2c41e641abae3be96b0c \ - --hash=sha256:e4be7d865cb5161824e12db71cee83290ab72b3523566371a30d6ba1bd63402a \ - --hash=sha256:e97af10b6f13a498de197fb852e9242064217c25dfca79ebe7ad0cf2b0dd0cb7 \ - --hash=sha256:f2d70b7f0b485f85141bbc518d0581ae96b912d9f8b070eaf68a9beef8eb1e60 \ - --hash=sha256:f3e651f04b7510fae7d4706a4600cd43457f015df08702ece82a71339fc15c3d \ - --hash=sha256:f63535d51e039a984b2fb67ff87057ffe4216d4757c3cedf2fc846af88253cb7 \ - --hash=sha256:f881e2d8a022e9285aa2eab6ba8674358dbcb2b57fa68618d88d62937ac3ff04 \ - --hash=sha256:fadebaddd3eb71a5c986f0bdc7bb28b072bfc585c141eef37474fc66d1830b0a \ - --hash=sha256:fb1632b27e12c0b0df62f924c362206daf246a42c0080e959dd465810dc3482e \ - --hash=sha256:fecf83b2ef3cbce4f5cc573df6f6ded565e5e27c1af84038bae5ade306686d82 +ujson==5.7.0 \ + --hash=sha256:00343501dbaa5172e78ef0e37f9ebd08040110e11c12420ff7c1f9f0332d939e \ + --hash=sha256:0e4e8981c6e7e9e637e637ad8ffe948a09e5434bc5f52ecbb82b4b4cfc092bfb \ + --hash=sha256:0ee295761e1c6c30400641f0a20d381633d7622633cdf83a194f3c876a0e4b7e \ + --hash=sha256:137831d8a0db302fb6828ee21c67ad63ac537bddc4376e1aab1c8573756ee21c \ + --hash=sha256:14f9082669f90e18e64792b3fd0bf19f2b15e7fe467534a35ea4b53f3bf4b755 \ + --hash=sha256:16b2254a77b310f118717715259a196662baa6b1f63b1a642d12ab1ff998c3d7 \ + --hash=sha256:18679484e3bf9926342b1c43a3bd640f93a9eeeba19ef3d21993af7b0c44785d \ + --hash=sha256:24ad1aa7fc4e4caa41d3d343512ce68e41411fb92adf7f434a4d4b3749dc8f58 \ + --hash=sha256:26c2b32b489c393106e9cb68d0a02e1a7b9d05a07429d875c46b94ee8405bdb7 \ + --hash=sha256:2f242eec917bafdc3f73a1021617db85f9958df80f267db69c76d766058f7b19 \ + --hash=sha256:341f891d45dd3814d31764626c55d7ab3fd21af61fbc99d070e9c10c1190680b \ + --hash=sha256:35209cb2c13fcb9d76d249286105b4897b75a5e7f0efb0c0f4b90f222ce48910 \ + --hash=sha256:3d3b3499c55911f70d4e074c626acdb79a56f54262c3c83325ffb210fb03e44d \ + --hash=sha256:4a3d794afbf134df3056a813e5c8a935208cddeae975bd4bc0ef7e89c52f0ce0 \ + --hash=sha256:4c592eb91a5968058a561d358d0fef59099ed152cfb3e1cd14eee51a7a93879e \ + --hash=sha256:4ee997799a23227e2319a3f8817ce0b058923dbd31904761b788dc8f53bd3e30 \ + --hash=sha256:523ee146cdb2122bbd827f4dcc2a8e66607b3f665186bce9e4f78c9710b6d8ab \ + --hash=sha256:54384ce4920a6d35fa9ea8e580bc6d359e3eb961fa7e43f46c78e3ed162d56ff \ + --hash=sha256:5593263a7fcfb934107444bcfba9dde8145b282de0ee9f61e285e59a916dda0f \ + --hash=sha256:581c945b811a3d67c27566539bfcb9705ea09cb27c4be0002f7a553c8886b817 \ + --hash=sha256:5eba5e69e4361ac3a311cf44fa71bc619361b6e0626768a494771aacd1c2f09b \ + --hash=sha256:6411aea4c94a8e93c2baac096fbf697af35ba2b2ed410b8b360b3c0957a952d3 \ + --hash=sha256:64772a53f3c4b6122ed930ae145184ebaed38534c60f3d859d8c3f00911eb122 \ + --hash=sha256:67a19fd8e7d8cc58a169bea99fed5666023adf707a536d8f7b0a3c51dd498abf \ + --hash=sha256:6abb8e6d8f1ae72f0ed18287245f5b6d40094e2656d1eab6d99d666361514074 \ + --hash=sha256:6e80f0d03e7e8646fc3d79ed2d875cebd4c83846e129737fdc4c2532dbd43d9e \ + --hash=sha256:6faf46fa100b2b89e4db47206cf8a1ffb41542cdd34dde615b2fc2288954f194 \ + --hash=sha256:7312731c7826e6c99cdd3ac503cd9acd300598e7a80bcf41f604fee5f49f566c \ + --hash=sha256:75204a1dd7ec6158c8db85a2f14a68d2143503f4bafb9a00b63fe09d35762a5e \ + --hash=sha256:7592f40175c723c032cdbe9fe5165b3b5903604f774ab0849363386e99e1f253 \ + --hash=sha256:7b9dc5a90e2149643df7f23634fe202fed5ebc787a2a1be95cf23632b4d90651 \ + --hash=sha256:7df3fd35ebc14dafeea031038a99232b32f53fa4c3ecddb8bed132a43eefb8ad \ + --hash=sha256:800bf998e78dae655008dd10b22ca8dc93bdcfcc82f620d754a411592da4bbf2 \ + --hash=sha256:8b4257307e3662aa65e2644a277ca68783c5d51190ed9c49efebdd3cbfd5fa44 \ + --hash=sha256:90712dfc775b2c7a07d4d8e059dd58636bd6ff1776d79857776152e693bddea6 \ + --hash=sha256:9b0f2680ce8a70f77f5d70aaf3f013d53e6af6d7058727a35d8ceb4a71cdd4e9 \ + --hash=sha256:a5d2f44331cf04689eafac7a6596c71d6657967c07ac700b0ae1c921178645da \ + --hash=sha256:aae4d9e1b4c7b61780f0a006c897a4a1904f862fdab1abb3ea8f45bd11aa58f3 \ + --hash=sha256:adf445a49d9a97a5a4c9bb1d652a1528de09dd1c48b29f79f3d66cea9f826bf6 \ + --hash=sha256:af4639f684f425177d09ae409c07602c4096a6287027469157bfb6f83e01448b \ + --hash=sha256:afff311e9f065a8f03c3753db7011bae7beb73a66189c7ea5fcb0456b7041ea4 \ + --hash=sha256:b01a9af52a0d5c46b2c68e3f258fdef2eacaa0ce6ae3e9eb97983f5b1166edb6 \ + --hash=sha256:b522be14a28e6ac1cf818599aeff1004a28b42df4ed4d7bc819887b9dac915fc \ + --hash=sha256:b5ac3d5c5825e30b438ea92845380e812a476d6c2a1872b76026f2e9d8060fc2 \ + --hash=sha256:b6a6961fc48821d84b1198a09516e396d56551e910d489692126e90bf4887d29 \ + --hash=sha256:b7316d3edeba8a403686cdcad4af737b8415493101e7462a70ff73dd0609eafc \ + --hash=sha256:b738282e12a05f400b291966630a98d622da0938caa4bc93cf65adb5f4281c60 \ + --hash=sha256:bab10165db6a7994e67001733f7f2caf3400b3e11538409d8756bc9b1c64f7e8 \ + --hash=sha256:bea8d30e362180aafecabbdcbe0e1f0b32c9fa9e39c38e4af037b9d3ca36f50c \ + --hash=sha256:c0d1f7c3908357ee100aa64c4d1cf91edf99c40ac0069422a4fd5fd23b263263 \ + --hash=sha256:c3af9f9f22a67a8c9466a32115d9073c72a33ae627b11de6f592df0ee09b98b6 \ + --hash=sha256:c96e3b872bf883090ddf32cc41957edf819c5336ab0007d0cf3854e61841726d \ + --hash=sha256:cd90027e6d93e8982f7d0d23acf88c896d18deff1903dd96140613389b25c0dd \ + --hash=sha256:d2e43ccdba1cb5c6d3448eadf6fc0dae7be6c77e357a3abc968d1b44e265866d \ + --hash=sha256:d36a807a24c7d44f71686685ae6fbc8793d784bca1adf4c89f5f780b835b6243 \ + --hash=sha256:d7ff6ebb43bc81b057724e89550b13c9a30eda0f29c2f506f8b009895438f5a6 \ + --hash=sha256:d8cd622c069368d5074bd93817b31bdb02f8d818e57c29e206f10a1f9c6337dd \ + --hash=sha256:dda9aa4c33435147262cd2ea87c6b7a1ca83ba9b3933ff7df34e69fee9fced0c \ + --hash=sha256:e788e5d5dcae8f6118ac9b45d0b891a0d55f7ac480eddcb7f07263f2bcf37b23 \ + --hash=sha256:e87cec407ec004cf1b04c0ed7219a68c12860123dfb8902ef880d3d87a71c172 \ + --hash=sha256:ea7423d8a2f9e160c5e011119741682414c5b8dce4ae56590a966316a07a4618 \ + --hash=sha256:ed22f9665327a981f288a4f758a432824dc0314e4195a0eaeb0da56a477da94d \ + --hash=sha256:ed24406454bb5a31df18f0a423ae14beb27b28cdfa34f6268e7ebddf23da807e \ + --hash=sha256:f7f241488879d91a136b299e0c4ce091996c684a53775e63bb442d1a8e9ae22a \ + --hash=sha256:ff0004c3f5a9a6574689a553d1b7819d1a496b4f005a7451f339dc2d9f4cf98c # via python-jsonrpc-server zipp==3.11.0 \ --hash=sha256:83a28fcb75844b5c0cdaf5aa4003c2d728c77e05f5aeabe8e95e56727005fbaa \