emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

About commands to manage Python imports


From: Matthias Meulien
Subject: About commands to manage Python imports
Date: Sat, 1 Jul 2023 18:14:32 +0200

If I read the logs correctly, commands python-add-import, python-fix-imports, etc. will be introduced with Emacs 29. I am surprised there's no NEWS item related to those commands. Are the menu entries considered enough?

They're really cool commands (despite bug#64397). Let me suggest one easy improvement. The variable python--list-imports starts with:

    from isort import find_imports_in_stream, find_imports_in_paths

but find_imports_in_stream and find_imports_in_paths were introduced in
version 5.7.0 of the isort library.

Debian bookworm has isort version 5.6.4 in its package repositories. Thus the
commands python-add-import, python-fix-imports, and python-remove-import
don't work as expected on such system.

Could one apply the following patch to make the expected version clear to Emacs users?

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index d9ca37145e1..353dd960a4e 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -6420,7 +6420,7 @@ python--list-imports
                                 (mapcar #'file-local-name source)))))
              lines)
         (unless (eq 0 status)
-          (error "%s exited with status %s (maybe isort is missing?)"
+          (error "%s exited with status %s (maybe isort>=5.7.0 is missing?)"
                  python-interpreter status))
         (goto-char (point-min))
         (while (not (eobp))
@@ -6465,7 +6465,7 @@ python--do-isort
                                "-m" "isort" "-" args))
                 (tick (buffer-chars-modified-tick)))
             (unless (eq 0 status)
-              (error "%s exited with status %s (maybe isort is missing?)"
+              (error "%s exited with status %s (maybe isort>=5.7.0 is missing?)"
                      python-interpreter status))
             (replace-buffer-contents temp)
             (not (eq tick (buffer-chars-modified-tick)))))))))

--
Matthias

reply via email to

[Prev in Thread] Current Thread [Next in Thread]