unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* About commands to manage Python imports
@ 2023-07-01 16:14 Matthias Meulien
  2023-07-01 16:45 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Matthias Meulien @ 2023-07-01 16:14 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1914 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 2476 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-07-02  4:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-01 16:14 About commands to manage Python imports Matthias Meulien
2023-07-01 16:45 ` Eli Zaretskii
2023-07-01 19:23   ` Matthias Meulien
2023-07-01 20:19     ` Matthias Meulien
2023-07-02  4:49     ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).