-
Notifications
You must be signed in to change notification settings - Fork 284
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
Support Flake8 plugins and configuration #190
Comments
So you need to set |
I try it and nothing changed. This option parse |
I have a
But I still get errors about the length of the line of more than 79 characters. A similar problem if the file is named Why not use flake8 directly (as optional feature, for example)? I use some flake8-plugins, for example, |
The reasoning is that there are lots of tools for python linting, and to avoid keeping up with all of them, we would just integrate with the core set of tools that actually do the lifting. These being pycodestyle, pydocstyle, pyflakes, pylint etc. Aggregation tools, such as flake8, pylama etc. tend to add lots of duplication. However, you raise a very good point around plugins for these tools, as well as the complexity we now have to deal with around configuration options. I'll give it a think, but it may just be easier to provide plugins for these tools and then allow the user to enable/disable plugins to get their preferred set of tools. |
@gatesn If I'm installed python-language-server via pypi where do I change |
Depends which client you’re using?
…________________________________
From: purpleP <[email protected]>
Sent: Wednesday, January 10, 2018 8:39:40 AM
To: palantir/python-language-server
Cc: Nicholas Gates; Mention
Subject: Re: [palantir/python-language-server] Flake8 linting (#190)
@gatesn<https://github.com/gatesn> If I'm installed python-language-server via pypi where do I change configurationSources
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#190 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AB1rdOR7H10C8b_75Ky-8oJ-LEScOI6cks5tJHdMgaJpZM4QczKr>.
|
@gatesn neovim language server. |
I think you'll have to take a look at this: autozimu/LanguageClient-neovim#139 |
@gatesn
|
@purpleP I still can't seem to reproduce this issue. Can you pass |
Hi, I'm not sure if I'm having the same issue, but it sounds similar. In my situation, changing the For example:
|
EDIT: Got this to work. I had to set @gatesn what is the default value for this variable? If I don't set it, it doesn't appear to be set, and the documentation says the default is Leaving the below for context @purpleP @gatesn did you get this to work? My LanguageClient_neovim seems unable to pick up the setting to look at the
This is my
This is my
I also tried this:
Neither of these worked, is one of them supposed to? This is my dummy script
|
I am using LanguageClient-neovim too and wanted to disable the linting so I set the variable to [] but like op I don't see any change.
|
Does anyone have a working .vim/settings.json for Neovim's LanguageClient_Neovim I could have? I've been trying all night trying to get it to respect my ~/.config/flake8 all i want is for it to ignore docstrings. |
I've done some testing with this as well. My LanguageClient-neovim {
"pyls": {
"plugins": {
"pycodestyle": {
"enabled": true,
"ignore": [
"E501"
],
"select": [
"C",
"E",
"F",
"W",
"B",
"B950"
]
}
},
"configurationSources": [
"pycodestyle",
"flake8"
]
}
} And I have it configured to run
But then the value of the
On the other hand, if I remove the {
"pyls": {
"plugins": {
"pycodestyle": {
"enabled": true,
"ignore": [
"E501"
]
}
},
"configurationSources": [
"pycodestyle",
"flake8"
]
}
} Then it works just fine. So I played around with it some more:
It appears that:
This behaviour is fairly different to
And also partly different to
ConclusionI believe there are two problems:
For now, I'll just disable |
Thanks for the awesome report @Shados . I have a perfectly fine ~/.config/pycodestyle/config I would very much love to be respected by pyls. Corssing fingers for a fix. |
I created a quick-and-dirty pyls plugin called pyls-flake8. Once you install it with pip, I set the pyls config to disable pyflakes and pycodestyle, restarted the server, and voila. |
@emanspeaks python2 support...? |
Can we expect support for flake8 plugins in the near future? |
I'm a sublime user, but I had the same issue as OP, .flake8 config file not being picked up. "LSP": {
"pyls": {
"syntaxes": ["Packages/Python/Python.sublime-syntax", "Packages/Djaneiro/Syntaxes/Python Django.tmLanguage"],
"command": ["/Users/my_user/.virtualenvs/webappv2/bin/pyls"],
"enabled": true,
"scopes": ["source.python"],
"settings": {
"pyls": {
"configurationSources": ["flake8"],
"plugins": {
"autopep8": {
"enabled": false
},
"yapf": {
"enabled": false
}
}
}
},
}
} The main trick was adding the nested "pyls" prop inside the "settings" dictionary. PS -- I was also forced to restart the language server on every change to this config. I'm not sure why it's the case but it might prevent false negatives when testing the config with your own editor. |
I'm looking to do this as well. What was the configuration needed for |
@mikew The relevant "pyls": {
"plugins": {
"pycodestyle": {
"enabled": false
}
}
} You'll have to figure out how to get your LSP client to pass on the settings, but that should be all you need to disable |
I want to point out that in the common case, you're going to want to configure your language server to match exactly what lint settings you are enforcing in, e.g., CI. Not supporting, e.g., flake8 behavior exactly, means the user has to do a bunch of work manually enabling the constituent bits to replicate the lint setting locally. |
@gatesn We can start supporting flake8 by introducing a new plugin under To load the plugin on startup we need to list it under |
It seems that flake8 is not enabled by default in pyls. I am currently using vim-lsp with pyls, the following config works for me: if executable('pyls')
" pip install python-language-server
au User lsp_setup call lsp#register_server({
\ 'name': 'pyls',
\ 'cmd': {server_info->['pyls']},
\ 'allowlist': ['python'],
\ 'workspace_config': {
\ 'pyls':
\ {'configurationSources': ['flake8'],
\ 'plugins': {'flake8': {'enabled': v:true},
\ 'pyflakes': {'enabled': v:false},
\ 'pycodestyle': {'enabled': v:false},
\ }
\ }
\ }})
endif The the flake8 config is put in |
I'm using neovim/nvim-lspconfig Similar to @ckm2k1 I needed to add a settings key to get flake8 to work, however, still no luck with mypy require("lspconfig").pyls.setup(
{
enable = true,
settings = {
pyls = {
configurationSources = {"flake8"},
plugins = {
pycodestyle = {enabled = false},
flake8 = {enabled = true},
pyls_mypy = {
enabled = true,
live_mode = false
},
jedi_completion = {fuzzy = true}
}
}
},
on_attach = custom_attach
}
) |
Don't know why but
I don't have However if I put ignore directive:
it starts to respect everything inside it (E402 is not shown, E226 is shown). What could be the reason for such strange behavior? |
I observe the same behaviour: I would like to set the |
I found the answer
https://flake8.pycqa.org/en/2.5.5/config.html#default @GaetanLepage
|
Can I use flake8 tool for linting? I looked in package.json, but did not find there the corresponding options.
if I change
configurationSources
to ['flake'], then I do not see any changes andpyflakes
continues to be used. I storeflake8
settings in .flake8
file for all projects.If this is important, I use lsp-mode in Emacs and LanguageClient-neovim in Neovim as clients.
The text was updated successfully, but these errors were encountered: