summaryrefslogtreecommitdiff
path: root/isort/parse.py
diff options
context:
space:
mode:
Diffstat (limited to 'isort/parse.py')
-rw-r--r--isort/parse.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/isort/parse.py b/isort/parse.py
index 92bb46b5..8172808d 100644
--- a/isort/parse.py
+++ b/isort/parse.py
@@ -332,7 +332,8 @@ def file_contents(contents: str, config: Config = DEFAULT_CONFIG) -> ParsedConte
categorized_comments["nested"].setdefault(import_from, {})[
import_name
] = associated_comment
- comments.pop(comments.index(associated_comment))
+ if associated_comment in comments:
+ comments.pop(comments.index(associated_comment))
if comments:
categorized_comments["from"].setdefault(import_from, []).extend(comments)