syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.68k stars 4.89k forks source link

LSP and Python: flake8 settings are not honored #15137

Closed synic closed 2 years ago

synic commented 2 years ago

Description :octocat:

LSP and Python: flake8 settings are not honored

Reproduction guide :beetle:

Observed behaviour: :eyes: :broken_heart:

Emacs ignores the flake8 configuration. Errors that are set to be ignored (for example, D100, D103) are shown in flyckeck.

I have tried telling LSP where the configuration file is using .dir-locals.el:

((python-mode
  (eval . (python-black-on-save-mode))
  (fill-column . 88)
  (auto-fill-mode . -1)
  (flycheck-flake8rc . "/pythonlsptest/.flake8")
  (lsp-pylsp-plugins-flake8-config . "/pythonlsptest/.flake8")
 ))

However, this appears to have no effect.

Expected behaviour: :heart: :smile:

The flake8 configuration should be honored like it is in company-mode

System Info :computer:

Backtrace :paw_prints:

<<BACKTRACE IF RELEVANT>>
lebensterben commented 2 years ago

try M-x flycheck-select-checker and choose python-flake8

synic commented 2 years ago

@lebensterben This does work, thanks! How do I get it to automatically select python-flake8?

I've got this setup in my .dir-locals.el:

((python-mode
  (eval . (python-black-on-save-mode))
  (fill-column . 88)
  (auto-fill-mode . -1)
  (flycheck--automatically-disabled-checkers . '(python-pylint lsp python-pycompile))
  (flycheck--automatically-enabled-checkers . '(python-flake8))
  (flycheck-add-next-checker 'python-flake8 'lsp)
))

but it sure doesn't want to disable lsp as a checker

lebensterben commented 2 years ago

set flycheck-checker

synic commented 2 years ago

It doesn't work, for some reason lsp gets enabled by default, even with the following:

((python-mode
  (eval . (python-black-on-save-mode))
  (fill-column . 88)
  (auto-fill-mode . -1)
  (flycheck-flake8rc . "/home/synic/Projects/defiq-coinprice-lambda/.flake8")
  (lsp-pylsp-plugins-flake8-config . "/home/synic/Projects/defiq-coinprice-lambda/.flake8")
  (flycheck-checker . 'python-flake8)
))

I've got this in my spacemacs config as well:

  (add-hook 'python-mode-hook
            (lambda ()
              ;; Enable fill column indicator
              ;; (display-fill-column-indicator-mode)
              (display-fill-column-indicator-mode)
              ;; Turn on line numbering
              ;; (linum-mode t)
              (setq fill-column 79)
              ;; set in-block indentation scale
              (setq python-indent-def-block-scale 1)
              ;; Set tab-width to 4
              (setq tab-width 4
                    evil-shift-width 4)
              (setq flycheck-checker 'python-flake8)
              ;; Enable automatic line wrapping at fill column
              (auto-fill-mode t)))

When I check the flycheck setup, is shows lsp as "explicitly selected"

lebensterben commented 2 years ago

lsp blackend is enabled whenever lsp layer is enabled. you have to explicitly set python layer variable to disable it.

this is not a bug and I'm transferring it to discussion.