* 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
* Re: About commands to manage Python imports
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
0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2023-07-01 16:45 UTC (permalink / raw)
To: Matthias Meulien; +Cc: emacs-devel
> From: Matthias Meulien <orontee@gmail.com>
> 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?
It's an omission. Feel free to write a NEWS entry and post it.
> --- 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?)"
Thanks, but the "isort>=5.7.0" part is quite cryptic. Can we do
better?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: About commands to manage Python imports
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
0 siblings, 2 replies; 5+ messages in thread
From: Matthias Meulien @ 2023-07-01 19:23 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1948 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?
>
> It's an omission. Feel free to write a NEWS entry and post it.
>
Here is a proposal:
diff --git a/etc/NEWS b/etc/NEWS
index 9e6f0c16bcd..f9621ef9164 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -3056,6 +3056,12 @@ Without a prefix argument, the kind of shell
(buffer-dedicated,
project-dedicated or global) is specified by the new
'python-shell-dedicated' user option.
+*** New commands to manage Python imports.
+'python-add-import', 'python-import-symbol-at-point',
+'python-remove-import', 'python-fix-imports', 'python-sort-imports'.
+The implementation relies on the Python library isort in version at
+least 5.7.0.
+
** Ruby Mode
---
> > --- 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?)"
>
> Thanks, but the "isort>=5.7.0" part is quite cryptic. Can we do
> better?
>
Yes, I'll work on it. I'll report a bug and send a patch there.
--
Matthias
[-- Attachment #2: Type: text/html, Size: 2933 bytes --]
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: About commands to manage Python imports
2023-07-01 19:23 ` Matthias Meulien
@ 2023-07-01 20:19 ` Matthias Meulien
2023-07-02 4:49 ` Eli Zaretskii
1 sibling, 0 replies; 5+ messages in thread
From: Matthias Meulien @ 2023-07-01 20:19 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 181 bytes --]
> Thanks, but the "isort>=5.7.0" part is quite cryptic. Can we do
>> better?
>>
>
> Yes, I'll work on it. I'll report a bug and send a patch there.
>
See bug#64406.
--
Matthias
[-- Attachment #2: Type: text/html, Size: 743 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: About commands to manage Python imports
2023-07-01 19:23 ` Matthias Meulien
2023-07-01 20:19 ` Matthias Meulien
@ 2023-07-02 4:49 ` Eli Zaretskii
1 sibling, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2023-07-02 4:49 UTC (permalink / raw)
To: Matthias Meulien; +Cc: emacs-devel
> From: Matthias Meulien <orontee@gmail.com>
> Date: Sat, 1 Jul 2023 21:23:12 +0200
> Cc: emacs-devel <emacs-devel@gnu.org>
>
> > > 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?
> >
> > It's an omission. Feel free to write a NEWS entry and post it.
> >
>
> Here is a proposal:
>
> diff --git a/etc/NEWS b/etc/NEWS
> index 9e6f0c16bcd..f9621ef9164 100644
> --- a/etc/NEWS
> +++ b/etc/NEWS
> @@ -3056,6 +3056,12 @@ Without a prefix argument, the kind of shell
> (buffer-dedicated,
> project-dedicated or global) is specified by the new
> 'python-shell-dedicated' user option.
>
> +*** New commands to manage Python imports.
> +'python-add-import', 'python-import-symbol-at-point',
> +'python-remove-import', 'python-fix-imports', 'python-sort-imports'.
> +The implementation relies on the Python library isort in version at
> +least 5.7.0.
> +
> ** Ruby Mode
Thanks. Two minor points: it should begin with "The new commands...",
and it should say at least something about what these commands do.
I'd also replace "in version" with "whose version".
Thanks.
^ permalink raw reply [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).