Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Pylint run to set cwd correctly #322

Merged
merged 2 commits into from
Dec 29, 2022

Conversation

Corentin-pro
Copy link
Contributor

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 use py_run (from pylint.epylint) will not use the proper working directory.

If __init__.py are not present as py_run will call lint from the same file. The lint 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 from pylint.lint can enable proper usage of cwd exactly as the flake8 plugins does (set to document._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#L171

If anything can be improved in this PR I will gladly make any change suggested.

Corentin added 2 commits December 29, 2022 00:14
* Call pylint.lint's Run directly instead of pylint.epylint's py_run
  (py_run is also deprecated and set to be removed in pylint 3.0)
@ccordoba12 ccordoba12 added this to the v1.7.0 milestone Dec 29, 2022
@ccordoba12 ccordoba12 changed the title Change pylint run to set cwd correctly Change Pylint run to set cwd correctly Dec 29, 2022
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 a lot @Corentin-pro for your contribution!

@ccordoba12 ccordoba12 merged commit 89375e0 into python-lsp:develop Dec 29, 2022
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