diff options
Diffstat (limited to 'isort/output.py')
-rw-r--r-- | isort/output.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/isort/output.py b/isort/output.py index 5f2659f7..cd925c91 100644 --- a/isort/output.py +++ b/isort/output.py @@ -1,7 +1,7 @@ import copy import itertools from functools import partial -from typing import Any, Dict, Iterable, List, Optional +from typing import Any, Dict, Iterable, List, Optional, Tuple from isort.format import format_simplified @@ -9,6 +9,8 @@ from . import parse, sorting, wrap from .comments import add_to_line as with_comments from .settings import DEFAULT_CONFIG, Config +STATEMENT_DECLERATIONS: Tuple[str, ...] = ("def ", "cdef ", "cpdef ", "class ", "@", "async def") + def sorted_imports( parsed: parse.ParsedContent, @@ -202,12 +204,7 @@ def sorted_imports( if config.lines_after_imports != -1: formatted_output[imports_tail:0] = ["" for line in range(config.lines_after_imports)] - elif extension != "pyi" and ( - next_construct.startswith("def ") - or next_construct.startswith("class ") - or next_construct.startswith("@") - or next_construct.startswith("async def") - ): + elif extension != "pyi" and next_construct.startswith(STATEMENT_DECLERATIONS): formatted_output[imports_tail:0] = ["", ""] else: formatted_output[imports_tail:0] = [""] |