How to use Pylint in Python LSP?

I want to use Pylint as linter for Python code using Python LSP. I have Pylint installed and have this in .config/doom/config.el.

(setq lsp-pylsp-plugins-flake8-enabled f)
(setq lsp-pylsp-plugins-autopep8-enabled f)
(setq lsp-pylsp-plugins-pyflakes-enabled f)
(setq lsp-pylsp-plugins-pylint-enabled t)

But when I open a Python file and add it to projects (as prompted by LSP), Pylint doesn’t get activated.

This is what M-x flycheck-verify-setup gives:

Syntax checkers for buffer two_sum.py in python-mode:

First checker to run:

  lsp (explicitly selected)
    - may enable: yes
    - may run:    t

Checkers that could run if selected:

  python-pylint  select
    - may enable:         yes
    - executable:         Found at /home/arun-mani-j/.local/bin/pylint
    - configuration file: Not found
    - next checkers:      python-mypy

  python-pycompile  select
    - may enable:    yes
    - executable:    Found at /usr/bin/python3
    - next checkers: python-mypy

  python-mypy  select
    - may enable:         yes
    - may run:            t
    - executable:         Found at /home/arun-mani-j/.local/bin/mypy
    - configuration file: Not found

Checkers that are compatible with this mode, but will not run until properly configured:

  python-flake8 (automatically disabled) reset
    - may enable:         no
    - executable:         Not found
    - configuration file: Not found
    - next checkers:      python-pylint, python-mypy

  python-pyright (automatically disabled) reset
    - may enable: no
    - executable: Not found

Flycheck Mode is enabled. Use C-u C-c ! x to enable disabled checkers.

--------------------

Flycheck version: 32snapshot
Emacs version:    28.2
System:           x86_64-pc-linux-gnu
Window system:    x

Why does Pylint get disabled even though I have set it to be enabled? Am I doing it wrong?

System information


Loading data dump...

Thanks for reading :)

Not sure if you ever found a solution, but I had the same issue and was able to solve it by adding a python-mode hook to set the checker explicitly:

(add-hook 'python-mode-hook #'(lambda () (setq flycheck-checker 'python-pylint)))

Which I found here: If flake8 is installed, pylint isn't ran. · Issue #185 · flycheck/flycheck · GitHub

Hii. Thanks for the follow up. Your code seems to set the Flychecker’s linter itself from lsp to pylint. Though it works, I’m wondering why LSP Server doesn’t respect the lsp-pylsp-plugins-* variables or is it a bug in Python LSP Server itself? :thinking:

This topic was automatically closed after 360 days. New replies are no longer allowed.