You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The README states when configuring flake8 one must
Change the pylsp.configurationSources setting (in the value passed in from your client) to ['flake8'] in order to use the flake8 configuration instead.
However, the CONFIGURATION suggests the value is either ["pycodestyle"] or ["pyflakes"].
Which document is correct? I set it to ["flake8"] and it seems to work. Thanks for your time.
It is however not clear to me if pyflakes should be there; there is no config source for those (unless it comes from a plugin):
True but maybe there should be considering flake8 is just a wrapper around pyflakes (which is really the error checker), pycodestyle and mccabe (plus others if also available such as pydocstyle (with flake8-docstrings), pep8-naming etc.).
That is perhaps pylsp.configurationSources should accept all three possibilities:
["pyflakes"] if you only want to check for code errors
["pycodestyle"] if you only want to check for style errors
["flake8"] if you want to check for both plus the added ability to check for complexity (via mccabe), docstrings (via pydocstyle + flake8-docstrings), PEP8 naming (via pep8-naming) etc.
I think the whole situation with configurationSources has derailed a bit.
Here me out.
It seems like introducing pylsp.configurationSources was a misguided decision (at least for flake8) as flake8 can and will read the relevant configuration files itself, regardless of that setting.
The pylsp.configurationSources might have been introduced because someone realized that some of the configuration settings, specifically ones that depend on file path/name, do not work. That is because the files are linted through stdin and flake8 is not aware of actual file path.
So someone added custom code to read the settings in flake8 pylsp plugin and apply those settings to linted files. So now we have a pylsp.configurationSources setting that is only really relevant for some of the settings but for other is not even needed.
The proper solution IMO would be to just make flake8 aware of the actual file path by using the --stdin-display-name argument that it supports. It can be set to an actual path so that all the rules that work based on file path can work properly.
(I might be missing something as I'm not a big user of flake8 but I was thinking about it yesterday)
The proper solution IMO would be to just make flake8 aware of the actual file path by using the --stdin-display-name argument that it supports. It can be set to an actual path so that all the rules that work based on file path can work properly.
Thanks for analyzing the situation in depth @rchl. Could you create a pull request that implements your proposed solution?
The proper solution IMO would be to just make flake8 aware of the actual file path by using the --stdin-display-name argument that it supports. It can be set to an actual path so that all the rules that work based on file path can work properly.
Thanks for analyzing the situation in depth @rchl. Could you create a pull request that implements your proposed solution?
Maybe I'd do that if I had more time but would still not be sure what extent of changes is expected here. Whether removing the flake8 form pylsp.configurationSources and all related code that manually reads the configuration would be OK or not.
Activity
krassowski commentedon Sep 12, 2022
Thanks for opening an issue.
flake8clearly should have been included (see test case inpython-lsp-server/test/plugins/test_flake8_lint.py
Line 99 in fa27a2b
python-lsp-server/pylsp/config/config.py
Line 53 in 98dc9c0
It is however not clear to me if
pyflakesshould be there; there is no config source for those (unless it comes from a plugin):python-lsp-server/pylsp/config/config.py
Lines 50 to 60 in 98dc9c0
doolio commentedon Sep 14, 2022
True but maybe there should be considering
flake8is just a wrapper aroundpyflakes(which is really the error checker),pycodestyleandmccabe(plus others if also available such aspydocstyle(withflake8-docstrings),pep8-namingetc.).That is perhaps
pylsp.configurationSourcesshould accept all three possibilities:["pyflakes"]if you only want to check for code errors["pycodestyle"]if you only want to check for style errors["flake8"]if you want to check for both plus the added ability to check for complexity (viamccabe), docstrings (viapydocstyle + flake8-docstrings), PEP8 naming (viapep8-naming) etc.doolio commentedon Sep 20, 2022
Any further thoughts on this?
rchl commentedon Sep 20, 2022
I think the whole situation with
configurationSourceshas derailed a bit.Here me out.
It seems like introducing
pylsp.configurationSourceswas a misguided decision (at least for flake8) as flake8 can and will read the relevant configuration files itself, regardless of that setting.The
pylsp.configurationSourcesmight have been introduced because someone realized that some of the configuration settings, specifically ones that depend on file path/name, do not work. That is because the files are linted through stdin and flake8 is not aware of actual file path.So someone added custom code to read the settings in flake8 pylsp plugin and apply those settings to linted files. So now we have a
pylsp.configurationSourcessetting that is only really relevant for some of the settings but for other is not even needed.The proper solution IMO would be to just make flake8 aware of the actual file path by using the
--stdin-display-nameargument that it supports. It can be set to an actual path so that all the rules that work based on file path can work properly.(I might be missing something as I'm not a big user of flake8 but I was thinking about it yesterday)
ccordoba12 commentedon Sep 25, 2022
Thanks for analyzing the situation in depth @rchl. Could you create a pull request that implements your proposed solution?
rchl commentedon Sep 27, 2022
Maybe I'd do that if I had more time but would still not be sure what extent of changes is expected here. Whether removing the
flake8formpylsp.configurationSourcesand all related code that manually reads the configuration would be OK or not.ccordoba12 commentedon Sep 28, 2022
If it's not really necessary, then I'm +1 with doing that.