python-language-server icon indicating copy to clipboard operation
python-language-server copied to clipboard

Add support for # noqa

Open maxnordlund opened this issue 7 years ago • 12 comments

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

maxnordlund avatar Mar 01 '18 16:03 maxnordlund

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.

gatesn avatar Mar 25 '18 08:03 gatesn

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

randy3k avatar May 07 '18 16:05 randy3k

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

languitar avatar May 28 '18 09:05 languitar

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!

joaqo avatar Jun 18 '18 16:06 joaqo

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.

emanspeaks avatar Nov 09 '18 02:11 emanspeaks

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

kierun avatar Nov 12 '18 08:11 kierun

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.

doronbehar avatar Dec 03 '18 12:12 doronbehar

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

screenshot

It is kinda annoying but is no deal breaker…

kierun avatar Sep 26 '19 12:09 kierun

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... ;)

BorgPrincess avatar May 29 '20 11:05 BorgPrincess

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:

  • nvim 0.6.0-dev
  • Plugin prabirshrestha/vim-lsp
  • Plugin prabirshrestha/async.vim
  • Plugin prabirshrestha/asyncomplete.vim
  • Plugin prabirshrestha/asyncomplete-lsp.vim
  • Plugin mattn/vim-lsp-settings
    • :LspInstallServer pylsp-all
  • Plugin dense-analysis/ale
  • Plugin rhysd/vim-lsp-ale
  • Additional PyPi package: neovim
  • Additional PyPi package: pylsp
  • Additional PyPi package: pyls-flake8
# ~/.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 },
\               }
\           }
\       }
\   },
\}

kevr avatar Oct 21 '21 15:10 kevr

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?

gatesn avatar Oct 21 '21 20:10 gatesn

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

joelthelion avatar Sep 10 '22 21:09 joelthelion