From 8e844eada1f244e437ff995172eff89710e42c03 Mon Sep 17 00:00:00 2001 From: Rakan Alhneiti Date: Wed, 11 Dec 2019 11:27:50 +0100 Subject: [PATCH 1/5] Add py-isort feature to the python module --- modules/lang/python/config.el | 10 ++++++++++ modules/lang/python/packages.el | 3 +++ 2 files changed, 13 insertions(+) diff --git a/modules/lang/python/config.el b/modules/lang/python/config.el index 66450c698..410e8bee6 100644 --- a/modules/lang/python/config.el +++ b/modules/lang/python/config.el @@ -143,6 +143,16 @@ called.") :desc "Optimize imports" "o" #'+python/optimize-imports))) +(use-package! py-isort + :defer t + :init + (map! :after python + :map python-mode-map + :localleader + (:prefix ("i" . "imports") + :desc "Sort imports" "s" #'py-isort-buffer + :desc "Sort region" "r" #'py-isort-region))) + (use-package! nose :commands nose-mode :preface (defvar nose-mode-map (make-sparse-keymap)) diff --git a/modules/lang/python/packages.el b/modules/lang/python/packages.el index 600af8529..98819857f 100644 --- a/modules/lang/python/packages.el +++ b/modules/lang/python/packages.el @@ -32,3 +32,6 @@ ;; Import managements (package! pyimport) (package! pyimpsort) + +(when (featurep! +isort) + (package! py-isort)) From 7d09921a29b178a254c128ea3305e7cfa0356ed7 Mon Sep 17 00:00:00 2001 From: Rakan Alhneiti Date: Wed, 11 Dec 2019 12:00:29 +0100 Subject: [PATCH 2/5] Add isort feature to readme --- modules/lang/python/README.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/lang/python/README.org b/modules/lang/python/README.org index 57e555f8f..8cf568435 100644 --- a/modules/lang/python/README.org +++ b/modules/lang/python/README.org @@ -31,7 +31,7 @@ Adds Python support to Doom Emacs. ** Plugins + [[https://github.com/pythonic-emacs/anaconda-mode][anaconda-mode]]* + [[https://github.com/Wilfred/pyimport][pyimport]]* -+ [[https://github.com/emacs-pe/pyimpsort.el][pyimpsort]]* ++ [[https://github.com/paetzke/py-isort.el][py-isort]]* + [[https://melpa.org/#/nose][nose]]* + [[https://github.com/wbolster/emacs-python-pytest][python-pytest]]* + [[https://github.com/Wilfred/pip-requirements.el][pip-requirements]]* From eeafec2df0cd84152d1bba8efc3d6c1957d21bef Mon Sep 17 00:00:00 2001 From: Rakan Alhneiti Date: Sun, 15 Dec 2019 16:25:27 +0100 Subject: [PATCH 3/5] Make isort default python import sorting package --- modules/lang/python/config.el | 1 - modules/lang/python/packages.el | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/lang/python/config.el b/modules/lang/python/config.el index 410e8bee6..d8d72f6a7 100644 --- a/modules/lang/python/config.el +++ b/modules/lang/python/config.el @@ -139,7 +139,6 @@ called.") (:prefix ("i" . "imports") :desc "Insert missing imports" "i" #'pyimport-insert-missing :desc "Remove unused imports" "r" #'pyimport-remove-unused - :desc "Sort imports" "s" #'pyimpsort-buffer :desc "Optimize imports" "o" #'+python/optimize-imports))) diff --git a/modules/lang/python/packages.el b/modules/lang/python/packages.el index 98819857f..053f1fb94 100644 --- a/modules/lang/python/packages.el +++ b/modules/lang/python/packages.el @@ -31,7 +31,4 @@ ;; Import managements (package! pyimport) -(package! pyimpsort) - -(when (featurep! +isort) - (package! py-isort)) +(package! py-isort) From a64b3bdceb8b55071ff8330fcea999b839009d67 Mon Sep 17 00:00:00 2001 From: Rakan Alhneiti Date: Sun, 15 Dec 2019 16:25:59 +0100 Subject: [PATCH 4/5] Add an entry in the readme for the isort prequisite --- modules/lang/python/README.org | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/lang/python/README.org b/modules/lang/python/README.org index 8cf568435..b0eff6697 100644 --- a/modules/lang/python/README.org +++ b/modules/lang/python/README.org @@ -67,6 +67,9 @@ This module has no direct prerequisites. Here are some of its soft dependencies. + ~pyimport~ requires Python's module ~pyflakes~: + ~pip install pyflakes~ ++ ~py-isort~ requires [[https://github.com/timothycrosley/isort][isort]] to be installed: + + ~pip install isort~ + + Python virtual environments install instructions at: + [[https://github.com/pyenv/pyenv][pyenv]] + [[https://conda.io/en/latest/][Conda]] From 304af70000f917342b0f893fc3628546e74aa2bb Mon Sep 17 00:00:00 2001 From: Rakan Alhneiti Date: Sun, 15 Dec 2019 16:48:27 +0100 Subject: [PATCH 5/5] Update optimize import to use py-isort --- modules/lang/python/autoload/python.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/lang/python/autoload/python.el b/modules/lang/python/autoload/python.el index 6cfd0429b..4f6ef7f3b 100644 --- a/modules/lang/python/autoload/python.el +++ b/modules/lang/python/autoload/python.el @@ -59,4 +59,4 @@ "organize imports" (interactive) (pyimport-remove-unused) - (pyimpsort-buffer)) + (py-isort-buffer))