3 ms·
Give µsort a try instead; it's focused on providing more safety when applying sorting to large codebases, and is designed to pair well with black out of the box
by jreese 5y ago
Give µsort a try instead; it's focused on providing more safety when applying sorting to large codebases, and is designed to pair well with black out of the box:
https://usort.readthedocs.io https://usort.readthedocs.io
https://ufmt.omnilib.dev https://ufmt.omnilib.dev
- Spiritus 5y agoFor me µsort is a non-starter since it doesn't ignore the import/from part when sorting lexicographically. So when an import changes from `import foo` to `from foo import bar` (and vice versa), the import is moved. Sorting should start at the package name, nothing else.
- jreese 5y agoI suspect you are fighting the tide of common practice in the Python community. In your example, switching from `import foo` to `from foo import bar` is changing the entire nature of the import. Sorting module- and from-imports separately also makes it much easier for many people to visually scan a block of imports. And similar to black, having a tool be consistent and predictable across projects and modules is more important than bikeshedding every possible opinion.
- Spiritus 5y ago> I suspect you are fighting the tide of common practice in the Python community. I hope not! > Sorting module- and from-imports separately also makes it much easier for many people to visually scan a block of imports. For me it's the opposite. My brain skips over the irrelevant parts (i.e. import/from). Not moving the import also produces better git diffs