palantir / python-language-server

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

Add support for # noqa #281

Open maxnordlund opened 6 years ago

maxnordlund commented 6 years ago

This is used at least by pycodestyle and flake8 to ignore a certain line from all linting. I personally use it when from .conftest import * # noqa in pytest.

https://github.com/PyCQA/pycodestyle/issues/476

gatesn commented 6 years ago

I also see that noqa is not respected, though I can't see any reason why it wouldn't be! Will need to dig in a bit more.

randy3k commented 6 years ago

I believe that it is because pyflakes doesn't support # noqa. Do we have the option to use flake8 instead?

languitar commented 6 years ago

I am not sure what raises the "imported but unused" warnings, but that also doesn't seem to respect this comment.

joaqo commented 6 years ago

If you go about adding support for inline noqa flags, please consider also adding support for flake8: noqa at the beginning of the file to ignore warnings/errors in the whole file too! Thanks!

emanspeaks commented 6 years ago

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--I had all my familiar noqa options back.

kierun commented 5 years ago

Same issue using the sure module which needs # noqa since you never use it as-is.

doronbehar commented 5 years ago

Well done @emanspeaks , you've helped me a lot! I think it'd be great if you'll create a PR for the '3rd party plugins' section in the README.

kierun commented 5 years ago

It has been a while, so here's a screenshot:

screenshot

It is kinda annoying but is no deal breaker…

BorgPrincess commented 4 years ago

This would also be a nice feature to work for warnings - much nicer to "wave through" a single line than to give Carte Blanche to all deprecation warnings project wide... ;)

kevr commented 3 years ago

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--I had all my familiar noqa options back.

You are a champion.

For anyone else dealing with this, my setup:

# ~/.config/nvim/init.vim - vim-lsp-settings configuration
" Language Server Protocol configuration
let g:lsp_settings = {
\   'pylsp-all': {
\       'workspace_config': {
\           'pylsp': {
\               'configurationSources': ['flake8'],
\               'plugins': {
\                   'pycodestyle': { 'enabled': 0 },
\                   'pyflakes': { 'enabled': 0 },
\                   'flake8': { 'enabled': 1 },
\               }
\           }
\       }
\   },
\}
gatesn commented 3 years ago

It does seem like at this point in time Flake8 has become the dominant linter. I'm not sure it was quite so convincing in the past.

But perhaps now the defaults should swap over to that? Any objections?

joelthelion commented 2 years ago

Is there still a plan to make flake8 the default some day?