Skip to content
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

pylsp does not react to "# noqa" #601

Open
Bazulenkov opened this issue Nov 1, 2024 · 1 comment
Open

pylsp does not react to "# noqa" #601

Bazulenkov opened this issue Nov 1, 2024 · 1 comment

Comments

@Bazulenkov
Copy link

I have neovim and pylsp as LSP server.

This is my config of pylsp:

pylsp = {
    settings = {
      pylsp = {
        plugins = {
          pycodestyle = {
            ignore = { "W391" },
            maxLineLength = 88,
          },
        },
      },
    },
  },

Example of python file:

# app/core/base.py

from app.core.db import Base  # noqa
from app.models.meeting_room import MeetingRoom  # noqa
from app.models.reservation import Reservation  # noqa

I attach the screenshot with errors.
Screenshot from 2024-11-01 15-16-17

@kompoth
Copy link

kompoth commented Mar 15, 2025

Hi! According to Ruff's list of rules these diagnostic messages must be invoked by pyflakes. As well as pycodestyle, pyflakes are enabled by default in pylsp.

I managed to reproduce your issue with the following lspconfig setup for pylsp:

return {
    "neovim/nvim-lspconfig",
    tag = "v0.1.8",
    config = function()
        local lspconfig = require("lspconfig")
        lspconfig.pylsp.setup {
            settings = {
                pylsp = {
                    plugins = {
                        pycodestyle = {enabled = false},
                        pyflakes = {enabled = true},
                    }
                }
            }
        }
    end
}

As you can see, pycodestyle is disabled, and I still got these messages in my Neovim. They disappear when I turn pyflakes off.

Now, according to this discussion pyflakes doesn't support # noqa comments.

# noqa are well supported by Ruff and flake8, the later works in pylsp out-of-the-box, but you'll have to enable it:

pyflakes = {enabled = false},  -- to avoid duplication
flake8 = {enabled = true},

See what I've got with this config:
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants