Skip to content

Conversation

@hfrentzel
Copy link
Contributor

Some pylint flags may have spaces in them. For example --init-hook="import sys; sys.path.append(...". Beginning in v1.7.0 I started seeing this error when running the server

"pylsp.plugins.pylint_lint - Error calling pylint: 'Traceback (most recent call last):
  File \"<string>\", line 1, in <module>
  File \"/home/hfrentzel/.local/lib/python3.9/site-packages/pylint/lint/run.py\", line 132, in __init__
    args = _preprocess_options(self, args)
  File \"/home/hfrentzel/.local/lib/python3.9/site-packages/pylint/config/utils.py\", line 271, in _preprocess_options
    cb(run, value)
  File \"/home/hfrentzel/.local/lib/python3.9/site-packages/pylint/config/utils.py\", line 167, in _init_hook
    exec(value)  # pylint: disable=exec-used
  File \"<string>\", line 1
    \"import
           ^
SyntaxError: EOL while scanning string literal
'
"

The issue is that the --init-hook flag is being split up incorrectly when passed to pylint. This PR switches to using shlex.split() instead of just a normal string split() to split the args as a shell would.

@ccordoba12 ccordoba12 added this to the v1.7.1 milestone Jan 17, 2023
Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks for your contribution @hfrentzel!

@ccordoba12 ccordoba12 merged commit 52a0d54 into python-lsp:develop Jan 17, 2023
@hfrentzel hfrentzel deleted the shlex.split branch January 17, 2023 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants