From 77da28f06a534c441dc3e56508b060192ef26f50 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 22 Jul 2019 00:37:34 +0200 Subject: [PATCH] lang/python: use correct executables for flycheck --- modules/lang/python/config.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/lang/python/config.el b/modules/lang/python/config.el index f76e3feb4..570466343 100644 --- a/modules/lang/python/config.el +++ b/modules/lang/python/config.el @@ -43,6 +43,24 @@ called.") (when (featurep! +lsp) (add-hook 'python-mode-local-vars-hook #'lsp!)) + (add-hook 'python-mode-hook + (defun +python-use-correct-flycheck-executables-h () + "Use the correct Python executables for Flycheck." + (let ((executable python-shell-interpreter)) + (save-excursion + (save-match-data + (when (or (looking-at "#!/usr/bin/env \\(python[^ \n]+\\)") + (looking-at "#!\\([^ \n]+/python[^ \n]+\\)")) + (setq executable (substring-no-properties (match-string 1)))))) + ;; Try to compile using the appropriate version of Python for + ;; the file. + (setq-local flycheck-python-pycompile-executable executable) + ;; We might be running inside a virtualenv, in which case the + ;; modules won't be available. But calling the executables + ;; directly will work. + (setq-local flycheck-python-pylint-executable "pylint") + (setq-local flycheck-python-flake8-executable "flake8")))) + (define-key python-mode-map (kbd "DEL") nil) ; interferes with smartparens (sp-local-pair 'python-mode "'" nil :unless '(sp-point-before-word-p