Change Pylint run to set cwd correctly #322
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since
__init__.py
are not necessary using the pylint plugins will miss configuration files is such files are not present.Explanation
In
pylsp.plugins/pylint_lint.py
the usepy_run
(frompylint.epylint
) will not use the proper working directory.If
__init__.py
are not present aspy_run
will calllint
from the same file. Thelint
function traverse parent folder as long as a__init__.py
is present (see https://github.com/PyCQA/pylint/blob/main/pylint/epylint.py#L65).Directly calling
Run
frompylint.lint
can enable proper usage ofcwd
exactly as the flake8 plugins does (set todocument._workspace.root_path
, see https://github.com/python-lsp/python-lsp-server/blob/develop/pylsp/plugins/flake8_lint.py#L114).Additional Points
py_run
is deprecated and to be removed in pylint 3.0 : https://github.com/PyCQA/pylint/blob/main/pylint/epylint.py#L171If anything can be improved in this PR I will gladly make any change suggested.