Skip to content

Float-to-top causes imports to appear above a module's docstring #1499

@willfrey

Description

@willfrey

With default settings only float-to-top enabled, imports end up getting placed above a module's docstring.

For example, I don't expect the following code block to change when I run isort over it with float-to-top enabled.

"""I'm a module-level docstring."""

import this

However, the code snippet will be reformatted with the import above the docstring.

import this

"""I'm a module-level docstring."""

Single-line comments starting with a # appear to be unaffected and will remain at the top, so shebangs and encoding comments are safe.

Is this intentional behavior? If so, is there any way to disable this?

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions