From 784c6a9e581afa05dcab6358df30b4a7e668d2af Mon Sep 17 00:00:00 2001 From: Ultimator14 Date: Mon, 15 May 2023 13:19:52 +0200 Subject: [PATCH] Fix empty cwd value for pylint (#371) --- pylsp/plugins/pylint_lint.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pylsp/plugins/pylint_lint.py b/pylsp/plugins/pylint_lint.py index 76e990c5..b4a43972 100644 --- a/pylsp/plugins/pylint_lint.py +++ b/pylsp/plugins/pylint_lint.py @@ -48,7 +48,7 @@ class PylintLinter: last_diags = collections.defaultdict(list) @classmethod - def lint(cls, document, is_saved, flags=''): + def lint(cls, document, is_saved, flags=''): # pylint: disable=too-many-locals,too-many-branches """Plugin interface to pylsp linter. Args: @@ -95,8 +95,12 @@ def lint(cls, document, is_saved, flags=''): ] + (shlex.split(str(flags)) if flags else []) log.debug("Calling pylint with '%s'", ' '.join(cmd)) + cwd = document._workspace.root_path + if not cwd: + cwd = os.path.dirname(__file__) + with Popen(cmd, stdout=PIPE, stderr=PIPE, - cwd=document._workspace.root_path, universal_newlines=True) as process: + cwd=cwd, universal_newlines=True) as process: process.wait() json_out = process.stdout.read() err = process.stderr.read()