From e2b2f8d0cab23dc32b9cae25de8e9d3f10b027aa Mon Sep 17 00:00:00 2001 From: Timothy Crosley Date: Thu, 3 Sep 2020 02:31:21 -0700 Subject: [PATCH] Resolve #1382: float to top --- isort/parse.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/isort/parse.py b/isort/parse.py index 980924f17..e15caf3e2 100644 --- a/isort/parse.py +++ b/isort/parse.py @@ -200,6 +200,10 @@ def file_contents(contents: str, config: Config = DEFAULT_CONFIG) -> ParsedConte if skipping_line: out_lines.append(line) continue + elif config.float_to_top and import_index == -1 and line and not in_quote and not line.strip().startswith("#"): + import_index = index - 1 + while import_index and not in_lines[import_index - 1]: + import_index -= 1 line, *end_of_line_comment = line.split("#", 1) if ";" in line: