Open SummerStorm opened 1 year ago
We definitely can fix this but for the reasons you describe it should probably be an opt-in fix once that feature ships.
We definitely can fix this but for the reasons you describe it should probably be an opt-in fix once that feature ships.
Yes, I agree. The user must opt-in via some new flag such as:
[tool.ruff.isort]
float-to-top = true
Is there any news on getting float-to-top added?
Minimal reproducible example
Ruff output and Ruff version
isort
output (and expected Ruff output)isort
has a usefulfloat_to_top
config where all non-indented imports are "floated" to the top of the file. I find this quite useful as I can import anywhere within the file, and the import will automatically "float" to the correct location. I propose that we add afloat-to-top
flag to mirror this behavior:By enabling this flag, the user is signaling to Ruff that it should autofix all such trivial cases of E402. While E402 is impossible to fix in general, I believe that non-indented cases of E402 are autofixable in the vast majority of projects. Here are two cases where re-positioning non-indented imports might break things: