Repository navigation
Replies: 1 comment
|
For three separate statements, you can define those groups explicitly and put import isort
source = """from tkinter import E, N, S, W # Constants
# isort: split
from tkinter import StringVar, Tk # Classes
# isort: split
from tkinter import ttk # Variables
"""
print(isort.code(source), end="")isort keeps those three statements separate, with blank lines before the split comments. You establish the groups; it sorts within each one. I checked that this layout is stable on a second pass with isort 9.0.2 and Python 3.12.14. If grouping the known constants together within one statement is sufficient, this project setting also works on your original input: [tool.isort]
constants = ["E", "N", "S", "W"]It produces: from tkinter import E, N, S, W, StringVar, Tk, ttkI tested that through the CLI with the actual |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
From this:
To this:
Or, otherwise:
I have reviewed the documentation and tried several options, but I don't get it to work.
@_@
All reactions