diff options
| author | Timothy Crosley <timothy.crosley@gmail.com> | 2020-12-30 15:05:27 -0800 |
|---|---|---|
| committer | Timothy Crosley <timothy.crosley@gmail.com> | 2020-12-30 15:05:27 -0800 |
| commit | 8b83d56588e9d4d0cf2e37c893de3f20ef78c3f8 (patch) | |
| tree | 8d169a076a9066aeafebc24f172dfc2f2019fb8e /isort | |
| parent | 0b072150304d582ffd67b9343f1dd30a73043625 (diff) | |
| download | isort-8b83d56588e9d4d0cf2e37c893de3f20ef78c3f8.tar.gz | |
Fix handling of yield and raise statements in import identification
Diffstat (limited to 'isort')
| -rw-r--r-- | isort/identify.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/isort/identify.py b/isort/identify.py index 7a909306..1f8185cb 100644 --- a/isort/identify.py +++ b/isort/identify.py @@ -57,6 +57,25 @@ def imports( if skipping_line: continue + stripped_line = line.strip().split("#")[0] + if stripped_line.startswith("raise") or stripped_line.startswith("yield"): + if stripped_line == "yield": + while not stripped_line or stripped_line == "yield": + try: + index, next_line = next(indexed_input) + except StopIteration: + break + + stripped_line = next_line.strip().split("#")[0] + while stripped_line.endswith("\\"): + try: + index, next_line = next(indexed_input) + except StopIteration: + break + + stripped_line = next_line.strip().split("#")[0] + continue + line, *end_of_line_comment = line.split("#", 1) statements = [line.strip() for line in line.split(";")] if end_of_line_comment: |
