summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Crosley <timothy.crosley@gmail.com>2019-11-20 23:46:39 -0800
committerTimothy Crosley <timothy.crosley@gmail.com>2019-11-20 23:46:39 -0800
commit28322bc4de4e3c47373156de113f579fa44f882a (patch)
tree04b5721a9a4c7aa22ea6b764d8be673451d55382
parentcbb62cbc222511bc551c59301aa967c5407f20e8 (diff)
downloadisort-28322bc4de4e3c47373156de113f579fa44f882a.tar.gz
Remove nested comments from import block identifcation code
-rw-r--r--isort/parse.py38
1 files changed, 1 insertions, 37 deletions
diff --git a/isort/parse.py b/isort/parse.py
index 73e2917e..02c1d630 100644
--- a/isort/parse.py
+++ b/isort/parse.py
@@ -503,18 +503,10 @@ def identify_contiguous_imports(
if import_index == -1:
import_index = index - 1
- nested_comments = {}
+
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 (
- type_of_import == "from"
- and len(line_parts) == 2
- and line_parts[1] != "*"
- and comments
- ):
- nested_comments[line_parts[-1]] = comments[0]
-
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])
@@ -522,13 +514,6 @@ def identify_contiguous_imports(
if new_comment:
comments.append(new_comment)
stripped_line = _strip_syntax(line).strip()
- if (
- type_of_import == "from"
- and stripped_line
- and " " not in stripped_line
- and new_comment
- ):
- nested_comments[stripped_line] = comments[-1]
import_string += line_separator + line
else:
while line.strip().endswith("\\"):
@@ -544,13 +529,6 @@ def identify_contiguous_imports(
and index < line_count
):
stripped_line = _strip_syntax(line).strip()
- if (
- type_of_import == "from"
- and stripped_line
- and " " not in stripped_line
- and new_comment
- ):
- nested_comments[stripped_line] = comments[-1]
import_string += line_separator + line
while not line.strip().endswith(")") and index < line_count:
@@ -559,23 +537,9 @@ def identify_contiguous_imports(
if new_comment:
comments.append(new_comment)
stripped_line = _strip_syntax(line).strip()
- if (
- type_of_import == "from"
- and stripped_line
- and " " not in stripped_line
- and new_comment
- ):
- nested_comments[stripped_line] = comments[-1]
import_string += line_separator + line
stripped_line = _strip_syntax(line).strip()
- if (
- type_of_import == "from"
- and stripped_line
- and " " not in stripped_line
- and new_comment
- ):
- nested_comments[stripped_line] = comments[-1]
if import_string.strip().endswith(" import") or line.strip().startswith(
"import "
):