ruff
56127792 - [isort] Simplify code structure for ordering imports (#8685)

Commit
1 year ago
[isort] Simplify code structure for ordering imports (#8685) While fixing #8661 I noticed that the code structure for sorting imports could be simplified. ## Summary - Move the logic for `force_sort_within_sections` from `isort/mod.rs` to `isort/ordering.rs` => now there is just one line in `isort/mod.rs`: `let imports = order_imports(import_block, settings);` which yields the sorted imports - Change the function signature of `order_imports` to directly return a `Vec<EitherImport<'a>>` => no need for `OrderedImportBlock` I think this is a bit of an improvement because the code is simpler and there should be a bit of a speedup when setting `force-sort-within-sections` to true. Indeed, when it's set to true we're now directly ordering all the imports, whereas before we would first order the straight imports, then the from imports, combine them and finally sort the combination a second time (this is probably not noticeable in practice though). ## Test Plan No tests added, this is a simple refactor.
Author
Parents
Loading