From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matthias Meulien Newsgroups: gmane.emacs.devel Subject: About commands to manage Python imports Date: Sat, 1 Jul 2023 18:14:32 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000041384d05ff6f3b12" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23953"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jul 01 18:15:51 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qFdGJ-00067E-GJ for ged-emacs-devel@m.gmane-mx.org; Sat, 01 Jul 2023 18:15:51 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qFdFI-0005QF-NL; Sat, 01 Jul 2023 12:14:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qFdFH-0005Py-HM for emacs-devel@gnu.org; Sat, 01 Jul 2023 12:14:47 -0400 Original-Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qFdFF-0000d8-RM for emacs-devel@gnu.org; Sat, 01 Jul 2023 12:14:47 -0400 Original-Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-992bc8b5c5cso297035266b.0 for ; Sat, 01 Jul 2023 09:14:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688228084; x=1690820084; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=SczOEuXv7BjQ4mPMqlOwWL9tccdH2hkCuPTtXgyHHCI=; b=rFm2htgrZ55/3QFMcIGnqc5EGfx3g02uEopYMKEZX+M86/eJOSBIJjTAL6BJGkOt9v EXp8wyGzMV2y5FKV4zURAxmOJ1hfrASFwS07sctSgz9q8tPiiARiXlFGwNAz+xLHGsGw mxC/JSRmVHO1MkeLHg+SsvlAuRWK5uh0tbV6agXZyVbfgXvaS/FNmddUXX5Hz10XOFUj u8IOYwvoF5iM2MiVnzBFmTjo9ce4ijbgQCR9haUdfhXS/oQQ72VhOvjGP56IhsH/NeDz sjwBoa1WGlqk2R6/qHt22Fs4WdP5R2nHOLaWPQww3cpO1+fVe4D/Wbe6erP0NuVq+DpZ rh8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688228084; x=1690820084; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=SczOEuXv7BjQ4mPMqlOwWL9tccdH2hkCuPTtXgyHHCI=; b=Mcg6S8F+zpluh4KkUY6QJovKnwgeduRKZURxJlZ3QIWKEPaXrbXMBbzqx3PvT39mqH mp4pOjW1p2pDk/gHN7L3rEu0VVzrsVAqDUX65FHprMMjP4bPS5DU0ruoBZ67ZO3HUv1e rkZYLT3A6QcU+Sz7q6yl6qAmU5YSy50oiISYpEQj+x8jvMvldET4/awUnkJuROaD7YvQ YlRZPifFf2eIDpNJG3flRJg1vBe1J/8LlEX1T3P8Ia6F1uPSLAV350LH1Dmi8XQNQEDU +qaSXj3roHjY3DzHnhSL/MCfCuMaDGmeRxy4+ewlOph8iRJpSltl195YZSSvT6QSDF2a qw+w== X-Gm-Message-State: ABy/qLbG9JFi7Id1Woxx3xFbhlJLIQpetXcWBCUlQOIgbWbgkYlMGK13 aW/Cki/FG5AV/dBcDZU6w8LNAEk8jL7a4AYwLtf5xec+w2Qw7w== X-Google-Smtp-Source: APBJJlFrFRzjojJMAFxrkYGzaPuKld50H8KG2oMhWooWGRAj2TaoLTFUhCmPQt5/7oVqhtvE4hVWQDeBbC4WVNfcDxQ= X-Received: by 2002:a17:906:af79:b0:974:55ea:1ad8 with SMTP id os25-20020a170906af7900b0097455ea1ad8mr4100138ejb.63.1688228084134; Sat, 01 Jul 2023 09:14:44 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::634; envelope-from=orontee@gmail.com; helo=mail-ej1-x634.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:307332 Archived-At: --00000000000041384d05ff6f3b12 Content-Type: text/plain; charset="UTF-8" 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 --00000000000041384d05ff6f3b12 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
If I read the logs correctly, commands python-add-imp= ort, python-fix-imports, etc. will be introduced with Emacs 29. I am surpri= sed there's no NEWS item related to those commands. Are the menu entri= es considered enough?

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

=C2=A0=C2=A0=C2=A0 from isort imp= ort find_imports_in_stream, find_imports_in_paths

but find_imports_i= n_stream and find_imports_in_paths were introduced in
version 5.7.0 of t= he isort library.

Debian bookworm has isort version 5.6.4 in its pac= kage repositories. Thus the
commands python-add-import, python-fix-impor= ts, and python-remove-import
don't work as expected on such system.<= /div>

Could one apply the following patch to make the ex= pected version clear to Emacs users?

diff --git a/lisp/= progmodes/python.el b/lisp/progmodes/python.el
index d9ca37145e1..353dd9= 60a4e 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/pyth= on.el
@@ -6420,7 +6420,7 @@ python--list-imports
=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0(mapcar #'file-local-name source)))))
=C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 lines)
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0(unless (eq 0 status)
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(= error "%s exited with status %s (maybe isort is missing?)"
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(error "%s exited with status %s (ma= ybe isort>=3D5.7.0 is missing?)"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 python-interpreter status))
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0(goto-char (point-min))
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0(while (not (eobp))
@@ -6465,7 +6465,7 @@ python--do-isort
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "-m" "isort" &qu= ot;-" args))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0(tick (buffer-chars-modified-tick)))
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0(unless (eq 0 status)
- =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0(error "%s exited with status %s (maybe isort = is missing?)"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(er= ror "%s exited with status %s (maybe isort>=3D5.7.0 is missing?)&qu= ot;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 python-interpreter status))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0(replace-buffer-contents temp)
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0(not (eq tick (buffer-chars-modified-tick)))))))))<= br>

--
Matthias
--00000000000041384d05ff6f3b12--