Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if not indent:
import_section += line
if not contains_imports:
output_stream.write(import_section)
else:
if first_import_section and not import_section.lstrip(
line_separator
).startswith(COMMENT_INDICATORS):
import_section = import_section.lstrip(line_separator)
first_import_section = False
if indent:
import_section = line_separator.join(
line.lstrip() for line in import_section.split(line_separator)
)
sorted_import_section = output.sorted_imports(
parse.file_contents(import_section, config=config), config, extension
)
if indent:
sorted_import_section = (
textwrap.indent(sorted_import_section, indent) + line_separator
)
output_stream.write(sorted_import_section)
if indent:
output_stream.write(line)
indent = ""
contains_imports = False
import_section = ""
else: