isort icon indicating copy to clipboard operation
isort copied to clipboard

Force to top should support *specific* ordering

Open jannisborn opened this issue 1 year ago • 0 comments

Currently when "force to top" is being used with multiple packages, then it forces all of them to the top but unfortunately does so in an alphabetical manner.

When setting:

force_to_top = ["torch", "tensorflow"]

The result will be:

import tensorflow
import torch

whereas it should be:

import torch
import tensorflow

Currently, it seems that isort does not support the ability to set multiple imports at the top of a section with a user-specified ordering. This is prohibitive because, unfortunately, some python packages have strict order import requirements.

I hope that I'm missing something! Any idea on how to solve this with isort would be much appreciated!

jannisborn avatar May 05 '23 14:05 jannisborn