How can I use flycheck virtualenv

I just happily configured emacs with jedi autocompletion and syntax checking with flycheck and virtualenvs created in bootstrap. Everything seems to work.

I would like to add the ability to use flycheck-pylint (to get errors in the import), but I can't get it to work. Even if I manually change virtualenv (Mx: pyvenv-activate RET path-to-my-venv), I still see many import errors that come from misuse of virtualenv.

My current initialization code is:

(require 'pyvenv)
(add-hook 'after-init-hook #'global-flycheck-mode)
(defun set-flake8-executable ()
  (pyvenv-activate (get-current-buffer-venv))
  (flycheck-set-checker-executable (quote python-flake8)
               (get-current-buffer-flake8)))

where "get-current-buffer-venv" and "get-current-buffer-flake8" are functions that implement my specific setup and work correctly.

How can I change the interpreter used?

+4
1

Lunaryorn on github , --- . :

(defun set-flychecker-executables ()
  "Configure virtualenv for flake8 and lint."
  (when (get-current-buffer-flake8)
    (flycheck-set-checker-executable (quote python-flake8)
                                     (get-current-buffer-flake8)))
  (when (get-current-buffer-pylint)
    (flycheck-set-checker-executable (quote python-pylint)
                                     (get-current-buffer-pylint))))
(add-hook 'flycheck-before-syntax-check-hook
          #'set-flychecker-executables 'local)
+8

Source: https://habr.com/ru/post/1598139/


All Articles