python-lsp / python-lsp-server

Fork of the python-language-server project, maintained by the Spyder IDE team and the community
MIT License
1.96k stars 195 forks source link

pyflakes configuration #106

Open pag opened 3 years ago

pag commented 3 years ago

As far as I can tell there is no way to configure pyflakes to ignore certain warning (e.g. 'f-string is missing placeholders'). Does that sound right? If so I'll happily submit a pull request to add some configurability to plugins/pyflakes_lint.py, e.g. reading a file at ~/config/pyflakes.

michaelaye commented 2 years ago

pyflakes also cannot cope with line-based # noqa instructions, which is why flake8 is preferrable (which uses pyflakes internally), but I have yet to manage to run flake8 successfully with pylsp. :(

doolio commented 2 years ago

@michaelaye have you tried these instructions from the README.

If you would like to use flake8, you will need to:

  1. Disable pycodestyle, mccabe, and pyflakes, by setting their corresponding enabled configurations, e.g. pylsp.plugins.pycodestyle.enabled, to false. This will prevent duplicate linting messages as flake8 includes these tools.
  2. Set pylsp.plugins.flake8.enabled to true.
  3. Change the pylsp.configurationSources setting (in the value passed in from your client) to ['flake8'] in order to use the flake8 configuration instead.

It has likely been updated since you posted here. What client are you using?

AloisMahdal commented 5 months ago

This works for me in neovim 0.10.0 with pylsp v1.11.0 installed using Mason and configured using mason-lspconfig:

-- ... --
settings = {
    pylsp = {
        configurationSources = { "flake8" },
        plugins = {
            -- ... --
            pylint = { enabled = false },
            pyflakes = { enabled = false },
            mccabe = { enabled = false },
            pycodestyle = { enabled = false },
            flake8 = {
                enabled = true,
                maxLineLength = 120,
                maxComplexity = 15,
            },
            -- ... --
        },
    },
},
-- ... --

This is the only way i found to have everything I need: