Sort by length doesn't really sort by length
Please see the following issue that I raised with ruff: issue
The gist is I can't get isort to truly sort by length as for statements that use the from keyword to import modules, eg:
from package.subpackage.module import function
It does not count anything including or after the import statement towards the line length. For example, when sorting by line length the output would be something like this.
from package.short.path import more_functions, another_function
from package.with.long.path import fn
I'm not sure if this is intended but for me personally it seems to make more sense that the total line length should be taken into account, not just the length of the module.
P.S. As a side note, as a possible new feature, it would be really great if there was an option to import statements that span multiple lines at the bottom of the section, sort of in a subsection. I say subsection because ideally the main sections could have line breaks but the subsections wouldn't. Something like the following would be really cool
import x
from x import y
from x.subpackage.module import function1
from x.module import (
function2,
function3,
function4,
function5,
)
import k # New section
from k.subpackage.module import j
from k.module import (
fn1,
fn2,
fn3,
)
It doesn't appear that isort sorts by line length. This may be difference between expectations and what isort supports.
Please close this issue to reduce the number of issues to address in the backlog. Thanks!
Can we change this to a feature request then? I think most people would expect the same behaviour as I did for sort by length. Not sure in what instances the current behaviour of isort sort by length would be desired