-
-
Notifications
You must be signed in to change notification settings - Fork 584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Float-to-top causes imports to appear above a module's docstring #1499
Float-to-top causes imports to appear above a module's docstring #1499
Comments
Temporary fix is to add
after line 208 in https://github.com/PyCQA/isort/blob/develop/isort/parse.py#L208 |
Also I think it would be better if there is an empty line after the module comment and the imports. These change seems to handle it (it preserve existing empty lines): if skipping_line:
out_lines.append(line)
continue
elif (
config.float_to_top
and import_index == -1
and line
and not in_quote
and not line.strip().startswith("#")
and not line.strip().startswith('"""')
and not line.strip() != ""
):
import_index = index - 1
while import_index and not in_lines[import_index - 1]:
import_index -= 1 |
@willfrey Thank you for reporting! This is fixed in develop and will be released in the 5.6.0 release of isort slated for early October. ~Timothy |
Thank you for fixing this! |
Update: this has just been released to PyPI in 5.6.0 release of isort: https://pycqa.github.io/isort/CHANGELOG/#560-october-7-2020 Thanks! ~Timothy |
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.However, the code snippet will be reformatted with the import above the 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!
The text was updated successfully, but these errors were encountered: