Fix python setup for mspyls

This commit is contained in:
Jeremy Dormitzer 2020-05-29 14:35:29 -04:00
parent 887252589f
commit f67f639c0f

View File

@ -2930,15 +2930,48 @@ And support pyenv (NOT pyvenv) to change Python versions:
Use the LSP python client:
#+BEGIN_SRC emacs-lisp
(defun python-lsp ()
(when (derived-mode-p 'python-mode)
(lsp-deferred)))
(add-hook 'hack-local-variables-hook #'python-lsp)
(use-package lsp-python-ms
:init
(setq lsp-python-ms-auto-install-server t)
(defun python-lsp ()
(require 'lsp-python-ms)
(lsp-deferred))
:hook
(python-mode . python-lsp)
:general
(python-mode-map "C-c C-d" #'lsp-describe-thing-at-point))
(general-def 'normal python-mode-map "C-c C-d" #'lsp-describe-thing-at-point)
#+END_SRC
Override the flycheck python-mypy checker to run in the right
directory:
#+BEGIN_SRC emacs-lisp
(flycheck-define-checker python-mypy
"Mypy syntax and type checker. Requires mypy>=0.580.
See URL `http://mypy-lang.org/'."
:command ("mypy"
"--show-column-numbers"
(config-file "--config-file" flycheck-python-mypy-config)
(option "--cache-dir" flycheck-python-mypy-cache-dir)
source-original)
:error-patterns
((error line-start (file-name) ":" line (optional ":" column)
": error:" (message) line-end)
(warning line-start (file-name) ":" line (optional ":" column)
": warning:" (message) line-end)
(info line-start (file-name) ":" line (optional ":" column)
": note:" (message) line-end))
:modes python-mode
;; Ensure the file is saved, to work around
;; https://github.com/python/mypy/issues/4746.
:predicate flycheck-buffer-saved-p
:working-directory (lambda (checker)
(projectile-compilation-dir)))
#+END_SRC
** Autoflake
[[https://pypi.org/project/autoflake/][Autoflake]] is a tool that removes unused imports and variables from Python code:
#+BEGIN_SRC emacs-lisp
@ -5252,7 +5285,7 @@ Some functions to make my day job easier.
(format "$WORKON_HOME/%s" venv)))
(substitute-in-file-name
(format "$WORKON_HOME/%s" venv)))
((t (error "virtual environment %s does not exist" venv))))))
(t (error "virtual environment %s does not exist" venv)))))
(call-with-env-from-file (format "%s/bin/activate" venv-dir) callback)))
(defun get-latest-lola-log (prefix)
@ -5428,35 +5461,35 @@ Some functions to make my day job easier.
(prodigy-define-service
:name "priceline-service"
:tags '(lola backend)
:command "~/lola/python-services/priceline/bin/start.sh"
:command "~/lola/python_services/priceline/bin/start.sh"
:args '("web")
:cwd "~/lola/python-services"
:cwd "~/lola/python_services"
:stop-signal 'int
:init-async (python-service-setup "~/lola/python-services/.venv"
"~/lola/python-services/priceline/.env"
:env-dir "~/lola/python-services"))
:init-async (python-service-setup "~/lola/python_services/.venv"
"~/lola/python_services/priceline/.env"
:env-dir "~/lola/python_services"))
(prodigy-define-service
:name "threev-service"
:tags '(lola backend)
:command "~/lola/python-services/threev/bin/start.sh"
:command "~/lola/python_services/threev/bin/start.sh"
:args '("web")
:cwd "~/lola/python-services"
:cwd "~/lola/python_services"
:stop-signal 'int
:init-async (python-service-setup "~/lola/python-services/.venv"
"~/lola/python-services/threev/.env"
:env-dir "~/lola/python-services"))
:init-async (python-service-setup "~/lola/python_services/.venv"
"~/lola/python_services/threev/.env"
:env-dir "~/lola/python_services"))
(prodigy-define-service
:name "ean-hotels-service"
:tags '(lola backend)
:command "~/lola/python-services/ean_hotels/bin/start.sh"
:command "~/lola/python_services/ean_hotels/bin/start.sh"
:args '("web")
:cwd "~/lola/python-services"
:cwd "~/lola/python_services"
:stop-signal 'kill
:init-async (python-service-setup "~/lola/python-services/.venv"
"~/lola/python-services/ean_hotels/.env"
:env-dir "~/lola/python-services"))
:init-async (python-service-setup "~/lola/python_services/.venv"
"~/lola/python_services/ean_hotels/.env"
:env-dir "~/lola/python_services"))
(prodigy-define-service
:name "email-template-service"