Pylsp config is not used

Hi,

I have been unable to change any of the settings or activate/deactivate plugins in my pylsp setup, after reducing my config to just this to disable mccabe, and still I am seeing complexity warnings on python functions:

require('lspconfig').pylsp.setup {
  settings = {
    pylsp = {
      plugins = {
        mccabe = { enabled = false }
      }
    }
  }
}

My setup:
$ pylsp --version
pylsp v1.4.1

NeoVim 0.8.0:

$ nvim --version
NVIM v0.8.0-dev+60-ga75efc237
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=malloc -Wsuggest-attribute=cold -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az32-981

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"

Run :checkhealth for more info

:checkhealth shows nothing relevant to python, pylsp, or lsp-config going wrong.

After opening a trivial file with a trivial function in it, I see the mccabe warning that a cyclomatic complexity of 2 is too high. (in case anyone was wondering why there are so many questions on this discourse asking how to turn off the mccabe plugin)

def foo(bar):          'foo' is too complex (2)
    if bar:
        print("bar")
    print("after bar")

I later found out that flake8, which is on by default, has a mccabe complexity warning, also on by default. I used this code in my lspconfig.lua file:

local flake_ignores = {"E203", -- whitespace before :
                       "W503", -- line break before binary operator
                       "E501", -- line too long
                       "C901"} -- mccabe complexity
local settings = {
  pylsp = {
    plugins = {
      mccabe = { enabled = false },
      flake8 = {
        enabled = true,
        ignore = table.concat(flake_ignores, ",")
      }
    }
  },
}
1 Like