palantir / python-language-server

An implementation of the Language Server Protocol for Python
MIT License
2.61k stars 285 forks source link

Project specific max-line-length not #433

Open IamGianluca opened 6 years ago

IamGianluca commented 6 years ago

I have a .flake8 file in my project which defines some choices my team made about code style, including max line length of 100 characters.

[flake8]
ignore = W503,E501,E203
exclude = alembic_scripts
max-line-length = 100
import-order-style = pep8

Unfortunately, python-language-server doesn't seem to read such file by default. I've read that the default linter is pycodestyle, so I've tried to set the max line length argument in a setup.cfg. However, in this case, the linter doesn't flag any line, even if longer that 120 characters.

[pycodestyle]
ignore = W503,E501,E203
max-line-length=100
simark commented 5 years ago

Hmm same here, my setup.cfg is picked up by pycodestyle on the command line, but not by pycodestyle as ran by python-language-server.

simark commented 5 years ago

329 is possible related.

dsummersl commented 5 years ago

In vim, putting a pycodestyle in setup.cfg works for me (.pycodestyle does not :( )

jvytee commented 5 years ago

Had a similar problem when trying to set a maximum line length of 120 globally. Configured ~/.config/flake8 and ~/.config/pycodestyle accordingly, but pyls with ALE would still show warnings in lines that exceeded only a length of 100 instead of 120 characters.

Turnes out pip install 'python-language-server[all]' additionally comes with pylint, so generating a global pylint coniguration by pylint --generate-rcfile > ~/.pylintrc and setting max-line-length = 120 there finally solved the issue.

Ecno92 commented 5 years ago

The pycodestyle and pylint plugins are automatically activated when they are found in the virutalenv. In case of using flake8 you do not want this. The easiest way to enforce proper flake8 behaviour is by using pyls-flake8. Since my latest commit got merged by the maintainer it disables the other plugins to make sure that everything is done through flake8.

From my experience this is easier than disabling the plugins through the editor configuration.

youben11 commented 5 years ago

pyls now support flake8, you will just need to enable the appropriate plugin.