Skip to content

Commit fe57bfd

Browse files
committed
Add edge case future imports handler.
1 parent e8c127b commit fe57bfd

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

isort/output.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def sorted_imports(
8888
lines_between = [""] * (
8989
config.lines_between_types if from_modules and straight_modules else 0
9090
)
91-
if config.from_first:
91+
if config.from_first or section == "FUTURE":
9292
section_output = from_imports + lines_between + straight_imports
9393
else:
9494
section_output = straight_imports + lines_between + from_imports
@@ -153,6 +153,16 @@ def sorted_imports(
153153
if pending_lines_before or not no_lines_before:
154154
output += [""] * config.lines_between_sections
155155

156+
# if (
157+
# section == "FUTURE"
158+
# and len(section_output) > 1
159+
# and not section_output[0].startswith("from")
160+
# ):
161+
# print(">>> section", section)
162+
# print(">>> output", section_output)
163+
# section_output = [section_output[1], section_output[0]]
164+
# print(">>> output", section_output)
165+
156166
output += section_output
157167

158168
pending_lines_before = False
@@ -226,6 +236,7 @@ def sorted_imports(
226236
else:
227237
formatted_output[imports_tail:0] = [""]
228238

239+
# print(">>> formatted_output", formatted_output)
229240
if parsed.place_imports:
230241
new_out_lines = []
231242
for index, line in enumerate(formatted_output):

0 commit comments

Comments
 (0)