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

pylintrc not respected in subfolder #616

Open
chthor opened this issue Jul 5, 2019 · 8 comments · May be fixed by #673
Open

pylintrc not respected in subfolder #616

chthor opened this issue Jul 5, 2019 · 8 comments · May be fixed by #673

Comments

@chthor
Copy link

chthor commented Jul 5, 2019

I have the following structure:

root/
  .pylintrc
  wtf.py
  wtf/
    wtf.py
# wtf.py (identical both times)
X = 1
# .pylintrc
[MASTER]
disable=missing-docstring

pylint is ok with both files:

root $ pylint wtf.py

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

root $ pylint wtf/wtf.py

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

I'm running Neovim with LanguageClient-Neovim.

# .vimrc
let g:LanguageClient_serverCommands = {
  \ 'python': ['/usr/local/bin/pyls'],
  \ }

The top-level wtf.py works as expected:

# wtf.py
X = 1  <no warnings here>

But the subfolder version of wtf.py does not respect the pylintrc. I get the missing-docstring warning:

# wtf/wtf.py
X = 1 [missing-docstring] Missing module docstring

Why does pylintrc not apply to the subfolder?

@jml
Copy link

jml commented Jul 27, 2019

I'm being hit by this too, except in Emacs.

From the logs:

2019-07-26 17:44:36,577 UTC - DEBUG - pyls.plugins.pylint_lint - Calling pylint with '/Users/jml/src/myproject/somefolder/another/thingy.py -f json '

The results of this command change depending on which directory it runs in.

From /Users/jml: lots of errors, pylintrc not respected
From /Users/jml/src/myproject/ (where my pylintrc lives): no errors, pylintrc respected
From /Users/jml/src/myproject/somefolder/another/: lots of errors, same as /Users/jml

There's an args setting that the pylint plugin takes (see

pylint_args = settings.get('args')
) but I haven't yet been able to figure out how to actually set it. Will update here if I do.

I guess you could make an argument that pylint (and other external processes) should be run from the project root as a matter of course, which would make this problem go away.

@chthor
Copy link
Author

chthor commented Aug 1, 2019

@jml In my case the problem was a missing __init__.py in the subfolders in question, so they were not acting as proper Python packages. Adding __init__.py resolved my issue. (Not sure if that's relevant to your problem?)

@jml
Copy link

jml commented Aug 1, 2019

Ooh, that's a likely explanation. I haven't verified experimentally, but there are definitely directories missing __init__.py files.

jml added a commit to jml/dotfiles that referenced this issue Sep 17, 2019
Work around the issue
palantir/python-language-server#616, which would be
fixed by emacs-lsp/lsp-mode#928, but is not yet
merged.
@youben11
Copy link
Contributor

.pylintrc files aren't used for linting by pyls for the moment, the way you can configure pylint is by passing a list of arguments (the same arguments you would pass when using the pylint command line tool) like @jml said. In the vscode client you can update "pyls.plugins.pylint.args" to list your agruments in the vscode/package.json file.

@noctuid
Copy link

noctuid commented Oct 12, 2019

Yeah pylintrc is not respected anywhere for me. This issue seems to me to be a feature request for that (though the title should be edited) unless there is already another open issue I missed.

@youben11
Copy link
Contributor

@gatesn I think we should add support for pylint config files as it doesn't seem really obvious to pass config through "pyls.plugins.pylint.args".

@gatesn
Copy link
Contributor

gatesn commented Oct 13, 2019

Yep, agree. I don’t think it should be too hard either since we shell out to pylint - so we should be able to have it discover it’s own config instead of parsing it ourselves

@youben11
Copy link
Contributor

youben11 commented Oct 13, 2019

@chthor the reason why it's not using the .pylintrc config in the subfolder is because pylint is ran under that exact subfolder which doesn't contain a .pylintrc. We should get this fixed by parsing the config file on startup and passing that config to every run of pylint as arguments.

UPDATE: pylint isn't ran under that subfolder, but the fix should still make pylint have the same behavour while linting all project files.

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 a pull request may close this issue.

5 participants