PR #4493 is now in devel

21 views
Skip to first unread message

Edward K. Ream

unread,
Jan 10, 2026, 8:20:51 AMJan 10
to leo-editor
PR #4493 uses ruff format when  @bool beautify-python-code-on-write = True

I merged it immediately because the PR removes a "race" condition when beautifying python code automatically. Previously, ruff format and Leo's legacy formatter would be in conflict. Now, once again, it's safe to set @bool beautify-python-code-on-write to True.

There will be one more PR related to ruff format. This PR will acknowledge what's already so, namely that @beautify and @nobeautify no longer have any effect. Leo's users should use the fmt: pragmas instead.

This PR will move Leo's legacy beautifier to the attic. I'll wait longer for review comments for this last PR.

All your comments are welcome. Please report any problems immediately.

Edward

Thomas Passin

unread,
Jan 10, 2026, 9:16:35 AMJan 10
to leo-editor
On Saturday, January 10, 2026 at 8:20:51 AM UTC-5 Edward K. Ream wrote:
PR #4493 uses ruff format when  @bool beautify-python-code-on-write = True

There will be one more PR related to ruff format. This PR will acknowledge what's already so, namely that @beautify and @nobeautify no longer have any effect. Leo's users should use the fmt: pragmas instead.

What the heck are those? Where do we find information about them? 

jkn

unread,
Jan 10, 2026, 3:57:37 PMJan 10
to leo-editor
They are (I presume) the ruff pragmas mentioned in the first of Edwards posts on this topic, a thread or two ago

Edward K. Ream

unread,
Jan 10, 2026, 5:34:59 PMJan 10
to leo-e...@googlegroups.com


On Sat, Jan 10, 2026 at 2:57 PM jkn <jkn...@nicorp.co.uk> wrote:

They [the way to control syntax coloring] are (I presume) the ruff pragmas mentioned in the first of Edwards posts on this topic, a thread or two ago.

Yes, ruff's (and black's) #fmt pragmas are now the main way to control beautification. I rather like them, especially #fmt: skip.

It's not exactly true that @beautify and @nobeautify have no effect, but their effects are limited to languages other than Python.

HTH. All questions are welcome.

Edward

Edward K. Ream

unread,
Jan 10, 2026, 5:39:19 PMJan 10
to leo-e...@googlegroups.com
See this page. You can search Leo's code for fmt: on, fmt: off, and fmt: skip. All three are useful in various situations.

Edward

Thomas Passin

unread,
Jan 12, 2026, 4:37:31 PMJan 12
to leo-editor
That's all very well but how would we apply fmt: on, etc,  when we want to run ruff from within Leo?

Edward K. Ream

unread,
Jan 12, 2026, 5:10:18 PMJan 12
to leo-e...@googlegroups.com
On Mon, Jan 12, 2026 at 3:37 PM Thomas Passin <tbp1...@gmail.com> wrote:

See this page. You can search Leo's code for fmt: on, fmt: off, and fmt: skip. All three are useful in various situations.

That's all very well but how would we apply fmt: on, etc,  when we want to run ruff from within Leo?

I get that the new workflow is confusing. I'll be documenting the new workflow and settings in the new release notes.

The main idea is to use # fmt statements to control ruff format within your Python files.

You can then run ruff format outside of Leo. Or within Leo if you set the following settings as shown:

@bool beautify-python-code-on-write = True
@bool write-black-sentinels = True

You can also specify line length with this setting:

@int black-line-length = 120

I'd be happy to zoom with you about all this if you would like.

Edward
Reply all
Reply to author
Forward
0 new messages