diff options
author | Timothy Crosley <timothy.crosley@gmail.com> | 2019-11-21 23:42:42 -0800 |
---|---|---|
committer | Timothy Crosley <timothy.crosley@gmail.com> | 2019-11-21 23:42:42 -0800 |
commit | 3b4c669058baccafb9d7dafa0cd25d2c317162f7 (patch) | |
tree | 9eb3cc0b9425efc124d15a04c01daf75e3410c01 | |
parent | 28322bc4de4e3c47373156de113f579fa44f882a (diff) | |
download | isort-3b4c669058baccafb9d7dafa0cd25d2c317162f7.tar.gz |
Start moving line index usage out, relying instead on streaming through file
-rw-r--r-- | isort/parse.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/isort/parse.py b/isort/parse.py index 02c1d630..1239359b 100644 --- a/isort/parse.py +++ b/isort/parse.py @@ -507,17 +507,17 @@ def identify_contiguous_imports( import_string, comment = parse_comments(line) comments = [comment] if comment else [] line_parts = [part for part in _strip_syntax(import_string).strip().split(" ") if part] - if "(" in line.split("#")[0] and index < line_count: - while not line.strip().endswith(")") and index < line_count: - line, new_comment = parse_comments(in_lines[index]) - index += 1 + if "(" in line.split("#")[0]: + while not line.strip().endswith(")"): + line, new_comment = parse_comments(line) if new_comment: comments.append(new_comment) stripped_line = _strip_syntax(line).strip() import_string += line_separator + line + line = input_stream.readline() else: while line.strip().endswith("\\"): - line, new_comment = parse_comments(in_lines[index]) + line, new_comment = parse_comments(line) index += 1 if new_comment: comments.append(new_comment) @@ -531,9 +531,8 @@ def identify_contiguous_imports( stripped_line = _strip_syntax(line).strip() import_string += line_separator + line - while not line.strip().endswith(")") and index < line_count: - line, new_comment = parse_comments(in_lines[index]) - index += 1 + while not line.strip().endswith(")"): + line, new_comment = parse_comments() if new_comment: comments.append(new_comment) stripped_line = _strip_syntax(line).strip() |